{ "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.image\n===================\n\n`dolmen.widget.image` is a thin layer above `dolmen.widget.file`\nproviding a widget suitable to fields implementing IImageField. It\nadds, thanks to `dolmen.thumbnailer` a preview of the uploaded image\nin both input and display mode.\n\nExample\n=======\n\nWe are going to develop here a small example, to demonstrate the use\nof `dolmen.widget.image`. First, we instanciate our test model and add\nan image field to the object::\n\n >>> from persistent import Persistent\n\n >>> class Mammoth(Persistent):\n ... pass\n\n >>> import dolmen.file\n >>> import grokcore.component as grok\n >>> from zope.interface import Interface, alsoProvides\n >>> from zope.schema.fieldproperty import FieldProperty\n\n >>> class IMammothId(Interface):\n ... \"\"\"Even mammoths need an ID card\"\"\"\n ... picture = dolmen.file.ImageField(title=u'Luggages')\n\n >>> manfred = Mammoth()\n >>> manfred.picture = None\n >>> alsoProvides(manfred, IMammothId)\n\nThe picture is now set on our Mammoth. We create a form to try and\nedit the picture field::\n\n >>> from megrok.z3cform.base import EditForm\n\n >>> class EditMammoth(EditForm):\n ... grok.name('edit')\n ... grok.context(IMammothId)\n\n >>> grok.testing.grok_component('edit', EditMammoth)\n True\n\nWe persist our Mammoth to get a located mammoth with an URL::\n\n >>> from zope.component.hooks import getSite\n >>> root = getSite()\n >>> root['manfred'] = manfred\n >>> manfred = root['manfred']\n\nWe can call the edit form on our persisted object::\n\n >>> from zope.component import getMultiAdapter\n >>> from zope.publisher.browser import TestRequest\n \n >>> request = TestRequest()\n\n >>> form = getMultiAdapter((manfred, request), name='edit')\n >>> form.updateWidgets() \n >>> print form.widgets['picture'].render() \n
\n \n
\n\nNow, let's try with a fake value::\n \n >>> manfred.picture = \"some fake image\"\n >>> form = getMultiAdapter((manfred, request), name='edit')\n >>> form.updateWidgets() \n\n >>> print form.widgets['picture'].render() \n
\n
\n \n
\n \n —\n \n
\n \n \n \n
\n \n \n
\n \n \n
\n \n \n \n
\n \n\nWith non persistent objects (which don't resolve to an URL), no\npreview is displayed. If we can't resolve to an URL, we can't serve\nthe thumbnail or download the data::\n\n >>> judith = Mammoth()\n >>> judith.picture = \"Fake image data\"\n >>> alsoProvides(judith, IMammothId)\n\n >>> form = getMultiAdapter((judith, request), name='edit')\n >>> form.updateWidgets() \n >>> print form.widgets['picture'].render() \n
\n \n \n \n \n
\n \n \n \n
\n \n \n
\n \n \n
\n \n \n \n
\n \n\n\nChangelog\n=========\n\n0.2 (2010-03-01)\n----------------\n\n* Updated the code to use ``dolmen.widget.file 0.2`` and ``dolmen.file\n 0.5.1``.\n\n* Updated the template to use the ``zope.size.ISized`` adapter to\n display the file size.\n\n* Updated the tests to get rid of the unneeded zope.app packages.\n\n0.1 (2009-10-22)\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": "UNKNOWN", "keywords": "Grok Zope3 Dolmen Widget Image", "license": "GPL", "maintainer": null, "maintainer_email": null, "name": "dolmen.widget.image", "package_url": "https://pypi.org/project/dolmen.widget.image/", "platform": "Any", "project_url": "https://pypi.org/project/dolmen.widget.image/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/dolmen.widget.image/0.2/", "requires_dist": null, "requires_python": null, "summary": "Image widget (with thumbnails) for z3c.form, using Grok", "version": "0.2" }, "last_serial": 791342, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "bd5c7f8737e0df95d7a72532f08de29a", "sha256": "6c68e2d55be6ba13c179fcf7a18621a1e12e5de36fbf05fce5f11ba4fe303935" }, "downloads": -1, "filename": "dolmen.widget.image-0.1.tar.gz", "has_sig": false, "md5_digest": "bd5c7f8737e0df95d7a72532f08de29a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6224, "upload_time": "2009-10-22T13:05:15", "url": "https://files.pythonhosted.org/packages/bd/ed/be367eaa4f128b8866be985339f28660e187030b1fafe7cfb54f62a56479/dolmen.widget.image-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "c9de9f031349b17830cc9c3cf4bc78b5", "sha256": "8e31af9fc23cfcb2ab5814be705aba400e814b0f33742fa0d4d0983d6fa6df7d" }, "downloads": -1, "filename": "dolmen.widget.image-0.2.tar.gz", "has_sig": false, "md5_digest": "c9de9f031349b17830cc9c3cf4bc78b5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6611, "upload_time": "2010-03-01T12:54:19", "url": "https://files.pythonhosted.org/packages/8b/0b/79eff676c8996102b00a05da89a80bb462a496b3168a278f68cc61b4bc5d/dolmen.widget.image-0.2.tar.gz" } ], "1.0a1": [ { "comment_text": "", "digests": { "md5": "d83b111d489a4d30b06ea20316e286da", "sha256": "0bc3d882f70df9168fc75bc38a7318cce4bae54aa0e57a5abcdc97a495e98eb5" }, "downloads": -1, "filename": "dolmen.widget.image-1.0a1.tar.gz", "has_sig": false, "md5_digest": "d83b111d489a4d30b06ea20316e286da", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6059, "upload_time": "2010-05-14T16:08:11", "url": "https://files.pythonhosted.org/packages/4c/f8/2b351ec4d6ff402c4f8d438da6235448f1a349078c9e0dc15bd6e522a3b8/dolmen.widget.image-1.0a1.tar.gz" } ], "1.0b1": [ { "comment_text": "", "digests": { "md5": "5799baa4aa4fea5bfea026b9cff1b7fb", "sha256": "6b01224f9b9cd3f602dc24ea934c59f082e89270fc9fb05d2b6e2842be5c63de" }, "downloads": -1, "filename": "dolmen.widget.image-1.0b1.tar.gz", "has_sig": false, "md5_digest": "5799baa4aa4fea5bfea026b9cff1b7fb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6323, "upload_time": "2010-07-05T23:20:57", "url": "https://files.pythonhosted.org/packages/e7/d9/f18be69a289b422a3f8a619a80178c44e79effbae63b7a38c0ec8b964d81/dolmen.widget.image-1.0b1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c9de9f031349b17830cc9c3cf4bc78b5", "sha256": "8e31af9fc23cfcb2ab5814be705aba400e814b0f33742fa0d4d0983d6fa6df7d" }, "downloads": -1, "filename": "dolmen.widget.image-0.2.tar.gz", "has_sig": false, "md5_digest": "c9de9f031349b17830cc9c3cf4bc78b5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6611, "upload_time": "2010-03-01T12:54:19", "url": "https://files.pythonhosted.org/packages/8b/0b/79eff676c8996102b00a05da89a80bb462a496b3168a278f68cc61b4bc5d/dolmen.widget.image-0.2.tar.gz" } ] }