{ "info": { "author": "Sylvain Viollon", "author_email": "thefunny@gmail.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "==============\nzeam.form.base\n==============\n\nSummary\n=======\n\n``zeam.form.base`` is a form framework for Zope. It has common goals\nand purposes with ``formlib`` or ``z3c.form`` but tries to:\n\n- define small sane and reusable components : you don't\n need a full flavored form to render and display only few widgets in\n your application,\n\n- be easily customizable without using hundreds of adapters: most\n of settings are set with properties on your form/fields,\n\n- prevent ZCML declarations by using Grok to register the few needed\n adapters (widgets and widgets value extractors),\n\n- always keep the context untouched: the form works on a content\n that can be something else than the context, it can even be a\n dictionnary. That means everywhere in the form, including in\n widgets, and actions, you can either access the context as the real\n context of the form, and have a way to access the content that the\n form is working on. This helps greatly if you have complicated\n widgets working, including when they are embedded in other widgets\n (like in a list or a table),\n\n- let people easily change form templates, by using\n ``megrok.pagetemplate`` by default, selecting which fields goes\n where they want,\n\n- let people define easily their widgets, and use them,\n\n- be able to create complex forms, like composed or table\n forms, where each form can modify the data it needs without having\n to hack-o-refresh other sub-forms: *all* actions are executed before\n any widget compute its value to render,\n\nBy default, it is unware of things like Zope-schema. Generating fields\nfrom a Zope-schema would be done with the help of ``zeam.form.ztk``.\n\nIt work with Python 2.6, 2.7 (tested in Zope 2.13 and Grok 1.5). Older\nversions works for older versions of Zope 2 and Grok.\n\n\nExample\n=======\n\nLet's define a quick example. Actions can be defined standalone::\n\n from zeam.form.base import Action, SUCCESS\n\n class MailAction(Action):\n\n def available(self, form):\n return form.context.haveMailHost()\n\n def __call__(self, form):\n # Send a mail\n form.status = u\"Mail sent\"\n return SUCCESS\n\n\nAnd included as attributes to the form::\n\n class MailForm(Form):\n label = u\"Send a mail\"\n description = u\"to people\"\n fields = Fields(Field(u'Name'), Field(u'E-mail'), Field(u'Message'))\n actions = Actions(MailAction(u'Send mail'))\n\n\n(A decoractor can be used on a form method as well if you don't need\nlot of code for your action).\n\n\nFor more information\n====================\n\nYou can refer to the functional and doctest included in the\npackage. Since it tries to be composed of small components, there is\nmany way to put them together.\n\nChangelog\n=========\n\n1.3.2 (2019-01-15)\n------------------\n\n* Added the defaultFactory handling (needs testing)\n\n* Updated to newer versions of the GTK packages\n\n* Switch tests to zope.testbrowser.wsgi \n\n\n1.3.1 (2012/11/19)\n------------------\n\n* Improve actions ``htmlAttributes`` to reflect fields API.\n\n* Improve and fix ``constrainValue`` validation on fields.\n\n\n1.3 (2012/10/12)\n----------------\n\n* Fields now support more options. There is a ``constrainValue``\n method that can be used in addition to ``validate`` (to be\n compatible with ``zope.schema`` fields). An option ``interface`` had\n been added as well, and can be used by other zeam.form components to\n group fields.\n\n* Fields can be created with more options given through their\n constructor.\n\n* Fields and widget now support extra ``htmlAttributes``. They can be\n given to the field constructor, and are rendered automatically by\n the widget.\n\n* Actions supports ``htmlAttributes`` too.\n\n* Update translations.\n\n* Add some backward compatiblity helpers.\n\n1.2.3 (2012/09/24)\n------------------\n\n* ``grokcore.chameleon`` is able to negociate i18n by himself. Remove\n the ``i18nLanguage`` attribute that was an hack.\n\n* Refactor how the widgets and extractors are created. This is now\n done via the form data, and is customizable.\n\n1.2.2 (2012/05/02)\n------------------\n\n* Update to use the latest ``grokcore.component`` and ``grokcore.view``.\n\n1.2.1 (2012/04/27)\n------------------\n\n* Improve the sorting support on components (fields, actions, widgets).\n\n* Add a ``delete`` method to the data manager.\n\n* Now use ``grokcore.chameleon`` instead of ``megrok.chameleon``.\n\n* Add the missing ``static`` to a form default_namespace template.\n\n1.2 (2011/11/08)\n----------------\n\n* This version no longer support Zope 2 before 2.12.\n\n* And an helper to know if a field is hidden (so you don't display the\n label).\n\n* Support a callable to know if a field is required (the callable\n takes the form as parameter).\n\n* Add the HTML 5 attribute required by default in the widgets. Use\n novalidate attribute on your form tag if you want to disable it.\n\n* Improve error reporting. A widget can now return a collection of\n error (usefull is the widget is composed of more sub-widgets).\n\n* Extend API for ``dataValidator`` and widget ``prepareRequestValue``.\n\n* Add support for CompoundActions (actions implemented by different\n action collections).\n\n* ``updateActions`` now return the form on which the action have been\n executed. This is usefull in case of sub-forms.\n\n\n1.1 (2011/02/01)\n----------------\n\n* ``zeam.form.base`` now uses the latest ``grokcore.view`` template\n grokker.\n\n* Dependencies have been updated for the latest grokcore and megrok\n packages.\n\n\n1.0 (2010/10/19)\n----------------\n\n* Translation have been completed and reviewed in Dutch, French and\n German.\n\n* An infrastructure to write generic validatators on all fields have\n been added (``dataValidators`` on a ``FormData``).\n\n* Field ``getDefaultValue`` and ``defaultValue`` now take a\n parameter, the form itself. It allows you to compute a default value\n that needs the context.\n\n* Some extraction issues have been fixed: a field which is not\n available is no longer extracte and the ``extractData`` method can\n now be called multiple times with different collection of fields.\n\n* Some options have been added to Actions: a ``postOnly`` flag that\n requires the form to be submitted via the `POST` method only, and a\n ``description`` and ``accesskey`` properties. The ``postOnly``\n option is also available at the form level.\n\n* Actions return a status flag for the success or the failure.\n\n* Some helpers have been added to a form: ``haveRequiredFields`` and\n ``htmlId``. Default forms as well have a ``static`` attribute like\n Grok views do.\n\n* Changed the attribute formError to formErrors which now a list of errors\n instead of a single error. Because it's possible to have more then one\n main error in a form (eg. invariants).\n\n* Changed the formtemplate to display the new formError in an