{
"info": {
"author": "Souheil Chelfouh",
"author_email": "trollfot@gmail.com",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
"Framework :: Zope3",
"Intended Audience :: Other Audience",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Operating System :: OS Independent",
"Programming Language :: Python"
],
"description": "==================\ndolmen.widget.file\n==================\n\n`dolmen.widget.file` is a package that walks hand-in-hand with\n`dolmen.file`. It provides a useable and pluggable way to render the\n`dolmen.file.FileField` in a `z3c.form.Form`, using Grok (through\n`megrok.z3cform.base`)\n\nExample\n=======\n\nWe are going to develop here a small example, to demonstrate the use\nof `dolmen.widget.file`. First, we need to create a model content with\na file field::\n\n >>> import dolmen.file\n >>> import grokcore.component as grok\n >>> from zope.interface import Interface\n >>> from zope.schema.fieldproperty import FieldProperty\n\n\n >>> class ITravelMount(Interface):\n ... luggage = dolmen.file.FileField(title=u'Luggages')\n\n\n >>> class Mammoth(grok.Context):\n ... grok.implements(ITravelMount)\n ... luggage = FieldProperty(ITravelMount['luggage'])\n\n\nWe now have a travel mammoth on which we can add a luggage. Now, we\nneed a form to edit the animal::\n\n >>> from megrok.z3cform.base import EditForm\n >>> class EditMammoth(EditForm):\n ... grok.name('edit')\n ... grok.context(ITravelMount)\n\n >>> grok.testing.grok_component('edit', EditMammoth)\n True\n\nLet's instanciate a Mammoth and try to call the form on it::\n\n >>> from zope.component import getMultiAdapter\n >>> from zope.publisher.browser import TestRequest\n\n >>> manfred = Mammoth()\n >>> request = TestRequest()\n\n >>> form = getMultiAdapter((manfred, request), name='edit')\n >>> form.updateWidgets() \n >>> print form.widgets['luggage'].render() \n \n \n \n \n \n \n \n \n \n\nNow, let's try with a value::\n \n >>> manfred.luggage = \"A nice data\"\n >>> form = getMultiAdapter((manfred, request), name='edit')\n >>> form.updateWidgets() \n >>> print form.widgets['luggage'].render() \n \n \n