[Checkins] SVN: z3ext.formatter/tags/1.2.5/ release tag
Nikolay Kim
fafhrd at datacom.kz
Sun Nov 23 02:45:14 EST 2008
Log message for revision 93276:
release tag
Changed:
A z3ext.formatter/tags/1.2.5/
D z3ext.formatter/tags/1.2.5/CHANGES.txt
A z3ext.formatter/tags/1.2.5/CHANGES.txt
D z3ext.formatter/tags/1.2.5/buildout.cfg
A z3ext.formatter/tags/1.2.5/buildout.cfg
D z3ext.formatter/tags/1.2.5/setup.py
A z3ext.formatter/tags/1.2.5/setup.py
D z3ext.formatter/tags/1.2.5/src/z3ext/formatter/README.txt
A z3ext.formatter/tags/1.2.5/src/z3ext/formatter/README.txt
D z3ext.formatter/tags/1.2.5/src/z3ext/formatter/configure.zcml
A z3ext.formatter/tags/1.2.5/src/z3ext/formatter/configure.zcml
D z3ext.formatter/tags/1.2.5/src/z3ext/formatter/tests.py
A z3ext.formatter/tags/1.2.5/src/z3ext/formatter/tests.py
A z3ext.formatter/tags/1.2.5/tests.cfg
A z3ext.formatter/tags/1.2.5/zope34.cfg
-=-
Deleted: z3ext.formatter/tags/1.2.5/CHANGES.txt
===================================================================
--- z3ext.formatter/trunk/CHANGES.txt 2008-11-22 08:58:59 UTC (rev 93257)
+++ z3ext.formatter/tags/1.2.5/CHANGES.txt 2008-11-23 07:45:14 UTC (rev 93276)
@@ -1,68 +0,0 @@
-=======
-CHANGES
-=======
-
-1.2.5 (2008-??-??)
-------------------
-
-- z3ext.controlpanel is optional
-
-
-1.2.4 (2008-10-21)
-------------------
-
-- Fixed russian translation
-
-- nl translation updated
-
-
-1.2.3 (2008-10-20)
-------------------
-
-- Added translations: nl, ru
-
-
-1.2.2 (2008-10-10)
-------------------
-
-- Use new i18n domain z3ext.formatter
-
-
-1.2.1 (2008-05-16)
-------------------
-
-- Replace 'autoinclude' with 'includeDependendcies'
-
-
-1.2.0 (2008-03-25)
-------------------
-
-- Use z3c.autoinclude
-
-- Code moved to svn.zope.org
-
-
-1.1.2 (2008-03-06)
-------------------
-
-- Fixed bug in fancyDatetime formatter
-
-
-1.1.1 (2008-02-05)
-------------------
-
-- Added 'Timezones' vocabulary
-
-- Cleanup code
-
-
-1.1.0 (2007-12-21)
-------------------
-
-- Added controlpanel configlet
-
-
-1.0.0 (2007-12-07)
-------------------
-
-- Initial release.
Copied: z3ext.formatter/tags/1.2.5/CHANGES.txt (from rev 93261, z3ext.formatter/trunk/CHANGES.txt)
===================================================================
--- z3ext.formatter/tags/1.2.5/CHANGES.txt (rev 0)
+++ z3ext.formatter/tags/1.2.5/CHANGES.txt 2008-11-23 07:45:14 UTC (rev 93276)
@@ -0,0 +1,69 @@
+=======
+CHANGES
+=======
+
+1.2.5 (2008-11-23)
+------------------
+
+- z3ext.controlpanel is optional
+
+- Added buildout for testing against zope3.4
+
+1.2.4 (2008-10-21)
+------------------
+
+- Fixed russian translation
+
+- nl translation updated
+
+
+1.2.3 (2008-10-20)
+------------------
+
+- Added translations: nl, ru
+
+
+1.2.2 (2008-10-10)
+------------------
+
+- Use new i18n domain z3ext.formatter
+
+
+1.2.1 (2008-05-16)
+------------------
+
+- Replace 'autoinclude' with 'includeDependendcies'
+
+
+1.2.0 (2008-03-25)
+------------------
+
+- Use z3c.autoinclude
+
+- Code moved to svn.zope.org
+
+
+1.1.2 (2008-03-06)
+------------------
+
+- Fixed bug in fancyDatetime formatter
+
+
+1.1.1 (2008-02-05)
+------------------
+
+- Added 'Timezones' vocabulary
+
+- Cleanup code
+
+
+1.1.0 (2007-12-21)
+------------------
+
+- Added controlpanel configlet
+
+
+1.0.0 (2007-12-07)
+------------------
+
+- Initial release.
Deleted: z3ext.formatter/tags/1.2.5/buildout.cfg
===================================================================
--- z3ext.formatter/trunk/buildout.cfg 2008-11-22 08:58:59 UTC (rev 93257)
+++ z3ext.formatter/tags/1.2.5/buildout.cfg 2008-11-23 07:45:14 UTC (rev 93276)
@@ -1,61 +0,0 @@
-[buildout]
-develop = .
-parts = test coverage-test coverage-report i18n i18nall i18ncheck i18ndude
-
-[test]
-recipe = zc.recipe.testrunner
-eggs = z3ext.formatter [test]
-
-
-[coverage-test]
-recipe = zc.recipe.testrunner
-eggs = z3ext.formatter [test]
-defaults = ['--coverage', '../../coverage']
-
-
-[coverage-report]
-recipe = zc.recipe.egg
-eggs = z3c.coverage
-scripts = coverage=coverage-report
-arguments = ('coverage', 'coverage/report')
-
-[i18n]
-recipe = z3c.recipe.i18n:i18n
-packages = z3ext.formatter
-domain = z3ext.formatter
-output = ${buildout:directory}/src/z3ext/formatter/locales
-eggs = z3ext.formatter [test]
-zcml =
- <configure i18n_domain="zope"
- xmlns:zcml="http://namespaces.zope.org/zcml"
- xmlns:browser="http://namespaces.zope.org/browser">
- <include package="zope.component" file="meta.zcml" />
- <include package="zope.securitypolicy" file="meta.zcml" />
- <include package="zope.app.component" file="meta.zcml" />
- <include package="zope.app.security" file="meta.zcml" />
- <include package="zope.app.pagetemplate" file="meta.zcml" />
-
- <include package="zope.securitypolicy" />
- <include package="zope.app.security" />
- <include package="zope.app.zcmlfiles" />
- <include package="zope.app.authentication" />
-
- <include package="z3c.autoinclude" file="meta.zcml" />
- <include package="z3ext.controlpanel" />
- <include package="z3ext.formatter" />
- </configure>
-
-[i18nall]
-recipe = buildout_script
-template_dir = ${buildout:directory}/scripts/
-template = i18nall.in
-
-[i18ncheck]
-recipe = buildout_script
-template_dir = ${buildout:directory}/scripts/
-template = i18ncheck.in
-
-[i18ndude]
-unzip = true
-recipe = zc.recipe.egg
-eggs = i18ndude
Copied: z3ext.formatter/tags/1.2.5/buildout.cfg (from rev 93275, z3ext.formatter/trunk/buildout.cfg)
===================================================================
--- z3ext.formatter/tags/1.2.5/buildout.cfg (rev 0)
+++ z3ext.formatter/tags/1.2.5/buildout.cfg 2008-11-23 07:45:14 UTC (rev 93276)
@@ -0,0 +1,45 @@
+[buildout]
+develop = .
+extends = tests.cfg
+parts = test coverage-test coverage-report i18n i18nall i18ncheck i18ndude
+
+[i18n]
+recipe = z3c.recipe.i18n:i18n
+packages = z3ext.formatter
+domain = z3ext.formatter
+output = ${buildout:directory}/src/z3ext/formatter/locales
+eggs = z3ext.formatter [test]
+zcml =
+ <configure i18n_domain="zope"
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ xmlns:browser="http://namespaces.zope.org/browser">
+ <include package="zope.component" file="meta.zcml" />
+ <include package="zope.securitypolicy" file="meta.zcml" />
+ <include package="zope.app.component" file="meta.zcml" />
+ <include package="zope.app.security" file="meta.zcml" />
+ <include package="zope.app.pagetemplate" file="meta.zcml" />
+
+ <include package="zope.securitypolicy" />
+ <include package="zope.app.security" />
+ <include package="zope.app.zcmlfiles" />
+ <include package="zope.app.authentication" />
+
+ <include package="z3c.autoinclude" file="meta.zcml" />
+ <include package="z3ext.controlpanel" />
+ <include package="z3ext.formatter" />
+ </configure>
+
+[i18nall]
+recipe = buildout_script
+template_dir = ${buildout:directory}/scripts/
+template = i18nall.in
+
+[i18ncheck]
+recipe = buildout_script
+template_dir = ${buildout:directory}/scripts/
+template = i18ncheck.in
+
+[i18ndude]
+unzip = true
+recipe = zc.recipe.egg
+eggs = i18ndude
Deleted: z3ext.formatter/tags/1.2.5/setup.py
===================================================================
--- z3ext.formatter/trunk/setup.py 2008-11-22 08:58:59 UTC (rev 93257)
+++ z3ext.formatter/tags/1.2.5/setup.py 2008-11-23 07:45:14 UTC (rev 93276)
@@ -1,77 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Setup for z3ext.formatter package
-
-$Id$
-"""
-import sys, os
-from setuptools import setup, find_packages
-
-def read(*rnames):
- return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
-
-version = '1.2.5dev'
-
-
-setup(name='z3ext.formatter',
- version=version,
- description="Extensible TALES fomratter expression.",
- long_description=(
- 'Detailed Dcoumentation\n' +
- '======================\n'
- + '\n\n' +
- read('src', 'z3ext', 'formatter', 'README.txt')
- + '\n\n' +
- read('CHANGES.txt')
- ),
- classifiers=[
- 'Development Status :: 5 - Production/Stable',
- 'Environment :: Web Environment',
- 'Intended Audience :: Developers',
- 'License :: OSI Approved :: Zope Public License',
- 'Programming Language :: Python',
- 'Natural Language :: English',
- 'Operating System :: OS Independent',
- 'Topic :: Internet :: WWW/HTTP',
- 'Framework :: Zope3'],
- author='Nikolay Kim',
- author_email='fafhrd91 at gmail.com',
- url='http://z3ext.net/',
- license='ZPL 2.1',
- package_dir = {'':'src'},
- packages=find_packages('src'),
- namespace_packages=['z3ext'],
- install_requires = ['setuptools',
- 'pytz',
- 'zope.component',
- 'zope.interface',
- 'zope.publisher',
- 'zope.schema',
- 'zope.proxy',
- 'zope.tales',
- 'zope.i18n',
- 'zope.i18nmessageid',
- 'zope.app.appsetup',
- 'zope.app.pagetemplate',
- 'zope.app.publisher',
- 'z3c.autoinclude',
- ],
- extras_require = dict(test=['zope.app.zptpage',
- 'zope.app.testing',
- 'zope.testing',
- 'z3ext.controlpanel [test]',
- ]),
- include_package_data = True,
- zip_safe = False
- )
Copied: z3ext.formatter/tags/1.2.5/setup.py (from rev 93275, z3ext.formatter/trunk/setup.py)
===================================================================
--- z3ext.formatter/tags/1.2.5/setup.py (rev 0)
+++ z3ext.formatter/tags/1.2.5/setup.py 2008-11-23 07:45:14 UTC (rev 93276)
@@ -0,0 +1,76 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Setup for z3ext.formatter package
+
+$Id$
+"""
+import sys, os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+ return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+version = '1.2.5'
+
+
+setup(name='z3ext.formatter',
+ version=version,
+ description="Extensible TALES fomratter expression.",
+ long_description=(
+ 'Detailed Dcoumentation\n' +
+ '======================\n'
+ + '\n\n' +
+ read('src', 'z3ext', 'formatter', 'README.txt')
+ + '\n\n' +
+ read('CHANGES.txt')
+ ),
+ classifiers=[
+ 'Development Status :: 5 - Production/Stable',
+ 'Environment :: Web Environment',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: Zope Public License',
+ 'Programming Language :: Python',
+ 'Natural Language :: English',
+ 'Operating System :: OS Independent',
+ 'Topic :: Internet :: WWW/HTTP',
+ 'Framework :: Zope3'],
+ author='Nikolay Kim',
+ author_email='fafhrd91 at gmail.com',
+ url='http://z3ext.net/',
+ license='ZPL 2.1',
+ package_dir = {'':'src'},
+ packages=find_packages('src'),
+ namespace_packages=['z3ext'],
+ install_requires = ['setuptools',
+ 'pytz',
+ 'zope.component',
+ 'zope.interface',
+ 'zope.publisher',
+ 'zope.schema',
+ 'zope.proxy',
+ 'zope.tales',
+ 'zope.i18n',
+ 'zope.i18nmessageid',
+ 'zope.app.appsetup',
+ 'zope.app.pagetemplate',
+ 'zope.app.publisher',
+ 'z3c.autoinclude',
+ ],
+ extras_require = dict(test=['zope.app.testing',
+ 'zope.testing',
+ 'z3ext.controlpanel [test]',
+ ]),
+ include_package_data = True,
+ zip_safe = False
+ )
Deleted: z3ext.formatter/tags/1.2.5/src/z3ext/formatter/README.txt
===================================================================
--- z3ext.formatter/trunk/src/z3ext/formatter/README.txt 2008-11-22 08:58:59 UTC (rev 93257)
+++ z3ext.formatter/tags/1.2.5/src/z3ext/formatter/README.txt 2008-11-23 07:45:14 UTC (rev 93276)
@@ -1,398 +0,0 @@
-===============
-z3ext.formatter
-===============
-
-This package adds extensible tales expression for various formatters.
-You can change formatter setting per site basis (z3ext.controlpanel).
-
-For configure default settings, add following code to zope.conf
-
-<product-config z3ext.formatter>
- timezone UTC
- timezoneFormat 2
- principalTimezone true
-</product-config>
-
-Values for timezoneFormat are:
- 1: No timezone
- 2: Number of hours
- 3: Timezone name
-
-We need register controlpanel configlet
-
- >>> from zope.configuration import xmlconfig
- >>> context = xmlconfig.string("""
- ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
- ... i18n_domain="z3ext.formatter">
- ... <include package="z3ext.controlpanel" file="meta.zcml" />
- ... <z3ext:configlet
- ... name="formatter"
- ... schema="z3ext.formatter.interfaces.IFormatterConfiglet"
- ... title="Portal formatters"
- ... description="Configure portal formatters."/>
- ... </configure>""")
-
-We'll try emulate <product-config z3ext.formatter>
-
- >>> from zope.app.appsetup import product
- >>> product._configs['z3ext.formatter'] = {
- ... 'timezone': u'UTC', 'timezoneFormat': '2', 'principalTimezone': 'true'}
-
-Let's check this
-
- >>> product.getProductConfiguration('z3ext.formatter')
- {'timezone': u'UTC', 'timezoneFormat': '2', 'principalTimezone': 'true'}
-
-
-Usually initFormatter() function is colled during IDatabaseOpenedEvent event,
-we simply call it directly:
-
- >>> from z3ext.formatter.config import initFormatter
- >>> initFormatter(None)
-
-Now we can get IFormatterConfiglet utility
-
- >>> from zope.component import getUtility
- >>> from z3ext.formatter.interfaces import IFormatterConfiglet
-
- >>> configlet = getUtility(IFormatterConfiglet)
-
-Setup request
-
- >>> from zope import interface
- >>> from zope.publisher.browser import TestRequest
- >>> from zope.annotation.interfaces import IAttributeAnnotatable
-
- >>> request = TestRequest(environ={'HTTP_ACCEPT_LANGUAGE': 'en'})
- >>> interface.directlyProvides(request, IAttributeAnnotatable)
-
- >>> from pytz import UTC
- >>> from datetime import date, datetime, timedelta
-
-
-DateTime formatter
-------------------
-
- >>> from zope.app.zptpage import ZPTPage
- >>> page = ZPTPage()
- >>> page.setSource(u'''
- ... <html>
- ... <body>
- ... <tal:block tal:content="formatter:dateTime,short:options/now" />
- ... <tal:block tal:content="formatter:dateTime,medium:options/now" />
- ... <tal:block tal:content="formatter:dateTime,long:options/now" />
- ... <tal:block tal:content="formatter:dateTime,full:options/now" />
- ... <tal:block tal:content="formatter:dateTime:options/now" />
- ... </body>
- ... </html>''')
-
- >>> dt = datetime(2007, 1, 1, 0, 0, 0, tzinfo=UTC)
- >>> dt
- datetime.datetime(2007, 1, 1, 0, 0, tzinfo=<UTC>)
-
-By default we use UTC timezone for output:
-
- >>> print page.render(request, now=dt)
- <BLANKLINE>
- <html>
- <body>
- 1/1/07 12:00 AM
- Jan 1, 2007 12:00:00 AM
- January 1, 2007 12:00:00 AM +000
- Monday, January 1, 2007 12:00:00 AM +000
- Jan 1, 2007 12:00:00 AM
- </body>
- </html>
- <BLANKLINE>
-
-If datetime object doesn't contain timezone information, UTC is used
-
- >>> print page.render(request, now=datetime(2007, 1, 1, 0, 0))
- <BLANKLINE>
- <html>
- <body>
- 1/1/07 12:00 AM
- Jan 1, 2007 12:00:00 AM
- January 1, 2007 12:00:00 AM +000
- Monday, January 1, 2007 12:00:00 AM +000
- Jan 1, 2007 12:00:00 AM
- </body>
- </html>
- <BLANKLINE>
-
-
-Now let's chane timezone to US/Pacific, we change only time zone
-not datetime value
-
- >>> configlet.timezone = 'US/Pacific'
-
- >>> print page.render(request, now=dt)
- <BLANKLINE>
- <html>
- <body>
- 12/31/06 4:00 PM
- Dec 31, 2006 4:00:00 PM
- December 31, 2006 4:00:00 PM -800
- Sunday, December 31, 2006 4:00:00 PM -800
- Dec 31, 2006 4:00:00 PM
- </body>
- </html>
- <BLANKLINE>
-
-Now we can change timezone format to 3 (Timezone name)
-
- >>> configlet.timezoneFormat = 3
-
- >>> print page.render(request, now=dt)
- <BLANKLINE>
- <html>
- <body>
- 12/31/06 4:00 PM
- Dec 31, 2006 4:00:00 PM US/Pacific
- December 31, 2006 4:00:00 PM -800
- Sunday, December 31, 2006 4:00:00 PM US/Pacific
- Dec 31, 2006 4:00:00 PM US/Pacific
- </body>
- </html>
- <BLANKLINE>
-
-We also can redefine timezone for principal if we use principalTimezone true
-
- >>> from pytz import timezone
- >>> from zope import interface, component
- >>> class IPrincipal(interface.Interface):
- ... pass
-
- >>> class Principal:
- ... interface.implements(IPrincipal)
- ...
- ... def __init__(self, id):
- ... self.id = id
- ... self.groups = []
-
- >>> @component.adapter(IPrincipal)
- ... @interface.implementer(interface.common.idatetime.ITZInfo)
- ... def getTimezone(prin):
- ... if prin.id == 'user1':
- ... return timezone('Europe/Paris')
- ... elif prin.id == 'user2':
- ... return timezone('Asia/Almaty')
- >>> component.provideAdapter(getTimezone)
-
- >>> request.setPrincipal(Principal('user1'))
- >>> print page.render(request, now=dt)
- <BLANKLINE>
- <html>
- <body>
- 1/1/07 1:00 AM
- Jan 1, 2007 1:00:00 AM Europe/Paris
- January 1, 2007 1:00:00 AM +100
- Monday, January 1, 2007 1:00:00 AM Europe/Paris
- Jan 1, 2007 1:00:00 AM Europe/Paris
- </body>
- </html>
- <BLANKLINE>
-
- >>> request.setPrincipal(Principal('user2'))
- >>> print page.render(request, now=dt)
- <BLANKLINE>
- <html>
- <body>
- 1/1/07 6:00 AM
- Jan 1, 2007 6:00:00 AM Asia/Almaty
- January 1, 2007 6:00:00 AM +600
- Monday, January 1, 2007 6:00:00 AM Asia/Almaty
- Jan 1, 2007 6:00:00 AM Asia/Almaty
- </body>
- </html>
- <BLANKLINE>
-
- >>> request.setPrincipal(None)
-
-
-fancyDatetime formatter
------------------------
-
- >>> now = datetime.now(UTC)
-
- >>> from zope.app.zptpage import ZPTPage
- >>> fpage = ZPTPage()
- >>> fpage.setSource(u'''
- ... <html>
- ... <body>
- ... <tal:block tal:content="formatter:fancyDatetime:options/now" />
- ... <tal:block tal:content="formatter:fancyDatetime,short:options/now" />
- ... <tal:block tal:content="formatter:fancyDatetime,medium:options/now" />
- ... <tal:block tal:content="formatter:fancyDatetime,full:options/now" />
- ... </body>
- ... </html>''')
-
-Today's datetime
-
- >>> today = now - timedelta(hours=1)
-
- >>> print fpage.render(request, now=today)
- <BLANKLINE>
- <html>
- <body>
- Today at ...
- Today at ...
- Today at ...
- Today at ... US/Pacific
- </body>
- </html>
- <BLANKLINE>
-
-
-Yesterday's datetime
-
- >>> yesterday = now - timedelta(hours=25)
-
- >>> print fpage.render(request, now=yesterday)
- <BLANKLINE>
- <html>
- <body>
- Yesterday at ...
- Yesterday at ...
- Yesterday at ...
- Yesterday at ... US/Pacific
- </body>
- </html>
- <BLANKLINE>
-
-Default timezone is UTC
-
- >>> now = datetime.now()
- >>> print fpage.render(request, now=now)
- <BLANKLINE>
- <html>
- <body>
- Today at ...
- Today at ...
- Today at ...
- Today at ... US/Pacific
- </body>
- </html>
- <BLANKLINE>
-
-
-Date formatter
---------------
-
- >>> datepage = ZPTPage()
- >>> datepage.setSource(u'''
- ... <html>
- ... <body>
- ... <tal:block tal:content="formatter:date:options/today" />
- ... <tal:block tal:content="formatter:date,short:options/today" />
- ... </body>
- ... </html>''')
-
- >>> d = date(2007, 1, 1)
- >>> d
- datetime.date(2007, 1, 1)
-
- >>> print datepage.render(request, today=d)
- <BLANKLINE>
- <html>
- <body>
- Jan 1, 2007
- 1/1/07
- </body>
- </html>
- <BLANKLINE>
-
-
-Also you can get formatter from python code
-
- >>> from z3ext.formatter.utils import getFormatter
- >>> formatter = getFormatter(request, 'dateTime', 'full')
- >>> formatter.format(dt)
- u'Sunday, December 31, 2006 4:00:00 PM US/Pacific'
-
-We will get FormatterNotDefined if formatter is unknown
-
- >>> getFormatter(request, 'unknown')
- Traceback (most recent call last):
- ...
- FormatterNotDefined: ...
-
-Wrong format, we should add path expression
-
- >>> errpage = ZPTPage()
- >>> errpage.setSource(u'''
- ... <tal:block tal:content="formatter:unknown" />''')
- >>> print errpage.render(request)
- Traceback (most recent call last):
- ...
- PTRuntimeError: ...
-
-Unknown formatter
-
- >>> errpage = ZPTPage()
- >>> errpage.setSource(u'''
- ... <tal:block tal:content="formatter:unknown:opitons/now" />''')
- >>> print errpage.render(request)
- Traceback (most recent call last):
- ...
- FormatterNotDefined: unknown
-
-
-Custom formatter
-================
-
-We should define formatter factory and formatter itself
-Let's implement formatter that accept string and currency name and
-format as currency. Format of TALES expression whould be as
-'formatter:<formatter name>,<formatter var1>,<formatter var2>,...:<path expression>'
-<formatter name> is name of adapter that adapts IHTTPRequest to IFormatterFactory
-also expression will pass <formatter var[1-...]> as args to factory.
-
- >>> from z3ext.formatter.interfaces import IFormatter, IFormatterFactory
-
-Here code of formatter:
-
- >>> class MyFormatter(object):
- ... interface.implements(IFormatter)
- ...
- ... currencies = {'usd': '$', 'euro': 'Eur'}
- ...
- ... def __init__(self, request, *args):
- ... self.request = request
- ... self.currency = self.currencies[args[0]]
- ...
- ... def format(self, value):
- ... return '%s %s'%(value, self.currency)
-
-Now we need formatter factory:
-
- >>> class MyFormatterFactory(object):
- ... interface.implements(IFormatterFactory)
- ...
- ... def __init__(self, request):
- ... self.request = request
- ...
- ... def __call__(self, *args, **kw):
- ... return MyFormatter(self.request, *args)
-
-Now we need register factory as named adapter for IHTTPRequest
-
- >>> from zope.component import provideAdapter
- >>> from zope.publisher.interfaces.http import IHTTPRequest
-
- >>> provideAdapter(MyFormatterFactory, \
- ... (IHTTPRequest,), IFormatterFactory, name='currency')
-
-Now we can use formatter
-
- >>> page = ZPTPage()
- >>> page.setSource(u'''<tal:block tal:define="value python:121.04">
- ... <tal:block tal:content="formatter:currency,usd:value" />
- ... <tal:block tal:content="formatter:currency,euro:value" />
- ... </tal:block>''')
-
- >>> print page.render(request)
- <BLANKLINE>
- 121.04 $
- 121.04 Eur
- <BLANKLINE>
Copied: z3ext.formatter/tags/1.2.5/src/z3ext/formatter/README.txt (from rev 93275, z3ext.formatter/trunk/src/z3ext/formatter/README.txt)
===================================================================
--- z3ext.formatter/tags/1.2.5/src/z3ext/formatter/README.txt (rev 0)
+++ z3ext.formatter/tags/1.2.5/src/z3ext/formatter/README.txt 2008-11-23 07:45:14 UTC (rev 93276)
@@ -0,0 +1,379 @@
+===============
+z3ext.formatter
+===============
+
+This package adds extensible tales expression for various formatters.
+You can change formatter setting per site basis (z3ext.controlpanel).
+
+For configure default settings, add following code to zope.conf
+
+<product-config z3ext.formatter>
+ timezone UTC
+ timezoneFormat 2
+ principalTimezone true
+</product-config>
+
+Values for timezoneFormat are:
+ 1: No timezone
+ 2: Number of hours
+ 3: Timezone name
+
+We need register controlpanel configlet
+
+ >>> from zope.configuration import xmlconfig
+ >>> context = xmlconfig.string("""
+ ... <configure xmlns:z3ext="http://namespaces.zope.org/z3ext"
+ ... i18n_domain="z3ext.formatter">
+ ... <include package="z3ext.controlpanel" file="meta.zcml" />
+ ... <z3ext:configlet
+ ... name="formatter"
+ ... schema="z3ext.formatter.interfaces.IFormatterConfiglet"
+ ... title="Portal formatters"
+ ... description="Configure portal formatters."/>
+ ... </configure>""")
+
+We'll try emulate <product-config z3ext.formatter>
+
+ >>> from zope.app.appsetup import product
+ >>> product._configs['z3ext.formatter'] = {
+ ... 'timezone': u'UTC', 'timezoneFormat': '2', 'principalTimezone': 'true'}
+
+Let's check this
+
+ >>> product.getProductConfiguration('z3ext.formatter')
+ {'timezone': u'UTC', 'timezoneFormat': '2', 'principalTimezone': 'true'}
+
+
+Usually initFormatter() function is colled during IDatabaseOpenedEvent event,
+we simply call it directly:
+
+ >>> from z3ext.formatter.config import initFormatter
+ >>> initFormatter(None)
+
+Now we can get IFormatterConfiglet utility
+
+ >>> from zope.component import getUtility
+ >>> from z3ext.formatter.interfaces import IFormatterConfiglet
+
+ >>> configlet = getUtility(IFormatterConfiglet)
+
+Setup request
+
+ >>> from zope import interface
+ >>> from zope.publisher.browser import TestRequest
+ >>> from zope.annotation.interfaces import IAttributeAnnotatable
+
+ >>> request = TestRequest(environ={'HTTP_ACCEPT_LANGUAGE': 'en'})
+ >>> interface.directlyProvides(request, IAttributeAnnotatable)
+
+ >>> from pytz import UTC
+ >>> from datetime import date, datetime, timedelta
+
+
+DateTime formatter
+------------------
+
+ >>> from z3ext.formatter.tests import ZPTPage
+ >>> page = ZPTPage()
+ >>> page.pt_edit(u'''
+ ... <html>
+ ... <body>
+ ... <tal:block tal:content="formatter:dateTime,short:options/now" />
+ ... <tal:block tal:content="formatter:dateTime,medium:options/now" />
+ ... <tal:block tal:content="formatter:dateTime,long:options/now" />
+ ... <tal:block tal:content="formatter:dateTime,full:options/now" />
+ ... <tal:block tal:content="formatter:dateTime:options/now" />
+ ... </body>
+ ... </html>''', 'text/html')
+
+ >>> dt = datetime(2007, 1, 1, 0, 0, 0, tzinfo=UTC)
+ >>> dt
+ datetime.datetime(2007, 1, 1, 0, 0, tzinfo=<UTC>)
+
+By default we use UTC timezone for output:
+
+ >>> print page.render(request, now=dt)
+ <html>
+ <body>
+ 1/1/07 12:00 AM
+ Jan 1, 2007 12:00:00 AM
+ January 1, 2007 12:00:00 AM +000
+ Monday, January 1, 2007 12:00:00 AM +000
+ Jan 1, 2007 12:00:00 AM
+ </body>
+ </html>
+
+
+If datetime object doesn't contain timezone information, UTC is used
+
+ >>> print page.render(request, now=datetime(2007, 1, 1, 0, 0))
+ <html>
+ <body>
+ 1/1/07 12:00 AM
+ Jan 1, 2007 12:00:00 AM
+ January 1, 2007 12:00:00 AM +000
+ Monday, January 1, 2007 12:00:00 AM +000
+ Jan 1, 2007 12:00:00 AM
+ </body>
+ </html>
+
+
+Now let's chane timezone to US/Pacific, we change only time zone
+not datetime value
+
+ >>> configlet.timezone = 'US/Pacific'
+
+ >>> print page.render(request, now=dt)
+ <html>
+ <body>
+ 12/31/06 4:00 PM
+ Dec 31, 2006 4:00:00 PM
+ December 31, 2006 4:00:00 PM -800
+ Sunday, December 31, 2006 4:00:00 PM -800
+ Dec 31, 2006 4:00:00 PM
+ </body>
+ </html>
+
+
+Now we can change timezone format to 3 (Timezone name)
+
+ >>> configlet.timezoneFormat = 3
+
+ >>> print page.render(request, now=dt)
+ <html>
+ <body>
+ 12/31/06 4:00 PM
+ Dec 31, 2006 4:00:00 PM US/Pacific
+ December 31, 2006 4:00:00 PM -800
+ Sunday, December 31, 2006 4:00:00 PM US/Pacific
+ Dec 31, 2006 4:00:00 PM US/Pacific
+ </body>
+ </html>
+
+
+We also can redefine timezone for principal if we use principalTimezone true
+
+ >>> from pytz import timezone
+ >>> from zope import interface, component
+ >>> class IPrincipal(interface.Interface):
+ ... pass
+
+ >>> class Principal:
+ ... interface.implements(IPrincipal)
+ ...
+ ... def __init__(self, id):
+ ... self.id = id
+ ... self.groups = []
+
+ >>> @component.adapter(IPrincipal)
+ ... @interface.implementer(interface.common.idatetime.ITZInfo)
+ ... def getTimezone(prin):
+ ... if prin.id == 'user1':
+ ... return timezone('Europe/Paris')
+ ... elif prin.id == 'user2':
+ ... return timezone('Asia/Almaty')
+ >>> component.provideAdapter(getTimezone)
+
+ >>> request.setPrincipal(Principal('user1'))
+ >>> print page.render(request, now=dt)
+ <html>
+ <body>
+ 1/1/07 1:00 AM
+ Jan 1, 2007 1:00:00 AM Europe/Paris
+ January 1, 2007 1:00:00 AM +100
+ Monday, January 1, 2007 1:00:00 AM Europe/Paris
+ Jan 1, 2007 1:00:00 AM Europe/Paris
+ </body>
+ </html>
+
+ >>> request.setPrincipal(Principal('user2'))
+ >>> print page.render(request, now=dt)
+ <html>
+ <body>
+ 1/1/07 6:00 AM
+ Jan 1, 2007 6:00:00 AM Asia/Almaty
+ January 1, 2007 6:00:00 AM +600
+ Monday, January 1, 2007 6:00:00 AM Asia/Almaty
+ Jan 1, 2007 6:00:00 AM Asia/Almaty
+ </body>
+ </html>
+
+ >>> request.setPrincipal(None)
+
+
+fancyDatetime formatter
+-----------------------
+
+ >>> now = datetime.now(UTC)
+
+ >>> fpage = ZPTPage()
+ >>> fpage.pt_edit(u'''
+ ... <html>
+ ... <body>
+ ... <tal:block tal:content="formatter:fancyDatetime:options/now" />
+ ... <tal:block tal:content="formatter:fancyDatetime,short:options/now" />
+ ... <tal:block tal:content="formatter:fancyDatetime,medium:options/now" />
+ ... <tal:block tal:content="formatter:fancyDatetime,full:options/now" />
+ ... </body>
+ ... </html>''', 'text/html')
+
+Today's datetime
+
+ >>> today = now - timedelta(hours=1)
+
+ >>> print fpage.render(request, now=today)
+ <html>
+ <body>
+ Today at ...
+ Today at ...
+ Today at ...
+ Today at ...
+ </body>
+ </html>
+
+
+Yesterday's datetime
+
+ >>> yesterday = now - timedelta(hours=25)
+
+ >>> print fpage.render(request, now=yesterday)
+ <html>
+ <body>
+ Yesterday at ...
+ Yesterday at ...
+ Yesterday at ...
+ Yesterday at ...
+ </body>
+ </html>
+
+
+Default timezone is UTC
+
+ >>> now = datetime.now(UTC)
+ >>> print fpage.render(request, now=now)
+ <html>
+ <body>
+ Today at ...
+ Today at ...
+ Today at ...
+ Today at ...
+ </body>
+ </html>
+
+
+Date formatter
+--------------
+
+ >>> datepage = ZPTPage()
+ >>> datepage.pt_edit(u'''
+ ... <html>
+ ... <body>
+ ... <tal:block tal:content="formatter:date:options/today" />
+ ... <tal:block tal:content="formatter:date,short:options/today" />
+ ... </body>
+ ... </html>''', 'text/html')
+
+ >>> d = date(2007, 1, 1)
+ >>> d
+ datetime.date(2007, 1, 1)
+
+ >>> print datepage.render(request, today=d)
+ <html>
+ <body>
+ Jan 1, 2007
+ 1/1/07
+ </body>
+ </html>
+
+
+Also you can get formatter from python code
+
+ >>> from z3ext.formatter.utils import getFormatter
+ >>> formatter = getFormatter(request, 'dateTime', 'full')
+ >>> formatter.format(dt)
+ u'Sunday, December 31, 2006 4:00:00 PM US/Pacific'
+
+We will get FormatterNotDefined if formatter is unknown
+
+ >>> getFormatter(request, 'unknown')
+ Traceback (most recent call last):
+ ...
+ FormatterNotDefined: ...
+
+Wrong format, we should add path expression
+
+ >>> errpage = ZPTPage()
+ >>> errpage.pt_edit(u'''
+ ... <tal:block tal:content="formatter:unknown" />''', 'text/html')
+ >>> print errpage.render(request)
+ Traceback (most recent call last):
+ ...
+ PTRuntimeError: ...
+
+Unknown formatter
+
+ >>> errpage = ZPTPage()
+ >>> errpage.pt_edit(u'''
+ ... <tal:block tal:content="formatter:unknown:opitons/now" />''', 'text/html')
+ >>> print errpage.render(request)
+ Traceback (most recent call last):
+ ...
+ FormatterNotDefined: unknown
+
+
+Custom formatter
+================
+
+We should define formatter factory and formatter itself
+Let's implement formatter that accept string and currency name and
+format as currency. Format of TALES expression whould be as
+'formatter:<formatter name>,<formatter var1>,<formatter var2>,...:<path expression>'
+<formatter name> is name of adapter that adapts IHTTPRequest to IFormatterFactory
+also expression will pass <formatter var[1-...]> as args to factory.
+
+ >>> from z3ext.formatter.interfaces import IFormatter, IFormatterFactory
+
+Here code of formatter:
+
+ >>> class MyFormatter(object):
+ ... interface.implements(IFormatter)
+ ...
+ ... currencies = {'usd': '$', 'euro': 'Eur'}
+ ...
+ ... def __init__(self, request, *args):
+ ... self.request = request
+ ... self.currency = self.currencies[args[0]]
+ ...
+ ... def format(self, value):
+ ... return '%s %s'%(value, self.currency)
+
+Now we need formatter factory:
+
+ >>> class MyFormatterFactory(object):
+ ... interface.implements(IFormatterFactory)
+ ...
+ ... def __init__(self, request):
+ ... self.request = request
+ ...
+ ... def __call__(self, *args, **kw):
+ ... return MyFormatter(self.request, *args)
+
+Now we need register factory as named adapter for IHTTPRequest
+
+ >>> from zope.component import provideAdapter
+ >>> from zope.publisher.interfaces.http import IHTTPRequest
+
+ >>> provideAdapter(MyFormatterFactory, \
+ ... (IHTTPRequest,), IFormatterFactory, name='currency')
+
+Now we can use formatter
+
+ >>> page = ZPTPage()
+ >>> page.pt_edit(u'''<tal:block tal:define="value python:121.04">
+ ... <tal:block tal:content="formatter:currency,usd:value" />
+ ... <tal:block tal:content="formatter:currency,euro:value" />
+ ... </tal:block>''', 'text/html')
+
+ >>> print page.render(request)
+ 121.04 $
+ 121.04 Eur
Deleted: z3ext.formatter/tags/1.2.5/src/z3ext/formatter/configure.zcml
===================================================================
--- z3ext.formatter/trunk/src/z3ext/formatter/configure.zcml 2008-11-22 08:58:59 UTC (rev 93257)
+++ z3ext.formatter/tags/1.2.5/src/z3ext/formatter/configure.zcml 2008-11-23 07:45:14 UTC (rev 93276)
@@ -1,67 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:i18n="http://namespaces.zope.org/i18n"
- xmlns:z3ext="http://namespaces.zope.org/z3ext"
- xmlns:tales="http://namespaces.zope.org/tales"
- xmlns:browser="http://namespaces.zope.org/browser"
- i18n_domain="z3ext.formatter">
-
- <includeDependencies package="z3ext.formatter" />
-
- <!-- zope.conf configuration -->
- <subscriber handler=".config.initFormatter" />
-
- <!-- formatter: tales expresison -->
- <tales:expressiontype
- name="formatter"
- handler=".expression.FormatterExpression" />
-
- <!-- formatters -->
- <adapter name="date" factory=".dformatter.DateFormatterFactory" />
- <adapter name="dateTime" factory=".dtformatter.DatetimeFormatterFactory" />
- <adapter name="fancyDatetime"
- factory=".fancydatetime.FancyDatetimeFormatterFactory" />
-
- <!-- vocabularies -->
- <utility
- name="Timezones"
- factory=".vocabulary.Timezones" />
-
- <!-- formatter configlet -->
- <configure
- xmlns:zcml="http://namespaces.zope.org/zcml"
- xmlns:browser="http://namespaces.zope.org/browser"
- zcml:condition="installed z3ext.controlpanel">
- <include package="z3ext.controlpanel" />
-
- <z3ext:configlet
- name="system.formatter"
- schema=".interfaces.IFormatterConfiglet"
- title="Portal formatters"
- description="Configure portal formatters.">
- <allow interface=".interfaces.IFormatterConfiglet" />
- </z3ext:configlet>
-
- <browser:icon
- name="zmi_icon"
- for=".interfaces.IFormatterConfiglet"
- file="preferences-formatter.png" />
- </configure>
-
- <!-- Registering documentation with API doc -->
- <configure
- xmlns:apidoc="http://namespaces.zope.org/apidoc"
- xmlns:zcml="http://namespaces.zope.org/zcml"
- zcml:condition="have apidoc">
-
- <apidoc:bookchapter
- id="z3ext-formatter"
- title="z3ext.formatter - formatter TALES expression"
- doc_path="README.txt"
- parent="z3ext" />
- </configure>
-
- <!-- translations -->
- <i18n:registerTranslations directory="locales"/>
-
-</configure>
Copied: z3ext.formatter/tags/1.2.5/src/z3ext/formatter/configure.zcml (from rev 93275, z3ext.formatter/trunk/src/z3ext/formatter/configure.zcml)
===================================================================
--- z3ext.formatter/tags/1.2.5/src/z3ext/formatter/configure.zcml (rev 0)
+++ z3ext.formatter/tags/1.2.5/src/z3ext/formatter/configure.zcml 2008-11-23 07:45:14 UTC (rev 93276)
@@ -0,0 +1,69 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:i18n="http://namespaces.zope.org/i18n"
+ xmlns:z3ext="http://namespaces.zope.org/z3ext"
+ xmlns:tales="http://namespaces.zope.org/tales"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ i18n_domain="z3ext.formatter">
+
+ <includeDependencies package="z3ext.formatter" />
+
+ <!-- zope.conf configuration -->
+ <subscriber handler=".config.initFormatter" />
+
+ <!-- formatter: tales expresison -->
+ <tales:expressiontype
+ name="formatter"
+ handler=".expression.FormatterExpression" />
+
+ <!-- formatters -->
+ <adapter name="date" factory=".dformatter.DateFormatterFactory" />
+ <adapter name="dateTime" factory=".dtformatter.DatetimeFormatterFactory" />
+ <adapter name="fancyDatetime"
+ factory=".fancydatetime.FancyDatetimeFormatterFactory" />
+
+ <!-- vocabularies -->
+ <utility
+ name="Timezones"
+ factory=".vocabulary.Timezones" />
+
+ <!-- formatter configlet -->
+ <configure
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ zcml:condition="installed z3ext.controlpanel">
+
+ <include package="z3ext.controlpanel" file="meta.zcml" />
+ <include package="z3ext.controlpanel" />
+
+ <z3ext:configlet
+ name="system.formatter"
+ schema=".interfaces.IFormatterConfiglet"
+ title="Portal formatters"
+ description="Configure portal formatters.">
+ <allow interface=".interfaces.IFormatterConfiglet" />
+ </z3ext:configlet>
+
+ <browser:icon
+ name="zmi_icon"
+ for=".interfaces.IFormatterConfiglet"
+ file="preferences-formatter.png" />
+ </configure>
+
+ <!-- Registering documentation with API doc -->
+ <configure
+ xmlns:apidoc="http://namespaces.zope.org/apidoc"
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ zcml:condition="have apidoc">
+
+ <apidoc:bookchapter
+ id="z3ext-formatter"
+ title="z3ext.formatter - formatter TALES expression"
+ doc_path="README.txt"
+ parent="z3ext" />
+ </configure>
+
+ <!-- translations -->
+ <i18n:registerTranslations directory="locales"/>
+
+</configure>
Deleted: z3ext.formatter/tags/1.2.5/src/z3ext/formatter/tests.py
===================================================================
--- z3ext.formatter/trunk/src/z3ext/formatter/tests.py 2008-11-22 08:58:59 UTC (rev 93257)
+++ z3ext.formatter/tags/1.2.5/src/z3ext/formatter/tests.py 2008-11-23 07:45:14 UTC (rev 93276)
@@ -1,62 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" z3ext.formatter tests
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-
-import unittest, doctest
-from zope import interface, schema
-from zope.component import provideAdapter
-from zope.testing.cleanup import cleanUp
-from zope.app.testing import setup
-
-from zope.app.pagetemplate.engine import Engine, TrustedEngine
-from zope.app.pagetemplate.metaconfigure import clear
-
-from z3ext.controlpanel.testing import setUpControlPanel
-
-from z3ext.formatter import dformatter, dtformatter, fancydatetime
-from z3ext.formatter.expression import FormatterExpression
-
-
-def setUp(test):
- setup.placefulSetUp(True)
- setup.setUpTraversal()
- setUpControlPanel()
-
- Engine.registerType(u'formatter', FormatterExpression)
- TrustedEngine.registerType(u'formatter', FormatterExpression)
-
- provideAdapter(dformatter.DateFormatterFactory, name='date')
- provideAdapter(dtformatter.DatetimeFormatterFactory, name='dateTime')
- provideAdapter(
- fancydatetime.FancyDatetimeFormatterFactory, name='fancyDatetime')
-
-
-def tearDown(test):
- setup.placelessTearDown()
- clear()
-
-
-def test_suite():
- return unittest.TestSuite((
- doctest.DocFileSuite(
- 'README.txt',
- setUp=setUp, tearDown=tearDown,
- optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
- doctest.DocFileSuite(
- 'config.txt', setUp=setUp, tearDown=tearDown),
- ))
Copied: z3ext.formatter/tags/1.2.5/src/z3ext/formatter/tests.py (from rev 93275, z3ext.formatter/trunk/src/z3ext/formatter/tests.py)
===================================================================
--- z3ext.formatter/tags/1.2.5/src/z3ext/formatter/tests.py (rev 0)
+++ z3ext.formatter/tags/1.2.5/src/z3ext/formatter/tests.py 2008-11-23 07:45:14 UTC (rev 93276)
@@ -0,0 +1,71 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+""" z3ext.formatter tests
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import unittest, doctest
+from zope import interface, schema
+from zope.component import provideAdapter
+from zope.testing.cleanup import cleanUp
+from zope.app.testing import setup
+
+from zope.pagetemplate.pagetemplate import PageTemplate
+from zope.app.pagetemplate.engine import Engine, TrustedEngine, TrustedAppPT
+from zope.app.pagetemplate.metaconfigure import clear
+
+from z3ext.controlpanel.testing import setUpControlPanel
+
+from z3ext.formatter import dformatter, dtformatter, fancydatetime
+from z3ext.formatter.expression import FormatterExpression
+
+
+class ZPTPage(TrustedAppPT, PageTemplate):
+
+ def render(self, request, *args, **kw):
+ namespace = self.pt_getContext(args, kw)
+ namespace['request'] = request
+ return self.pt_render(namespace)
+
+
+def setUp(test):
+ setup.placefulSetUp(True)
+ setup.setUpTraversal()
+ setUpControlPanel()
+
+ Engine.registerType(u'formatter', FormatterExpression)
+ TrustedEngine.registerType(u'formatter', FormatterExpression)
+
+ provideAdapter(dformatter.DateFormatterFactory, name='date')
+ provideAdapter(dtformatter.DatetimeFormatterFactory, name='dateTime')
+ provideAdapter(
+ fancydatetime.FancyDatetimeFormatterFactory, name='fancyDatetime')
+
+
+def tearDown(test):
+ setup.placelessTearDown()
+ clear()
+
+
+def test_suite():
+ return unittest.TestSuite((
+ doctest.DocFileSuite(
+ 'README.txt',
+ setUp=setUp, tearDown=tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
+ doctest.DocFileSuite(
+ 'config.txt', setUp=setUp, tearDown=tearDown),
+ ))
Copied: z3ext.formatter/tags/1.2.5/tests.cfg (from rev 93275, z3ext.formatter/trunk/tests.cfg)
===================================================================
--- z3ext.formatter/tags/1.2.5/tests.cfg (rev 0)
+++ z3ext.formatter/tags/1.2.5/tests.cfg 2008-11-23 07:45:14 UTC (rev 93276)
@@ -0,0 +1,14 @@
+[test]
+recipe = zc.recipe.testrunner
+eggs = z3ext.formatter [test]
+
+[coverage-test]
+recipe = zc.recipe.testrunner
+eggs = z3ext.formatter [test]
+defaults = ['--coverage', '../../coverage']
+
+[coverage-report]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('coverage', 'coverage/report')
Copied: z3ext.formatter/tags/1.2.5/zope34.cfg (from rev 93275, z3ext.formatter/trunk/zope34.cfg)
===================================================================
--- z3ext.formatter/tags/1.2.5/zope34.cfg (rev 0)
+++ z3ext.formatter/tags/1.2.5/zope34.cfg 2008-11-23 07:45:14 UTC (rev 93276)
@@ -0,0 +1,9 @@
+[buildout]
+develop = .
+parts = test coverage-test coverage-report
+versions = versions
+extends = tests.cfg
+ http://download.zope.org/zope3.4/versions-3.4.0c7.cfg
+
+[versions]
+z3c.zrtresource = 1.1.0
More information about the Checkins
mailing list