{ "info": { "author": "Matthew Wilkes", "author_email": "matthew.wilkes@circulartriangle.eu", "bugtrack_url": null, "classifiers": [ "Framework :: Plone", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Section Sub Skin\n================\n\nSection Sub Skin is a system for applying an interface to a request that maps \ninto a description of how a theme should change for a subsection of the site.\nThese mappings do not automatically change things about the theme, but they \nare available in Zope3 style browser views for conditional inclusion. \n\nThe recommended way of doing this currently (as DTML views are not supported)\nis to create a view that uses TAL rather than the standard DTML method of \ngenerating customised CSS files.\n\nBrowser views that inherit from `collective.sectionsubskin.browser.subskin.SubSkin` \nhave a \"subskin\" variable set which is accessible from the view.\n\nFor example, if all subskins contain a `colour` attribute, the current colour can be found with::\n\n \n\nBoring imports and setup (move to tests.py?). You probably want to ignore all this.::\n\n >>> from zope.app.testing import ztapi\n >>> import zope.interface\n >>> from AccessControl.SecurityManagement import newSecurityManager\n >>> from AccessControl.User import UnrestrictedUser\n >>> from Testing.makerequest import makerequest\n >>> app = makerequest(app)\n >>> portal = portal.__of__(app)\n >>> newSecurityManager(None, UnrestrictedUser('god', '', ['Manager'], ''))\n >>> from Products.Five.testbrowser import Browser\n >>> browser = Browser()\n >>> from Testing.ZopeTestCase import user_password\n >>> browser.addHeader('Authorization', 'Basic %s:%s' % ('portal_owner', user_password)) # Only needed as our view is a dummy, if registered through ZCML we'd use permission=zope2.View\n \n\nCreating a new theme definition is very easy::\n \n >>> from collective.sectionsubskin.definition import BaseDefinition \n >>> from collective.sectionsubskin.interfaces import ISubskinDefinition\n >>> from collective.sectionsubskin.test_support import IRedSkin, RedSkin\n\nAgain, on the filesystem, the value of this code is::\n\n class IRedSkin(ISubskinDefinition): \n pass\n \n class RedSkin(BaseDefinition):\n title = u\"RedSkin\"\n colour = u\"FF0000\"\n type_interface = IRedSkin\n\nWe can keep an instance of this in a list so we can poke it later::\n\n >>> skins = []\n >>> skins.append(RedSkin())\n >>> skins\n []\n >>> skins[0].colour\n u'FF0000'\n\nThese are just basic python objects that inherit from BaseDefinition, which \nconditionally inherits from p4a.subtyper as well as providing some helper methods.\nThis means you can do anything with them that you can with normal objects::\n\n >>> from collective.sectionsubskin.test_support import IBlueSkin, BlueSkin\n >>> skins.append(BlueSkin())\n\n\nAgain, on the filesystem, the value of this code is::\n\n class IBlueSkin(ISubskinDefinition): \n pass\n \n class BlueSkin(BaseDefinition):\n title = u\"BlueSkin\"\n colour = u\"0000FF\"\n type_interface = IBlueSkin\n\n\nThe skins variable now contains both skins:: \n\n >>> skins\n [, ]\n >>> skins[1].colour\n u'0000FF'\n\nNow, if we create a browser view for the site (registed in test_support)::\n\n >>> from collective.sectionsubskin.test_support import colours\n\nThese things need to be in filesystem code so Zope doesn't throw a paddy, so it's actually::\n\n from collective.sectionsubskin.browser.subskin import SubSkin\n class colours(SubSkin):\n \"\"\" Colours. \"\"\"\n \n def render(self):\n \"\"\" Render the CSS. \"\"\"\n try:\n return \"\"\"html { background-color: #%s; }\"\"\" % (self.subskin.colour)\n except:\n return \"\"\"\"\"\"\n\n __call__ = render\n\n def __of__(self, parent):\n # We don't care about acquisition for this toy example\n return self\n\n \nWe can instantiate one directly, traverse to it or visit it in a browser::\n\n >>> colours(portal, app.REQUEST).render()\n ''\n >>> portal.unrestrictedTraverse(\"colours.css\").render()\n ''\n >>> browser.open(\"%s/colours.css\" % self.portal.absolute_url())\n >>> browser.contents\n ''\n\nOnly the last of these will trigger the subskin, as it only activates on HTTP requests traversing over the object.\n\nAs there is no subskin active for the root it correctly renders an empty string. \nIf, however, we create some subfolders we can assign them subskins::\n\n >>> red = portal[portal.invokeFactory(\"Folder\",\"red\")]\n >>> zope.interface.alsoProvides(red, (IRedSkin, ))\n >>> blue = portal[portal.invokeFactory(\"Folder\",\"blue\")]\n >>> zope.interface.alsoProvides(blue, (IBlueSkin, ))\n >>> noskin = portal[portal.invokeFactory(\"Folder\",\"noskin\")]\n \n\nNow when we traverse to the red folder we see the red skin::\n \n >>> browser.open(\"%s/red/colours.css\" % self.portal.absolute_url())\n >>> browser.contents\n 'html { background-color: #FF0000; }'\n\nBut if we go blue we see the other option::\n \n >>> browser.open(\"%s/blue/colours.css\" % self.portal.absolute_url())\n >>> browser.contents\n 'html { background-color: #0000FF; }'\n\nAny unmarked folders still show no subskin::\n \n >>> browser.open(\"%s/noskin/colours.css\" % self.portal.absolute_url())\n >>> browser.contents\n ''\n\nWeird traversal will give the last skin encountered::\n \n >>> browser.open(\"%s/red/blue/colours.css\" % self.portal.absolute_url())\n >>> browser.contents\n 'html { background-color: #0000FF; }'\n\nand::\n\n >>> browser.open(\"%s/blue/red/colours.css\" % self.portal.absolute_url())\n >>> browser.contents\n 'html { background-color: #FF0000; }'\nChangelog\n=========\n\n0.2\n---\n\nAdded support to the traverser to remove an existing subskin when a new definition is traversed over\n Matthew Wilkes\n\n0.1\n---\n\nWorks in 2.10 well. 2.9 with Five 1.4.4 works but is unsupported.\n MatthewWilkes", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://code.liberalyouth.org/basket/collective.sectionsubskin", "keywords": "", "license": "GPL", "maintainer": null, "maintainer_email": null, "name": "collective.sectionsubskin", "package_url": "https://pypi.org/project/collective.sectionsubskin/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/collective.sectionsubskin/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://code.liberalyouth.org/basket/collective.sectionsubskin" }, "release_url": "https://pypi.org/project/collective.sectionsubskin/0.2/", "requires_dist": null, "requires_python": null, "summary": "Apply a marker interface to a request to code for special presentation of a subsection.", "version": "0.2" }, "last_serial": 788193, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "4ba6412ef0686b32dd0e565061b7c731", "sha256": "3850cf985e83321a13a20437444c26ff4f8fa540e71f39412566a1c1e23ac6ed" }, "downloads": -1, "filename": "collective.sectionsubskin-0.1-py2.4.egg", "has_sig": false, "md5_digest": "4ba6412ef0686b32dd0e565061b7c731", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 20798, "upload_time": "2008-07-16T15:50:31", "url": "https://files.pythonhosted.org/packages/1c/83/8cd8f730472463036bd5881f4941df343e843ab4c69091310e3e3c8a4392/collective.sectionsubskin-0.1-py2.4.egg" }, { "comment_text": "", "digests": { "md5": "cd3745a2ab951ce9998c58fd8e0289c1", "sha256": "ffbfed2e73e3e0fe27af1f1a77a8e868666b0c5f9595f0f7cfc5a23a15f76e15" }, "downloads": -1, "filename": "collective.sectionsubskin-0.1.tar.gz", "has_sig": false, "md5_digest": "cd3745a2ab951ce9998c58fd8e0289c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14891, "upload_time": "2008-07-16T15:50:31", "url": "https://files.pythonhosted.org/packages/bb/e8/7bd3941673dfb07971300cdd18be55d470f688ac6931fd34cb80b5cfda24/collective.sectionsubskin-0.1.tar.gz" } ], "0.1dev-r61124": [ { "comment_text": "", "digests": { "md5": "9d70827ee3a0d7c54b2926a4d8b4b228", "sha256": "2eaf881b3eea9b0723af2eabbdd9b88ae0d0c7bce4faac2f9788c86232943f86" }, "downloads": -1, "filename": "collective.sectionsubskin-0.1dev-r61124.tar.gz", "has_sig": false, "md5_digest": "9d70827ee3a0d7c54b2926a4d8b4b228", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10503, "upload_time": "2008-07-10T15:57:35", "url": "https://files.pythonhosted.org/packages/59/68/6c9be1f09b9bd8021ba5f0834be875a7e5a9269c87335a9fe97b192a818e/collective.sectionsubskin-0.1dev-r61124.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "95d8427b3b82fa0822b90becfbf8fec4", "sha256": "e6e9c1c0ce55a34272ae780afd870b78967846fa98557d77899f4e9e2614f0dc" }, "downloads": -1, "filename": "collective.sectionsubskin-0.2-py2.4.egg", "has_sig": false, "md5_digest": "95d8427b3b82fa0822b90becfbf8fec4", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 21050, "upload_time": "2008-07-18T10:51:23", "url": "https://files.pythonhosted.org/packages/85/a2/caf11b6a242023b9d236c03add1a6c87d460bcb046794e48f742b3d6cd8c/collective.sectionsubskin-0.2-py2.4.egg" }, { "comment_text": "", "digests": { "md5": "ced314769d89aaf0de38ce21d40fd123", "sha256": "27530a013dd2e8a343dbb981c63c0b557143d185369f3ca7799ea9db1851d12d" }, "downloads": -1, "filename": "collective.sectionsubskin-0.2.tar.gz", "has_sig": false, "md5_digest": "ced314769d89aaf0de38ce21d40fd123", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15137, "upload_time": "2008-07-18T10:51:22", "url": "https://files.pythonhosted.org/packages/7b/75/e21c1fd5bdab0046162cf7e7f14ae8478b340ffaa9759d48a4c185141e0b/collective.sectionsubskin-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "95d8427b3b82fa0822b90becfbf8fec4", "sha256": "e6e9c1c0ce55a34272ae780afd870b78967846fa98557d77899f4e9e2614f0dc" }, "downloads": -1, "filename": "collective.sectionsubskin-0.2-py2.4.egg", "has_sig": false, "md5_digest": "95d8427b3b82fa0822b90becfbf8fec4", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 21050, "upload_time": "2008-07-18T10:51:23", "url": "https://files.pythonhosted.org/packages/85/a2/caf11b6a242023b9d236c03add1a6c87d460bcb046794e48f742b3d6cd8c/collective.sectionsubskin-0.2-py2.4.egg" }, { "comment_text": "", "digests": { "md5": "ced314769d89aaf0de38ce21d40fd123", "sha256": "27530a013dd2e8a343dbb981c63c0b557143d185369f3ca7799ea9db1851d12d" }, "downloads": -1, "filename": "collective.sectionsubskin-0.2.tar.gz", "has_sig": false, "md5_digest": "ced314769d89aaf0de38ce21d40fd123", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15137, "upload_time": "2008-07-18T10:51:22", "url": "https://files.pythonhosted.org/packages/7b/75/e21c1fd5bdab0046162cf7e7f14ae8478b340ffaa9759d48a4c185141e0b/collective.sectionsubskin-0.2.tar.gz" } ] }