1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.
Crud
This module gives you an abstract base class to make CRUD forms with. These forms give you by default a tabular view of the objects, where attributes of the object can be edited in-place. Please refer to the ICrudForm interface for more details.
>>> from megrok.z3cform.crud import crud
Form registration
Models
We set up some models to serve as a form context:
>>> import grokcore.component as grok >>> from zope import interface, schema >>> class IPerson(interface.Interface): ... name = schema.TextLine(title=u"Name") ... age = schema.Int(title=u"Age") >>> class Person(grok.Context): ... grok.implements(IPerson) ... name = schema.fieldproperty.FieldProperty(IPerson['name']) ... age = schema.fieldproperty.FieldProperty(IPerson['age']) ... ... def __init__(self, name, age): ... self.name = name ... self.age = age >>> class IPersonContainer(interface.Interface): ... pass >>> class PersonContainer(dict): ... grok.implements(IPersonContainer)
For this test, we take the the name of our persons as keys in our storage:
>>> storage = PersonContainer() >>> storage['Peter'] = Person(u'Peter', 16) >>> storage['Martha'] = Person(u'Martha', 32)
We declare the Form with the help of megrok.z3cform.base. It’s very similar to a grok.View:
>>> import megrok.z3cform.base as z3cform >>> class TestForm(crud.CrudForm): ... grok.context(IPersonContainer) ... ... update_schema = IPerson ... ... def get_items(self): ... return sorted(storage.items(), key=lambda x: x[1].name) ... ... def add(self, data): ... person = Person(**data) ... storage[str(person.name)] = person ... return person ... ... def remove(self, (id, item)): ... del storage[id]
Grokking and querying
We let Grok register the component:
>>> grok.testing.grok_component('form', TestForm)
True
Now, we can query it normally:
>>> from zope.publisher.browser import TestRequest
>>> request = TestRequest()
>>> from zope.component import getMultiAdapter
>>> myform = getMultiAdapter((storage, request), name="testform")
>>> myform
<TestForm object at ...>
>>> print myform()
<form action="http://127.0.0.1" method="post"
enctype="multipart/form-data" class="form-testform">
...
Changelog
0.1
Initial release
Metadata
Release files for megrok.z3cform.crud 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
File added late
1 file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release files before installing.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| megrok.z3cform.crud-0.1.tar.gz | 8.3 kB | Without provenance | Details for megrok.z3cform.crud-0.1.tar.gz |
Release files / megrok.z3cform.crud-0.1.tar.gz
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | megrok.z3cform.crud-0.1.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b0b0a1a91af3611b609e605c87cb7cbc02c74a6c30383e31f1b60c3322e2c4b2
|
|
BLAKE2b-256 checksum How to use checksums |
038560113819a451d8051dae35932fb79f8d74c060a9320c427eeecff2748ce5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for megrok.z3cform.crud 0.1
Upload timing
Release file added late
1 file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.