{ "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 :: Zope Public License", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "======================\nmegrok.resourceviewlet\n======================\n\n`megrok.resourceviewlet` is a package meant to include resources\nusing layer, context and view discriminations.\n\n\nSetup\n=====\n\nLet's import and init the necessary work environment::\n\n >>> import grokcore.component as grok\n >>> from grokcore import view, viewlet\n >>> from zope.app.wsgi.testlayer import Browser\n\n >>> browser = Browser()\n >>> browser.handleErrors = False\n\n\nLibrary\n=======\n\nWe first declare a resource. We'll include it in our page::\n\n >>> from fanstatic import Resource, Library\n >>> myLibrary = Library('test_library', 'ftests/resources')\n >>> Thing = Resource(myLibrary, 'thing.js')\n\nThis step is done by an entry point. For the testing, we do it by hand::\n\n >>> from zope.fanstatic.zcml import create_factory\n >>> from zope.component import getGlobalSiteManager\n >>> from zope.publisher.interfaces.browser import IBrowserRequest\n >>> from zope.interface import Interface\n\n >>> resource_factory = create_factory(myLibrary)\n >>> getGlobalSiteManager().registerAdapter(\n ... resource_factory, (IBrowserRequest,), Interface, myLibrary.name)\n\n\nComponents\n==========\n\nTo demonstrate our resource viewlet, we first need a page to\nrender. This page contains a content provider named 'resources'::\n\n >>> from zope.interface import Interface\n\n >>> class Index(view.View):\n ... view.require(\"zope.Public\")\n ... view.context(Interface)\n ...\n ... template = view.PageTemplate(\"\"\"
\n ...