[Checkins] SVN: z3ext.formatter/tags/1.3.0/ release tag

Nikolay Kim fafhrd91 at gmail.com
Sun Jul 5 03:55:36 EDT 2009


Log message for revision 101561:
  release tag

Changed:
  A   z3ext.formatter/tags/1.3.0/
  D   z3ext.formatter/tags/1.3.0/CHANGES.txt
  A   z3ext.formatter/tags/1.3.0/CHANGES.txt
  D   z3ext.formatter/tags/1.3.0/setup.py
  A   z3ext.formatter/tags/1.3.0/setup.py
  A   z3ext.formatter/tags/1.3.0/src/z3ext/formatter/chameleonexpr.py
  D   z3ext.formatter/tags/1.3.0/src/z3ext/formatter/configure.zcml
  A   z3ext.formatter/tags/1.3.0/src/z3ext/formatter/configure.zcml
  D   z3ext.formatter/tags/1.3.0/src/z3ext/formatter/expression.py
  A   z3ext.formatter/tags/1.3.0/src/z3ext/formatter/expression.py
  D   z3ext.formatter/tags/1.3.0/src/z3ext/formatter/fancydatetime.py
  A   z3ext.formatter/tags/1.3.0/src/z3ext/formatter/fancydatetime.py
  D   z3ext.formatter/tags/1.3.0/src/z3ext/formatter/humandatetime.py
  A   z3ext.formatter/tags/1.3.0/src/z3ext/formatter/humandatetime.py

-=-
Deleted: z3ext.formatter/tags/1.3.0/CHANGES.txt
===================================================================
--- z3ext.formatter/trunk/CHANGES.txt	2009-07-05 02:47:34 UTC (rev 101558)
+++ z3ext.formatter/tags/1.3.0/CHANGES.txt	2009-07-05 07:55:36 UTC (rev 101561)
@@ -1,85 +0,0 @@
-=======
-CHANGES
-=======
-
-1.2.7 (2009-04-??)
-------------------
-
-- Do not use z3c.autoinclude
-
-
-1.2.6 (2009-03-11)
-------------------
-
-- Added 'human' datetime formatter (XX minute(s) ago)
-
-- Do not show seconds for fancyDatetime fomratter
-
-- Fixed multple usage of one fancyDatetime formatter
-
-
-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.

Copied: z3ext.formatter/tags/1.3.0/CHANGES.txt (from rev 101559, z3ext.formatter/trunk/CHANGES.txt)
===================================================================
--- z3ext.formatter/tags/1.3.0/CHANGES.txt	                        (rev 0)
+++ z3ext.formatter/tags/1.3.0/CHANGES.txt	2009-07-05 07:55:36 UTC (rev 101561)
@@ -0,0 +1,93 @@
+=======
+CHANGES
+=======
+
+1.3.0 (2009-07-05)
+------------------
+
+- Added chameleon support
+
+- Added 'formatter' chameleon expression
+
+
+1.2.7 (2009-04-??)
+------------------
+
+- Do not use z3c.autoinclude
+
+
+1.2.6 (2009-03-11)
+------------------
+
+- Added 'human' datetime formatter (XX minute(s) ago)
+
+- Do not show seconds for fancyDatetime fomratter
+
+- Fixed multple usage of one fancyDatetime formatter
+
+
+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.3.0/setup.py
===================================================================
--- z3ext.formatter/trunk/setup.py	2009-07-05 02:47:34 UTC (rev 101558)
+++ z3ext.formatter/tags/1.3.0/setup.py	2009-07-05 07:55:36 UTC (rev 101561)
@@ -1,75 +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.7dev'
-
-
-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',
-                          ],
-      extras_require = dict(test=['zope.app.testing',
-                                  'zope.testing',
-                                  'z3ext.controlpanel [test]',
-                                  ]),
-      include_package_data = True,
-      zip_safe = False
-      )

Copied: z3ext.formatter/tags/1.3.0/setup.py (from rev 101559, z3ext.formatter/trunk/setup.py)
===================================================================
--- z3ext.formatter/tags/1.3.0/setup.py	                        (rev 0)
+++ z3ext.formatter/tags/1.3.0/setup.py	2009-07-05 07:55:36 UTC (rev 101561)
@@ -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.3.0'
+
+
+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.pt',
+                          ],
+      extras_require = dict(test=['zope.app.testing',
+                                  'zope.testing',
+                                  'z3ext.controlpanel [test]',
+                                  ]),
+      include_package_data = True,
+      zip_safe = False
+      )

Copied: z3ext.formatter/tags/1.3.0/src/z3ext/formatter/chameleonexpr.py (from rev 101559, z3ext.formatter/trunk/src/z3ext/formatter/chameleonexpr.py)
===================================================================
--- z3ext.formatter/tags/1.3.0/src/z3ext/formatter/chameleonexpr.py	                        (rev 0)
+++ z3ext.formatter/tags/1.3.0/src/z3ext/formatter/chameleonexpr.py	2009-07-05 07:55:36 UTC (rev 101561)
@@ -0,0 +1,65 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Foundation 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.
+#
+##############################################################################
+""" 
+
+$Id:  2007-12-12 12:27:02Z fafhrd $
+"""
+from zope.component import queryAdapter
+
+from chameleon.core import types
+from chameleon.zpt import expressions
+from z3c.pt.expressions import path_translator
+
+from interfaces import \
+    IFormatterFactory, FormatterNotDefined, FormatterExpressionError
+
+
+class FormatterExpression(object):
+
+    def __call__(self, request, formatterName, formatterArgs, value):
+        factory = queryAdapter(
+            request, IFormatterFactory, name=formatterName)
+
+        if factory is None:
+            raise FormatterNotDefined(self.formatterName)
+
+        return factory(*formatterArgs).format(value)
+
+
+class FormatterTranslator(expressions.ExpressionTranslator):
+
+    symbol = '_get_z3ext_formatter'
+    formatter_traverse = FormatterExpression()
+
+    def translate(self, string, escape=None):
+        parts = string.strip().split(':', 1)
+
+        try:
+            formatterName, string = parts[0], parts[1]
+        except IndexError:
+            raise SyntaxError(string)
+
+        string = path_translator.translate(string, escape)
+
+        args = formatterName.split(',')
+        formatterName = args[0]
+        formatterArgs = args[1:]
+
+        value = types.value(
+            "%s(request, '%s', %s, %s)" % \
+            (self.symbol, formatterName, formatterArgs, string))
+
+        value.symbol_mapping[self.symbol] = self.formatter_traverse
+
+        return value

Deleted: z3ext.formatter/tags/1.3.0/src/z3ext/formatter/configure.zcml
===================================================================
--- z3ext.formatter/trunk/src/z3ext/formatter/configure.zcml	2009-07-05 02:47:34 UTC (rev 101558)
+++ z3ext.formatter/tags/1.3.0/src/z3ext/formatter/configure.zcml	2009-07-05 07:55:36 UTC (rev 101561)
@@ -1,74 +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">
-
-  <!-- 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" />
-
-  <adapter name="humanDatetime"
-	   factory=".humandatetime.HumanDatetimeFormatterFactory" />
-
-  <!-- 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>

Copied: z3ext.formatter/tags/1.3.0/src/z3ext/formatter/configure.zcml (from rev 101559, z3ext.formatter/trunk/src/z3ext/formatter/configure.zcml)
===================================================================
--- z3ext.formatter/tags/1.3.0/src/z3ext/formatter/configure.zcml	                        (rev 0)
+++ z3ext.formatter/tags/1.3.0/src/z3ext/formatter/configure.zcml	2009-07-05 07:55:36 UTC (rev 101561)
@@ -0,0 +1,79 @@
+<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">
+
+  <!-- zope.conf configuration -->
+  <subscriber handler=".config.initFormatter" />
+
+  <!-- formatter: chameleon expression -->
+  <utility
+     name="formatter"
+     factory=".chameleonexpr.FormatterTranslator" />
+
+  <!-- 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" />
+
+  <adapter name="humanDatetime"
+	   factory=".humandatetime.HumanDatetimeFormatterFactory" />
+
+  <!-- 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.3.0/src/z3ext/formatter/expression.py
===================================================================
--- z3ext.formatter/trunk/src/z3ext/formatter/expression.py	2009-07-05 02:47:34 UTC (rev 101558)
+++ z3ext.formatter/tags/1.3.0/src/z3ext/formatter/expression.py	2009-07-05 07:55:36 UTC (rev 101561)
@@ -1,58 +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.
-#
-##############################################################################
-""" ``formatter`` TALES expression
-Author: Nikolay Kim <fafhrd91 at gmail.com>
-
-$Id$
-"""
-
-from zope.component import queryAdapter
-from zope.proxy import removeAllProxies
-from zope.tales.expressions import PathExpr, simpleTraverse
-
-from interfaces import IFormatterFactory
-from interfaces import FormatterNotDefined, FormatterExpressionError
-
-
-class FormatterExpression(PathExpr):
-    """ formatter sytax:
-       formatter:<formatterName>,<formatterVar1>,<formatterVar2>,...:pathExpr """
-
-    def __init__(self, name, expr, engine, traverser=simpleTraverse):
-        parts = expr.split(':', 1)
-        try:
-            formatterName, pathExpr = parts[0], parts[1]
-        except IndexError:
-            raise FormatterExpressionError(expr)
-
-        args = formatterName.split(',')
-        self.formatterName = args[0]
-        self.formatterArgs = args[1:]
-
-        super(FormatterExpression, self).__init__(
-            name, pathExpr, engine, traverser=simpleTraverse)
-    
-    def __call__(self, econtext):
-        request = removeAllProxies(econtext.request)
-
-        factory = queryAdapter(
-            request, IFormatterFactory, name=self.formatterName)
-
-        if factory is None:
-            raise FormatterNotDefined(self.formatterName)
-
-        formatter = factory(*self.formatterArgs)
-
-        value = super(FormatterExpression, self).__call__(econtext)
-        return formatter.format(value)

Copied: z3ext.formatter/tags/1.3.0/src/z3ext/formatter/expression.py (from rev 101559, z3ext.formatter/trunk/src/z3ext/formatter/expression.py)
===================================================================
--- z3ext.formatter/tags/1.3.0/src/z3ext/formatter/expression.py	                        (rev 0)
+++ z3ext.formatter/tags/1.3.0/src/z3ext/formatter/expression.py	2009-07-05 07:55:36 UTC (rev 101561)
@@ -0,0 +1,57 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+""" ``formatter`` TALES expression
+Author: Nikolay Kim <fafhrd91 at gmail.com>
+
+$Id$
+"""
+from zope.component import queryAdapter
+from zope.proxy import removeAllProxies
+from zope.tales.expressions import PathExpr, simpleTraverse
+
+from interfaces import IFormatterFactory
+from interfaces import FormatterNotDefined, FormatterExpressionError
+
+
+class FormatterExpression(PathExpr):
+    """ formatter sytax:
+       formatter:<formatterName>,<formatterVar1>,<formatterVar2>,...:pathExpr """
+
+    def __init__(self, name, expr, engine, traverser=simpleTraverse):
+        parts = expr.split(':', 1)
+        try:
+            formatterName, pathExpr = parts[0], parts[1]
+        except IndexError:
+            raise FormatterExpressionError(expr)
+
+        args = formatterName.split(',')
+        self.formatterName = args[0]
+        self.formatterArgs = args[1:]
+
+        super(FormatterExpression, self).__init__(
+            name, pathExpr, engine, traverser=simpleTraverse)
+    
+    def __call__(self, econtext):
+        request = removeAllProxies(econtext.request)
+
+        factory = queryAdapter(
+            request, IFormatterFactory, name=self.formatterName)
+
+        if factory is None:
+            raise FormatterNotDefined(self.formatterName)
+
+        formatter = factory(*self.formatterArgs)
+
+        value = super(FormatterExpression, self).__call__(econtext)
+        return formatter.format(value)

Deleted: z3ext.formatter/tags/1.3.0/src/z3ext/formatter/fancydatetime.py
===================================================================
--- z3ext.formatter/trunk/src/z3ext/formatter/fancydatetime.py	2009-07-05 02:47:34 UTC (rev 101558)
+++ z3ext.formatter/tags/1.3.0/src/z3ext/formatter/fancydatetime.py	2009-07-05 07:55:36 UTC (rev 101561)
@@ -1,114 +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.
-#
-##############################################################################
-""" ``fancyDatetime`` formatter implementation
-
-$Id$
-"""
-
-from pytz import utc, timezone
-from datetime import datetime
-from zope import interface, component
-from zope.component import getUtility
-from zope.interface.common.idatetime import ITZInfo
-from zope.publisher.interfaces.http import IHTTPRequest
-
-from interfaces import _, IFormatter, IFormatterFactory, IFormatterConfiglet
-
-
-class FancyDatetimeFormatter(object):
-    interface.implements(IFormatter)
-
-    def __init__(self, request, *args):
-        try:
-            self.tp = args[0]
-        except:
-            self.tp = 'medium'
-
-        self.request = request
-        self.formatter = request.locale.dates.getFormatter('dateTime', self.tp)
-
-    def format(self, value):
-        formatter = self.formatter
-
-        configlet = getUtility(IFormatterConfiglet)
-        tz = None
-        if configlet.principalTimezone:
-            tz = ITZInfo(self.request.principal, None)
-
-        if tz is None:
-            tz = timezone(configlet.timezone)
-
-        if value.tzinfo is None:
-            value = datetime(value.year, value.month, value.day, value.hour,
-                             value.minute, value.second, value.microsecond, utc)
-
-        value = value.astimezone(tz)
-
-        timezoneFormat = configlet.timezoneFormat
-
-        d1 = datetime.now(utc).date()
-        d2 = value.astimezone(utc).date()
-
-        delta = d1 - d2
-
-        oldpattern = formatter.getPattern()
-        if ':ss' in oldpattern:
-            formatter.setPattern(oldpattern.replace(':ss', '').strip())
-
-        if delta.days == 0:
-            pattern = formatter.getPattern()
-            pos = pattern.find('h')
-            if pos < 0:
-                pos = pattern.find('H')
-
-            formatter.setPattern(pattern[pos:])
-            value = _(u'Today at ${value}',
-                      mapping={'value': formatter.format(value)})
-            formatter.setPattern(oldpattern)
-            return value
-
-        if delta.days == 1:
-            pattern = formatter.getPattern()
-            pos = pattern.find('h')
-            if pos < 0:
-                pos = pattern.find('H')
-
-            formatter.setPattern(pattern[pos:])
-            value = _(u'Yesterday at ${value}',
-                      mapping={'value': formatter.format(value)})
-            formatter.setPattern(oldpattern)
-            return value
-
-        if timezoneFormat == 3:
-            if self.tp in ('full',):
-                formatter.setPattern(
-                    formatter.getPattern().replace('z', '').strip())
-                formatted = formatter.format(value)
-                formatter.setPattern(oldpattern)
-                return u'%s %s'%(formatted, tz.zone)
-
-        value = formatter.format(value)
-        formatter.setPattern(oldpattern)
-        return value
-
-
-class FancyDatetimeFormatterFactory(object):
-    component.adapts(IHTTPRequest)
-    interface.implements(IFormatterFactory)
-
-    def __init__(self, request):
-        self.request = request
-        
-    def __call__(self, *args, **kw):
-        return FancyDatetimeFormatter(self.request, *args)

Copied: z3ext.formatter/tags/1.3.0/src/z3ext/formatter/fancydatetime.py (from rev 101559, z3ext.formatter/trunk/src/z3ext/formatter/fancydatetime.py)
===================================================================
--- z3ext.formatter/tags/1.3.0/src/z3ext/formatter/fancydatetime.py	                        (rev 0)
+++ z3ext.formatter/tags/1.3.0/src/z3ext/formatter/fancydatetime.py	2009-07-05 07:55:36 UTC (rev 101561)
@@ -0,0 +1,117 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+""" ``fancyDatetime`` formatter implementation
+
+$Id$
+"""
+
+from pytz import utc, timezone
+from datetime import datetime
+from zope import interface, component
+from zope.i18n import translate
+from zope.component import getUtility
+from zope.interface.common.idatetime import ITZInfo
+from zope.publisher.interfaces.http import IHTTPRequest
+
+from interfaces import _, IFormatter, IFormatterFactory, IFormatterConfiglet
+
+
+class FancyDatetimeFormatter(object):
+    interface.implements(IFormatter)
+
+    def __init__(self, request, *args):
+        try:
+            self.tp = args[0]
+        except:
+            self.tp = 'medium'
+
+        self.request = request
+        self.formatter = request.locale.dates.getFormatter('dateTime', self.tp)
+
+    def format(self, value):
+        formatter = self.formatter
+
+        configlet = getUtility(IFormatterConfiglet)
+        tz = None
+        if configlet.principalTimezone:
+            tz = ITZInfo(self.request.principal, None)
+
+        if tz is None:
+            tz = timezone(configlet.timezone)
+
+        if value.tzinfo is None:
+            value = datetime(value.year, value.month, value.day, value.hour,
+                             value.minute, value.second, value.microsecond, utc)
+
+        value = value.astimezone(tz)
+
+        timezoneFormat = configlet.timezoneFormat
+
+        d1 = datetime.now(utc).date()
+        d2 = value.astimezone(utc).date()
+
+        delta = d1 - d2
+
+        oldpattern = formatter.getPattern()
+        if ':ss' in oldpattern:
+            formatter.setPattern(oldpattern.replace(':ss', '').strip())
+
+        if delta.days == 0:
+            pattern = formatter.getPattern()
+            pos = pattern.find('h')
+            if pos < 0:
+                pos = pattern.find('H')
+
+            formatter.setPattern(pattern[pos:])
+            value = translate(
+                u'Today at ${value}', 'z3ext.formatter',
+                mapping={'value': formatter.format(value)})
+            formatter.setPattern(oldpattern)
+            return value
+
+        if delta.days == 1:
+            pattern = formatter.getPattern()
+            pos = pattern.find('h')
+            if pos < 0:
+                pos = pattern.find('H')
+
+            formatter.setPattern(pattern[pos:])
+            value = translate(
+                u'Yesterday at ${value}', 'z3ext.formatter',
+                mapping={'value': formatter.format(value)})
+            formatter.setPattern(oldpattern)
+            return value
+
+        if timezoneFormat == 3:
+            if self.tp in ('full',):
+                formatter.setPattern(
+                    formatter.getPattern().replace('z', '').strip())
+                formatted = formatter.format(value)
+                formatter.setPattern(oldpattern)
+                return u'%s %s'%(formatted, tz.zone)
+
+        value = formatter.format(value)
+        formatter.setPattern(oldpattern)
+        return value
+
+
+class FancyDatetimeFormatterFactory(object):
+    component.adapts(IHTTPRequest)
+    interface.implements(IFormatterFactory)
+
+    def __init__(self, request):
+        self.request = request
+        
+    def __call__(self, *args, **kw):
+        return FancyDatetimeFormatter(self.request, *args)

Deleted: z3ext.formatter/tags/1.3.0/src/z3ext/formatter/humandatetime.py
===================================================================
--- z3ext.formatter/trunk/src/z3ext/formatter/humandatetime.py	2009-07-05 02:47:34 UTC (rev 101558)
+++ z3ext.formatter/tags/1.3.0/src/z3ext/formatter/humandatetime.py	2009-07-05 07:55:36 UTC (rev 101561)
@@ -1,97 +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.
-#
-##############################################################################
-""" ``humanDatetime`` formatter implementation
-
-$Id$
-"""
-from pytz import utc, timezone
-from datetime import datetime
-from zope import interface, component
-from zope.component import getUtility
-from zope.interface.common.idatetime import ITZInfo
-from zope.publisher.interfaces.http import IHTTPRequest
-
-from z3ext.formatter.interfaces import _, \
-    IFormatter, IFormatterFactory, IFormatterConfiglet
-
-
-class HumanDatetimeFormatter(object):
-    interface.implements(IFormatter)
-
-    def __init__(self, request, *args):
-        self.request = request
-
-    def format(self, value):
-        configlet = getUtility(IFormatterConfiglet)
-        tz = None
-        if configlet.principalTimezone:
-            tz = ITZInfo(self.request.principal, None)
-
-        if tz is None:
-            tz = timezone(configlet.timezone)
-
-        if value.tzinfo is None:
-            value = datetime(value.year, value.month, value.day, value.hour,
-                             value.minute, value.second, value.microsecond, utc)
-
-        value = value.astimezone(tz)
-
-        timezoneFormat = configlet.timezoneFormat
-
-        d1 = datetime.now(utc)
-        d2 = value.astimezone(utc)
-
-        delta = d1 - d2
-
-        years, months, weeks, hours, minutes = (
-            delta.days/365, delta.days/30, delta.days/7,
-            delta.seconds/3600, delta.seconds/60)
-
-        if years > 0:
-            return _(u'${value} year(s) ago',
-                     mapping={'value': years})
-
-        if months > 0:
-            return _(u'${value} month(s) ago',
-                     mapping={'value': months})
-
-        if weeks > 0:
-            return _(u'${value} week(s) ago',
-                     mapping={'value': weeks})
-
-        if delta.days > 0:
-            return _(u'${value} day(s) ago',
-                     mapping={'value': delta.days})
-
-        if hours > 0:
-            return _(u'${value} hour(s) ago',
-                     mapping={'value': hours})
-
-        if minutes > 0:
-            return _(u'${value} minute(s) ago',
-                     mapping={'value': minutes})
-
-        return _(u'${value} second(s) ago',
-                 mapping={'value': delta.seconds})
-
-
-class HumanDatetimeFormatterFactory(object):
-    component.adapts(IHTTPRequest)
-    interface.implements(IFormatterFactory)
-
-    def __init__(self, request):
-        self.request = request
-
-    def __call__(self, *args, **kw):
-        return HumanDatetimeFormatter(self.request, *args)

Copied: z3ext.formatter/tags/1.3.0/src/z3ext/formatter/humandatetime.py (from rev 101559, z3ext.formatter/trunk/src/z3ext/formatter/humandatetime.py)
===================================================================
--- z3ext.formatter/tags/1.3.0/src/z3ext/formatter/humandatetime.py	                        (rev 0)
+++ z3ext.formatter/tags/1.3.0/src/z3ext/formatter/humandatetime.py	2009-07-05 07:55:36 UTC (rev 101561)
@@ -0,0 +1,99 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+""" ``humanDatetime`` formatter implementation
+
+$Id$
+"""
+from pytz import utc, timezone
+from datetime import datetime
+from zope import interface, component
+from zope.i18n import translate
+from zope.component import getUtility
+from zope.interface.common.idatetime import ITZInfo
+from zope.publisher.interfaces.http import IHTTPRequest
+
+from z3ext.formatter.interfaces import _, \
+    IFormatter, IFormatterFactory, IFormatterConfiglet
+
+
+class HumanDatetimeFormatter(object):
+    interface.implements(IFormatter)
+
+    def __init__(self, request, *args):
+        self.request = request
+
+    def format(self, value):
+        configlet = getUtility(IFormatterConfiglet)
+        tz = None
+        if configlet.principalTimezone:
+            tz = ITZInfo(self.request.principal, None)
+
+        if tz is None:
+            tz = timezone(configlet.timezone)
+
+        if value.tzinfo is None:
+            value = datetime(value.year, value.month, value.day, value.hour,
+                             value.minute, value.second, value.microsecond, utc)
+
+        value = value.astimezone(tz)
+
+        timezoneFormat = configlet.timezoneFormat
+
+        d1 = datetime.now(utc)
+        d2 = value.astimezone(utc)
+
+        delta = d1 - d2
+
+        years, months, weeks, hours, minutes = (
+            delta.days/365, delta.days/30, delta.days/7,
+            delta.seconds/3600, delta.seconds/60)
+
+        if years > 0:
+            return translate(
+                u'${value} year(s) ago', 'z3ext.formatter',
+                mapping={'value': years})
+
+        if months > 0:
+            return translate(u'${value} month(s) ago', 'z3ext.formatter',
+                             mapping={'value': months})
+
+        if weeks > 0:
+            return translate(u'${value} week(s) ago', 'z3ext.formatter',
+                             mapping={'value': weeks})
+
+        if delta.days > 0:
+            return translate(u'${value} day(s) ago', 'z3ext.formatter',
+                             mapping={'value': delta.days})
+
+        if hours > 0:
+            return translate(u'${value} hour(s) ago', 'z3ext.formatter',
+                             mapping={'value': hours})
+
+        if minutes > 0:
+            return translate(u'${value} minute(s) ago', 'z3ext.formatter',
+                             mapping={'value': minutes})
+
+        return translate(u'${value} second(s) ago', 'z3ext.formatter',
+                         mapping={'value': delta.seconds})
+
+
+class HumanDatetimeFormatterFactory(object):
+    component.adapts(IHTTPRequest)
+    interface.implements(IFormatterFactory)
+
+    def __init__(self, request):
+        self.request = request
+
+    def __call__(self, *args, **kw):
+        return HumanDatetimeFormatter(self.request, *args)



More information about the Checkins mailing list