{
"info": {
"author": "mFabrik Research Oy",
"author_email": "info@mfabrik.com",
"bugtrack_url": null,
"classifiers": [
"Framework :: Plone",
"Programming Language :: Python"
],
"description": ".. contents ::\n\nIntroduction\n------------\n\nmfabrik.behaviorutilities is plone.behavior support and helper package for Plone 3 and Archetypes.\n\nAbout Behavior pattern\n-----------------------\n\nBehavior pattern is a way to provide extensible behavior for content objects,\nwithout touching the actual content object class source code and\nso that behaviors can be turned on and off.\n\nFirst read plone.behavior tutorial\n\n* http://plone.org/products/dexterity/documentation/manual/behaviors\n\nNote that the tutorial does not describe how to use behavior objects\nwith Archetypes based content and this Python module tries to fill\nin some gaps there.\n\nFeatures\n--------\n\n* Create plone.behavior behaviors for Archetypes objects and make them assignable\n\n* On-demand behavior object creation - do not make saves or Zope transactions\n if behavior defaults are not changed\n\n* z3c.form support to make behavior objects context aware and thus selection widget vocabulary resolving working\n\n* Traversing tools\n\nExample products\n-----------------\n\nThe following Plone add-ons have been created based on this code\n\n* https://svn.plone.org/svn/collective/mfabrik.trafficsigns/trunk/mfabrik/trafficsigns/behaviors.py\n\n* http://plonegomobile.googlecode.com/svn/trunk/gomobile/gomobile.mobile/gomobile/mobile/behaviors.py\n\n* http://plonegomobile.googlecode.com/svn/trunk/gomobile/gomobile.convergence/gomobile/convergence/behaviors.py\n\n* http://svn.plone.org/svn/collective/plone.app.headeranimation/trunk/README.txt\n\nSample code walkthrough\n-----------------------\n\n*Note*: Code here is only for example purposes and probably does not work as is.\nProper usage documentation will be done after the framework has taken more shape.\nRefer to existing code users for more help.\n\nBehavior is defined as an interface, which also defines form options\nwhich user can edit for this behavior. Schema is defined using *plone.directives.form* package::\n\n class IMultiChannelBehavior(form.Schema):\n \"\"\" How content and its children react to differt medias \"\"\"\n \n contentMedias = schema.Choice(title=u\"Content medias\",\n description=u\"Does this content appear on web, mobile or both\",\n default=ContentMediaOption.USE_PARENT,\n required=True)\n \n # More form fields here\n \n alsoProvides(IMultiChannelBehavior, form.IFormFieldProvider)\n\nThe behavior implementation is persistent Zope object,\nwhich knowns its *context* i.e. object for which behavior is assigned\nby using mfabrik.beahviorutilities.volatilecontext.VolatileContext base class,\nwhich is a subclass of Zope Persistent class. \n\nImplementation maps behavior interface fields itself as\nclass attributes using FieldProperties.\n\nWe use AnnotationPersistentFactory to store behavior.\nThis means that when behavior is once saved on your content object, \nyou can access by directly by traversing::\n\n context.__annotations__[\"your_annotation_key_name\"] \n\nExample::\n\n class MobileBehaviorStorage(VolatileContext):\n \n # Implement your behavior\n implements(IMobileBehavior)\n \n mobileFolderListing = FieldProperty(IMobileBehavior[\"mobileFolderListing\"])\n \n appearInFolderListing = FieldProperty(IMobileBehavior[\"appearInFolderListing\"])\n \n\n # This defines a behavior factoty method \n mobile_behavior_factory = AnnotationPersistentFactory(MobileBehaviorStorage, \"mobile\")\n\nNow you can create and query behaviors.\n\nFirst we check that the behavior is assignable. Currently it is hardcoded\nthat all behaviors are assignable to all Archetypes content objects::\n\n self.loginAsPortalOwner()\n self.portal.invokeFactory(\"Document\", \"doc\")\n doc = self.portal.doc\n \n # Check assignable works\n from plone.behavior.interfaces import IBehaviorAssignable\n assignable = IBehaviorAssignable(doc, None)\n\n self.assertTrue(assignable.supports(IMobileBehavior))\n self.assertNotEqual(assignable, None)\n\nWhen we query the behavior it is created on the fly if it does\nnot already exist on the content. If the behavior is created,\nthen its attributes are populated with the default values specific in the schema::\n\n behavior = IMobileBehavior(doc)\n\nBehavior knowns on which content it belongs. \nThis is implemented as volatile reference, so no circular\npointers are stored to ZODB.\n\n doc == behavior.context\n \nYou can edit the behavior parameters by using properties defined \non the storage class::\n\n behavior.mobileFolderListing = True\n\nIf you do any changes to the behavior you need to call save()\nmethod of the VolatileContext class. This makes sure that \nif the behavior is not the default behavior, you need to \nactually save persistent parameters in the annotations::\n\n behavior.save()\n\n # Recreate behavior from the scratch \n # and see it is persistent\n behavior = IMobileBehavior(doc)\n assert behavior.behavior.mobileFolderListing == True\n \nEach behavior also needs edit form - you can easily do this using z3c.form::\n\n class MobileForm(z3c.form.form.EditForm):\n \"\"\" Folder/page specific mobile publishing options \"\"\"\n \n fields = field.Fields(IMobileBehavior)\n \n prefix = \"mobile\"\n label = u\"Mobile navigation options\"\n \n def update(self):\n return z3c.form.form.EditForm.update(self)\n \n def getContent(self):\n \"\"\"\n Return the object which the form should edit.\n \"\"\"\n behavior = IMobileBehavior(self.context)\n return behavior\n \n def applyChanges(self, data):\n # Call super\n content = self.getContent() \n val = z3c.form.form.EditForm.applyChanges(self, data)\n \n # Write behavior to database\n content = self.getContent() \n content.save()\n \n return val\n \n MobileFormView = wrap_form(MobileForm)\n\nIt is easiest to link this form to your object using document_actions \nlink. actions.xml snippet::\n\n \n \n\nAuthor\n------\n\n`mFabrik Research Oy `_ - Python and Plone professionals for hire.\n\n* `mFabrik web site `_ \n\n* `mFabrik mobile site `_ \n\n* `Blog `_\n\n* `More about Plone `_ \n\n \n \nChangelog\n=========\n\n0.1 - 0.1.1\n------------\n\n- plone.org release\n\n- Updated README\n\n0.1\n-------------------\n\n- Initial release",
"description_content_type": null,
"docs_url": null,
"download_url": "UNKNOWN",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "http://svn.plone.org/svn/collective/",
"keywords": "plone behavior archetypes",
"license": "GPL",
"maintainer": null,
"maintainer_email": null,
"name": "mfabrik.behaviorutilities",
"package_url": "https://pypi.org/project/mfabrik.behaviorutilities/",
"platform": "UNKNOWN",
"project_url": "https://pypi.org/project/mfabrik.behaviorutilities/",
"project_urls": {
"Download": "UNKNOWN",
"Homepage": "http://svn.plone.org/svn/collective/"
},
"release_url": "https://pypi.org/project/mfabrik.behaviorutilities/0.1.1/",
"requires_dist": null,
"requires_python": null,
"summary": "Helper patterns to create behaviors for Archetypes content with plone.behavior package",
"version": "0.1.1"
},
"last_serial": 1459629,
"releases": {
"0.1": [
{
"comment_text": "",
"digests": {
"md5": "9ee3b6df7fe5bc1d974dba97fb4d8355",
"sha256": "43d839712b24c241392ce95d73243e1efdb5f20e63bd1650886fc4351ac0abf1"
},
"downloads": -1,
"filename": "mfabrik.behaviorutilities-0.1.tar.gz",
"has_sig": false,
"md5_digest": "9ee3b6df7fe5bc1d974dba97fb4d8355",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 16773,
"upload_time": "2010-03-16T02:03:09",
"url": "https://files.pythonhosted.org/packages/57/c2/76b0ff7c8f4faff63407f0d32ec39a9b4d3c143822699427cff6b5c45982/mfabrik.behaviorutilities-0.1.tar.gz"
}
],
"0.1.1": [
{
"comment_text": "",
"digests": {
"md5": "2ba593cef154ed7ab31a05064f41653b",
"sha256": "50a7b6252a463e8461ca5d562adc171b445c9fd4c9d47aef9773087e184bff7c"
},
"downloads": -1,
"filename": "mfabrik.behaviorutilities-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "2ba593cef154ed7ab31a05064f41653b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 19704,
"upload_time": "2010-03-24T16:51:23",
"url": "https://files.pythonhosted.org/packages/11/93/85e9ea0421edefc490a511158c86b63087cf351c2c0c9f2b4ca0ddcafc8e/mfabrik.behaviorutilities-0.1.1.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "2ba593cef154ed7ab31a05064f41653b",
"sha256": "50a7b6252a463e8461ca5d562adc171b445c9fd4c9d47aef9773087e184bff7c"
},
"downloads": -1,
"filename": "mfabrik.behaviorutilities-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "2ba593cef154ed7ab31a05064f41653b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 19704,
"upload_time": "2010-03-24T16:51:23",
"url": "https://files.pythonhosted.org/packages/11/93/85e9ea0421edefc490a511158c86b63087cf351c2c0c9f2b4ca0ddcafc8e/mfabrik.behaviorutilities-0.1.1.tar.gz"
}
]
}