{ "info": { "author": "Ilshad Habibullin", "author_email": "astoon.net at gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Zope3", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP :: Site Management" ], "description": "============================\r\nPersistent Cheetah templates\r\n============================\r\n\r\nFeatures:\r\n\r\n- Cheetah template engine,\r\n- sources in filesystem,\r\n- stored in ZODB,\r\n- editable TTW, simple \"$var\" Cheetah syntax for non-technical user,\r\n- able to testing in management web-form,\r\n- able to reset from source.\r\n\r\nUse cases:\r\n\r\n- mail templates,\r\n- editable HTML snippets and pages,\r\n- other.\r\n\r\n\r\n* Needed imports for these tests *\r\n\r\n >>> import os, tempfile\r\n >>> temp_dir = tempfile.mkdtemp()\r\n\r\n >>> import zope.component\r\n >>> import ice.template\r\n\r\n >>> from zope.configuration import xmlconfig\r\n >>> context = xmlconfig.file('meta.zcml', ice.template)\r\n\r\n\r\nCreate templates\r\n----------------\r\n\r\n1) Create source file using Cheetah syntax \"$\" for the variables::\r\n\r\n >>> file = os.path.join(temp_dir, 'welcome.tmpl')\r\n\r\n >>> open(file, 'w').write('''\r\n ... Dear $user_name!\r\n ...\t Welcome to $site_name!\r\n ... ''')\r\n\r\n2) Register template::\r\n\r\n >>> context = xmlconfig.string('''\r\n ... <configure\r\n ...\t xmlns=\"http://namespaces.zope.org/zope\"\r\n ...\t xmlns:ice=\"http://namespaces.zope.org/ice\"\r\n ...\t i18n_domain=\"test\">\r\n ...\r\n ...\t <ice:template\r\n ...\t name=\"welcome\"\r\n ...\t\t title=\"Welcome\"\r\n ...\t\t storage=\"my-templates\"\r\n ...\t\t source=\"%s\"\r\n ...\t\t variables=\"user_name\r\n ...\t\t site_name\"\r\n ...\t\t />\r\n ...\r\n ...\t </configure>\r\n ... ''' % file, context=context)\r\n\r\n\r\nCreate storage\r\n--------------\r\n\r\nNeed create (one or more) local utility to store templates.\r\nNote, the utility name used for lookup the storage::\r\n\r\n >>> templates = ice.template.Templates()\r\n\r\n >>> zope.component.provideUtility(\r\n ... templates, ice.template.ITemplates, 'my-templates')\r\n\r\n\r\nUsage\r\n-----\r\n\r\nUse template::\r\n\r\n >>> data = {'user_name':u'Bob', 'site_name':'www.gnu.org'}\r\n\r\n >>> templates.compileTemplate('welcome', data)\r\n '\\n Dear Bob!\\n Welcome to www.gnu.org!\\n'\r\n\r\n\r\nManage templates\r\n----------------\r\n\r\nLooking all templates, registered for this storage::\r\n\r\n >>> list(templates.getAllTemplates())\r\n [(u'welcome', )]\r\n\r\nGet variables names::\r\n\r\n >>> templates.getVariables('welcome')\r\n [u'user_name', u'site_name']\r\n\r\nGet template::\r\n\r\n >>> templates.getTemplate('welcome')\r\n '\\n Dear $user_name!\\n Welcome to $site_name!\\n'\r\n\r\nEdit template::\r\n\r\n >>> templates.setTemplate('welcome', \"$site_name for you, $user_name\")\r\n\r\n >>> templates.compileTemplate('welcome', data)\r\n 'www.gnu.org for you, Bob'\r\n\r\nReset from source::\r\n\r\n >>> templates.resetTemplate('welcome')\r\n '\\n Dear $user_name!\\n Welcome to $site_name!\\n'\r\n\r\n >>> templates.compileTemplate('welcome', data)\r\n '\\n Dear Bob!\\n Welcome to www.gnu.org!\\n'\r\n\r\n\r\nUsing property\r\n--------------\r\n\r\nAnother way to use special property::\r\n\r\n >>> class Pagelet(object):\r\n ...\r\n ... template = ice.template.PersistentTemplate('my-templates', 'welcome')\r\n ...\r\n ... def update(self):\r\n ... self.data = {'user_name':'Man', 'site_name':'www.python.com.ua'}\r\n ...\r\n ... def render(self):\r\n ... return self.template(self.data)\r\n\r\n >>> view = Pagelet()\r\n >>> view.update()\r\n >>> view.render()\r\n '\\n Dear Man!\\n Welcome to www.python.com.ua!\\n'\r\n\r\n\r\nManagement UI\r\n-------------\r\n\r\nManagement persistent Cheetah templates UI based on z3c.pagelet layers.\r\n\r\nThere are 3 views for management templates:\r\n\r\n 1) Listing of all storages.\r\n 2) Listing of all templates in a storage.\r\n 3) Edit form for given template, reload, testing, preview.\r\n\r\nActually, you need to do only one: register listing of all storages\r\npagelet using class ice.template.browser.storages.Pagelet (see example\r\nin configure.zcml in ice.template.browser module), because (2) and (3)\r\nare already registered. For examples, take a look configure.zcml\r\nin ice.template.tests module.\r\n\r\n=======\r\nCHANGES\r\n=======\r\n\r\n\r\nVersion 0.1.0 (2009-05-04)\r\n--------------------------\r\n\r\n- Initial release, this code is moved from common ice.app library.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://launchpad.net/ice.template", "keywords": "", "license": "GPL v.3", "maintainer": "", "maintainer_email": "", "name": "ice.template", "package_url": "https://pypi.org/project/ice.template/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/ice.template/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://launchpad.net/ice.template" }, "release_url": "https://pypi.org/project/ice.template/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Persistent Cheetah templates", "version": "0.1.0" }, "last_serial": 102491, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "da79d711036ae4a3779bdea46bd59229", "sha256": "0b9d5453df5ce88c36036874ecf6ec651756d24b988c9aa45c88d08770d90fe4" }, "downloads": -1, "filename": "ice.template-0.1.0-py2.4.egg", "has_sig": false, "md5_digest": "da79d711036ae4a3779bdea46bd59229", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 33309, "upload_time": "2009-05-04T20:45:12", "url": "https://files.pythonhosted.org/packages/bc/0c/50fea78c6df20e21401dadbe3285f610bc201fab37fefd3de7531ad92c32/ice.template-0.1.0-py2.4.egg" }, { "comment_text": "", "digests": { "md5": "317542ddfd85d8dbea0455e978015a3c", "sha256": "97870b3d4047cfe1e8247b10a4b131712dfc63c410f4771d631bf0554be412d7" }, "downloads": -1, "filename": "ice.template-0.1.0.tar.gz", "has_sig": false, "md5_digest": "317542ddfd85d8dbea0455e978015a3c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12841, "upload_time": "2009-05-04T20:45:09", "url": "https://files.pythonhosted.org/packages/5d/b5/d0f933ceed5f814411dd33e749c31e4834c1d4dddcece5cf43765a396522/ice.template-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "da79d711036ae4a3779bdea46bd59229", "sha256": "0b9d5453df5ce88c36036874ecf6ec651756d24b988c9aa45c88d08770d90fe4" }, "downloads": -1, "filename": "ice.template-0.1.0-py2.4.egg", "has_sig": false, "md5_digest": "da79d711036ae4a3779bdea46bd59229", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 33309, "upload_time": "2009-05-04T20:45:12", "url": "https://files.pythonhosted.org/packages/bc/0c/50fea78c6df20e21401dadbe3285f610bc201fab37fefd3de7531ad92c32/ice.template-0.1.0-py2.4.egg" }, { "comment_text": "", "digests": { "md5": "317542ddfd85d8dbea0455e978015a3c", "sha256": "97870b3d4047cfe1e8247b10a4b131712dfc63c410f4771d631bf0554be412d7" }, "downloads": -1, "filename": "ice.template-0.1.0.tar.gz", "has_sig": false, "md5_digest": "317542ddfd85d8dbea0455e978015a3c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12841, "upload_time": "2009-05-04T20:45:09", "url": "https://files.pythonhosted.org/packages/5d/b5/d0f933ceed5f814411dd33e749c31e4834c1d4dddcece5cf43765a396522/ice.template-0.1.0.tar.gz" } ] }