This release is a pre-release and may not be stable for production use.
dolmen.widget.file
dolmen.widget.file is a package that walks hand-in-hand with dolmen.file. It provides a useable and pluggable way to render the dolmen.file.FileField in a zeam.form Form.
Example
We are going to develop here a small example, to demonstrate the use of dolmen.widget.file. First, we need to create a model content with a file field:
>>> import dolmen.file >>> import grokcore.component as grok >>> from zope.interface import Interface >>> from zope.schema.fieldproperty import FieldProperty >>> class ITravelMount(Interface): ... luggage = dolmen.file.FileField(title=u'Luggages') >>> class Mammoth(grok.Context): ... grok.implements(ITravelMount) ... luggage = FieldProperty(ITravelMount['luggage'])
We now have a travel mammoth on which we can add a luggage. Now, we need a form to edit the animal:
>>> from zeam.form.ztk import Form, Fields
>>> class EditMammoth(Form):
... grok.name('edit')
... grok.context(ITravelMount)
... ignoreContent = False
... fields = Fields(ITravelMount)
>>> grok.testing.grok_component('edit', EditMammoth)
True
Let’s instanciate a Mammoth and try to call the form on it:
>>> from zope.component import getMultiAdapter
>>> from zope.publisher.browser import TestRequest
>>> manfred = Mammoth()
>>> request = TestRequest()
>>> form = getMultiAdapter((manfred, request), name='edit')
>>> form.updateWidgets()
>>> print form.fieldWidgets.get('form.field.luggage').render()
<div id="form-field-luggage">
<input type="file" id="form-field-luggage-input"
name="form.field.luggage" />
</div>
Now, let’s try with a value:
>>> manfred.luggage = "A nice data"
>>> form = getMultiAdapter((manfred, request), name='edit')
>>> form.updateWidgets()
>>> print form.fieldWidgets.get('form.field.luggage').render()
<div id="form-field-luggage">
<div>
<input type="radio" value="keep" checked="checked"
class="noborder" name="form.field.luggage.action"
onclick="document.getElementById('form-field-luggage-input').disabled=true"
id="form-field-luggage-action" />
<label for="form-field-luggage-action">Keep existing file</label>
<br />
<input type="radio" value="delete" class="noborder"
name="form.field.luggage.action"
onclick="document.getElementById('form-field-luggage-input').disabled=true"
id="form-field-luggage-delete" />
<label for="form-field-luggage-delete">Delete existing file</label>
<br />
<input type="radio" value="replace" class="noborder"
name="form.field.luggage.action"
onclick="document.getElementById('form-field-luggage-input').disabled=false"
id="form-field-luggage-replace" />
<label for="form-field-luggage-replace">Replace with new file</label>
</div>
<div>
<input type="file" id="form-field-luggage-input"
name="form.field.luggage" />
<script type="text/javascript">document.getElementById('form-field-luggage-input').disabled=true;</script>
</div>
</div>
Changelog
1.0 alpha 1 (2010-05-14)
Major change : the widget is now meant to be used in zeam.form. Dolmen is no longer using z3c.form.
French translations have been added.
The HTML code of the widget has been improved.
0.2 (2010-03-01)
Code base has been cleaned to be pep8 compliant.
We are now using the zope.size.ISized adaptation to get the size of the file to display.
Cleaned dependencies. zope.app dependencies have been severed when possible.
0.1 (2009-10-21)
Initial release
Metadata
Release files for dolmen.widget.file 1.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dolmen.widget.file-1.0a1.tar.gz | 7.5 kB | Without provenance | Details |
Release files / dolmen.widget.file-1.0a1.tar.gz
| Download URL | dolmen.widget.file-1.0a1.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba0184fbb23683bfac50fff6d3991ebea13bde08bd5abddec76a28777b2409f1
|
|
BLAKE2b-256 checksum How to use checksums |
0f20e6f78c099d77e1b8a516dc24beccaf60a1dd36f4b50eb100a3f5275e6029
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for dolmen.widget.file 1.0a1
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.