{ "info": { "author": "Kevin Smith", "author_email": "kevin@mcweekly.com", "bugtrack_url": null, "classifiers": [ "Framework :: Zope3" ], "description": "===================\nPluggable Templates\n===================\n\n\nThis package does two things. First, it does everything z3c.viewtemplate does\n-- seperate the view code layer from the template skin layer. Second, it\nallows an unlimited number of templates to be plugged into any view class.\n\nWhat's this for?\n~~~~~~~~~~~~~~~~\n\nMaking masterpages simple is hard work. Using macros is fairly complicated for\ndesigners to deal with. In fact they don't. Using z3c.viewtemplate with viewlets\nis fairly complicated for programmers to deal with. In fact I don't. So this\nis another evolutionary step to allow designers and programmersto work together\nwithout necessarily knowing or even liking each other.\n\nThis work relies heavily on the working code done by Jurgen for z3c.viewtemplate.\n\nA simple masterpage implementation\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThis is a simple masterpage implementation without using pluggabletemplates.\n\nbrowser.py::\n\n\tclass MyView(object):\n\n\t\tmasterpage = ViewTemplateFile('templates/masterpage.pt')\n\t\tsubpage = ViewTemplateFile('templates/content.pt')\n\n\t\tauthors = ['Roger Zelazny', 'Isaac Asimov', 'Robert Heinlien', 'J.R.R Tolkein']\n\n\t\tdef __call__(self):\n\t\t\treturn masterpage()\n\n templates/masterpage.pt::\n\n \t...\n \t\n \t

My Master Page

\n \t\n \t\n \t\n\n templates/index.pt::\n\n\t\n\nThis is a very easy to follow pattern which can be extended fairly easily. This\npattern runs into immediate problems when you want to change skins. Changing skins\nshould be as easy as ++skin++design1 ... +++skin++design2, but to do so, all of the\nview code needs to be duplicated. Which can be done, but as soon as one piece of view\ncode is changed, all the other view code has to be patched and easily falls out of\nsync.\n\nEnter viewplugs\n~~~~~~~~~~~~~~~\n\ndesign1/configure.zcml::\n\n\t\n\t\t\n\t\t\n\t\n\nSo does this mean we'll need to duplicate all of this configuration for\n++skin++design2?? Not necessarily::\n\n\tclass Design2(Design1):\n\t\t\"\"\" Skin marker \"\"\"\n\nNow you can use ++skin++design1 one as your base and simply override\nthe views or templates you need to change et. al. stylesheets and\nimages.\n\n\nBy plugging templates into view code, each template can display each of the\nother templates::\n\n\t\n\t\n\nAnd of course all view attributes are available::\n\n\t\n\nYou can add as many views as you like, though, too many, and it could get recomplicated.\n\nDoctests\n~~~~~~~~\n\nBefore we can setup a view component using this new method, we have to first\ncreate a master template and subtemplate ...\n\n >>> import os, tempfile\n >>> temp_dir = tempfile.mkdtemp()\n >>> master = os.path.join(temp_dir, 'master.pt')\n >>> open(master, 'w').write('''

Masterpage

''')\n >>> subtemplate = os.path.join(temp_dir, 'subtemplate.pt')\n >>> open(subtemplate, 'w').write('''This is the subtemplate: ''')\n >>> from zope.publisher.browser import TestRequest\n >>> request = TestRequest()\n\n >>> from zope import interface\n >>> from z3c.pluggabletemplates.baseview import MasterView\n >>> from z3c.pluggabletemplates.pagetemplate import RegisteredPageTemplate\n >>> class IMyView(interface.Interface):\n ... pass\n >>> class MyView(MasterView):\n ... interface.implements(IMyView)\n ... master = RegisteredPageTemplate( 'master' )\n ...\t taste = 'success'\n ... subtemplate = RegisteredPageTemplate( 'subtemplate' )\n\n\n >>> view = MyView(root, request)\n\nSince the template is not yet registered, rendering the view will fail::\n\n >>> print view()\n Traceback (most recent call last):\n ...\n ComponentLookupError: ......\n\nLet's now register the template (commonly done using ZCML)::\n\n >>> from zope import component\n >>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer\n >>> from z3c.pluggabletemplates.zcml import TemplateFactory\n >>> from zope.pagetemplate.interfaces import IPageTemplate\n\nThe template factory allows us to create a ViewPageTemplateFile instance::\n\n >>> factory = TemplateFactory(master, 'text/html')\n\nWe register the factory on a view interface and a layer::\n\n >>> component.provideAdapter(factory,\n ... (interface.Interface, IDefaultBrowserLayer),\n ... IPageTemplate, name=\"master\")\n >>> mastertemplate = component.getMultiAdapter(\n ... (view, request), IPageTemplate, name=\"master\" )\n >>> mastertemplate\n \n\n >>> factory = TemplateFactory(subtemplate, 'text/html')\n\nWe register the factory on a view interface and a layer::\n\n >>> component.provideAdapter(factory,\n ... (interface.Interface, IDefaultBrowserLayer),\n ... IPageTemplate, name=\"subtemplate\")\n >>> subtemplate = component.getMultiAdapter(\n ... (view, request), IPageTemplate, name=\"subtemplate\" )\n >>> subtemplate\n \n\nNow that we have a registered template for the default layer we can call our\nview again::\n\n >>> print view()\n

Masterpage

This is the subtemplate: success\n \n\n\nCleanup\n\n >>> import shutil\n >>> shutil.rmtree(temp_dir)\n\nRevision Log\r\n============\r\n\r\n* 11/03/06 initial checkin", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://code.google.com/p/pluggabletemplates/", "keywords": "zope zope3 template", "license": "ZPL 2.1", "maintainer": null, "maintainer_email": null, "name": "z3c.pluggabletemplates", "package_url": "https://pypi.org/project/z3c.pluggabletemplates/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/z3c.pluggabletemplates/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://code.google.com/p/pluggabletemplates/" }, "release_url": "https://pypi.org/project/z3c.pluggabletemplates/0.2/", "requires_dist": null, "requires_python": null, "summary": "Allows seperation of view code from skin templates like z3c.viewtemplate, but also allows multiple templates to be plugged into your view code.", "version": "0.2" }, "last_serial": 802064, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "a9adbbb6194dc585c9b02721edb488fc", "sha256": "0c3529ce8736ade71c608d3bf1114fd1d37dbcbf46e0db0de09f8a6b4496f1a1" }, "downloads": -1, "filename": "z3c.pluggabletemplates-0.2-py2.4.egg", "has_sig": false, "md5_digest": "a9adbbb6194dc585c9b02721edb488fc", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 19784, "upload_time": "2006-11-04T01:57:11", "url": "https://files.pythonhosted.org/packages/3f/14/d0c91a8cff2935f6f3f8a973b629170e47dbb1e4b0aa3912300e144b50cf/z3c.pluggabletemplates-0.2-py2.4.egg" }, { "comment_text": "", "digests": { "md5": "b04cda507f2488fa7aa0a2a1a54ef583", "sha256": "54d503956a0b6491e8e8b40834da53de5c2e30107af23c4c1c0f91ce72fea8a9" }, "downloads": -1, "filename": "z3c.pluggabletemplates-0.2.tar.gz", "has_sig": false, "md5_digest": "b04cda507f2488fa7aa0a2a1a54ef583", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8025, "upload_time": "2006-11-04T01:55:29", "url": "https://files.pythonhosted.org/packages/16/01/7409af0d49554bfb39b92ad08a340114d9491b42a0a4cc73ecdf7956caba/z3c.pluggabletemplates-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a9adbbb6194dc585c9b02721edb488fc", "sha256": "0c3529ce8736ade71c608d3bf1114fd1d37dbcbf46e0db0de09f8a6b4496f1a1" }, "downloads": -1, "filename": "z3c.pluggabletemplates-0.2-py2.4.egg", "has_sig": false, "md5_digest": "a9adbbb6194dc585c9b02721edb488fc", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 19784, "upload_time": "2006-11-04T01:57:11", "url": "https://files.pythonhosted.org/packages/3f/14/d0c91a8cff2935f6f3f8a973b629170e47dbb1e4b0aa3912300e144b50cf/z3c.pluggabletemplates-0.2-py2.4.egg" }, { "comment_text": "", "digests": { "md5": "b04cda507f2488fa7aa0a2a1a54ef583", "sha256": "54d503956a0b6491e8e8b40834da53de5c2e30107af23c4c1c0f91ce72fea8a9" }, "downloads": -1, "filename": "z3c.pluggabletemplates-0.2.tar.gz", "has_sig": false, "md5_digest": "b04cda507f2488fa7aa0a2a1a54ef583", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8025, "upload_time": "2006-11-04T01:55:29", "url": "https://files.pythonhosted.org/packages/16/01/7409af0d49554bfb39b92ad08a340114d9491b42a0a4cc73ecdf7956caba/z3c.pluggabletemplates-0.2.tar.gz" } ] }