Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
This package provides a table implementation including form support for Zope3 based on z3c.form and z3c.table.
.. contents::
<form>
tags. Fix the sample and use real subform templates.Fixed package metadata (home page and author e-mail).
Added a default supportsCancel = False to TableBase
Using registerType
from zope.browserpage
instead from
zope.app.pagetemplate
Adjusted test output.
Updated test dependencies so tests run with current z3c.form
versions.
Added doctests to long_description
so they show up on PyPI.
allowEdit
property to SubFormTable
The goal of this package is to offer a modular table rendering library which includes built in support for update forms. This will allow us to adapt items rendered as table row items to forms. This could prevent to use traversable exposed forms for such items. But this is just one of the benefits. See more below.
We need to setup the form defaults first:
from z3c.form.testing import setupFormDefaults setupFormDefaults()
And load the formui confguration, which will make sure that all macros get registered correctly.
from zope.configuration import xmlconfig import zope.component import zope.viewlet import zope.component import zope.app.publisher.browser import z3c.macro import z3c.template import z3c.formui xmlconfig.XMLConfig('meta.zcml', zope.component)() xmlconfig.XMLConfig('meta.zcml', zope.viewlet)() xmlconfig.XMLConfig('meta.zcml', zope.app.publisher.browser)() xmlconfig.XMLConfig('meta.zcml', z3c.macro)() xmlconfig.XMLConfig('meta.zcml', z3c.template)() xmlconfig.XMLConfig('configure.zcml', z3c.formui)()
And load the z3c.tabular configure.zcml:
import z3c.tabular xmlconfig.XMLConfig('configure.zcml', z3c.tabular)()
Let's create a sample container which we can use as our iterable context:
from zope.container import btree class Container(btree.BTreeContainer): ... """Sample container.""" ... name = u'container' container = Container()
and set a parent for the container:
root['container'] = container
and create a sample content object which we use as container item:
import zope.interface import zope.schema class IContent(zope.interface.Interface): ... """Content interface.""" ... ... title = zope.schema.TextLine(title=u'Title') ... number = zope.schema.Int(title=u'Number')
class Content(object): ... """Sample content.""" ... zope.interface.implements(IContent) ... def init(self, title, number): ... self.name = title.lower() ... self.title = title ... self.number = number
Now setup some items:
container[u'first'] = Content('First', 1) container[u'second'] = Content('Second', 2) container[u'third'] = Content('Third', 3)
The FormTable
offers a sub form setup for rendering items within a form.
Let's first define a form for our used items:
from z3c.form import form from z3c.form import field class ContentEditForm(form.EditForm): ... fields = field.Fields(IContent)
Now we can define our FormTable
including the SelectedItemColumn:
from z3c.table import column import z3c.tabular.table class ContentFormTable(z3c.tabular.table.SubFormTable): ... ... subFormClass = ContentEditForm ... ... def setUpColumns(self): ... return [ ... column.addColumn(self, column.SelectedItemColumn, ... u'selectedItem', weight=1), ... ]
And support the div form layer for our request:
from z3c.formui.interfaces import IDivFormLayer from zope.interface import alsoProvides from z3c.form.testing import TestRequest request = TestRequest() alsoProvides(request, IDivFormLayer)
Now we can render our table. As you can see the SelectedItemColumn
renders
a link which knows hot to select the item:
contentSubFormTable = ContentFormTable(container, request) contentSubFormTable.name = 'view.html' contentSubFormTable.update() print contentSubFormTable.render()
Now we are ready to select an item by click on the link. We simulate this by set the relevant data in the request:
selectRequest = TestRequest(form={ ... 'subFormTable-selectedItem-0-selectedItems': 'second'}) alsoProvides(selectRequest, IDivFormLayer) selectedItemTable = ContentFormTable(container, selectRequest) selectedItemTable.name = 'view.html' selectedItemTable.update() print selectedItemTable.render()
Clicking the Edit
button at the same time should hold the same result:
selectRequest = TestRequest(form={ ... 'subFormTable-selectedItem-0-selectedItems': 'second', ... 'subFormTable.buttons.edit': 'Edit'}) alsoProvides(selectRequest, IDivFormLayer) selectedItemTable = ContentFormTable(container, selectRequest) selectedItemTable.name = 'view.html' selectedItemTable.update() print selectedItemTable.render()
Unless allowEdit
is False
.
In this case the editform won't appear.
selectRequest = TestRequest(form={ ... 'subFormTable-selectedItem-0-selectedItems': 'second', ... 'subFormTable.buttons.edit': 'Edit'}) alsoProvides(selectRequest, IDivFormLayer) selectedItemTable = ContentFormTable(container, selectRequest) selectedItemTable.name = 'view.html' selectedItemTable.allowEdit = False selectedItemTable.update() print selectedItemTable.render()
FAQs
Table with form support based on z3c.form and z3c.table for Zope3
We found that z3c.tabular demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.