[Checkins] SVN: z3ext.formatter/trunk/ update tests

Nikolay Kim fafhrd91 at gmail.com
Tue Dec 22 18:44:09 EST 2009


Log message for revision 106968:
  update tests

Changed:
  U   z3ext.formatter/trunk/CHANGES.txt
  U   z3ext.formatter/trunk/buildout.cfg
  U   z3ext.formatter/trunk/setup.py
  U   z3ext.formatter/trunk/src/z3ext/formatter/README.txt
  D   z3ext.formatter/trunk/src/z3ext/formatter/config.py
  U   z3ext.formatter/trunk/src/z3ext/formatter/configure.zcml
  U   z3ext.formatter/trunk/src/z3ext/formatter/fancydatetime.py

-=-
Modified: z3ext.formatter/trunk/CHANGES.txt
===================================================================
--- z3ext.formatter/trunk/CHANGES.txt	2009-12-22 23:44:08 UTC (rev 106967)
+++ z3ext.formatter/trunk/CHANGES.txt	2009-12-22 23:44:08 UTC (rev 106968)
@@ -2,6 +2,12 @@
 CHANGES
 =======
 
+1.5.0 (Unreleased)
+------------------
+
+- ZTK support
+
+
 1.4.2 (2009-11-09)
 ------------------
 

Modified: z3ext.formatter/trunk/buildout.cfg
===================================================================
--- z3ext.formatter/trunk/buildout.cfg	2009-12-22 23:44:08 UTC (rev 106967)
+++ z3ext.formatter/trunk/buildout.cfg	2009-12-22 23:44:08 UTC (rev 106968)
@@ -27,20 +27,8 @@
   <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" />
+    <include package="z3ext.autoinclude" file="meta.zcml" />
+    <includeAllDependencies package="z3ext.formatter" extras="test" />
   </configure>
 
 [i18nall]

Modified: z3ext.formatter/trunk/setup.py
===================================================================
--- z3ext.formatter/trunk/setup.py	2009-12-22 23:44:08 UTC (rev 106967)
+++ z3ext.formatter/trunk/setup.py	2009-12-22 23:44:08 UTC (rev 106968)
@@ -47,13 +47,12 @@
         'Framework :: Zope3'],
       author='Nikolay Kim',
       author_email='fafhrd91 at gmail.com',
-      url='http://z3ext.net/',
+      url='http://pypi.python.org/pypi/z3ext.formatter/',
       license='ZPL 2.1',
       package_dir = {'':'src'},
       packages=find_packages('src'),
       namespace_packages=['z3ext'],
-      install_requires = ['setuptools',
-                          'pytz',
+      install_requires = ['setuptools', 'pytz',
                           'zope.component',
                           'zope.interface',
                           'zope.publisher',
@@ -62,14 +61,15 @@
                           'zope.tales',
                           'zope.i18n',
                           'zope.i18nmessageid',
-                          'zope.app.appsetup',
-                          'zope.app.pagetemplate',
-                          'zope.app.publisher',
                           'z3c.pt',
+                          'z3ext.controlpanel',
+                          'z3ext.resourcepackage',
                           'z3ext.jquery.i18n',
                           ],
       extras_require = dict(test=['zope.app.testing',
                                   'zope.testing',
+                                  'zope.app.pagetemplate',
+                                  'z3ext.autoinclude',
                                   'z3ext.controlpanel [test]',
                                   ]),
       include_package_data = True,

Modified: z3ext.formatter/trunk/src/z3ext/formatter/README.txt
===================================================================
--- z3ext.formatter/trunk/src/z3ext/formatter/README.txt	2009-12-22 23:44:08 UTC (rev 106967)
+++ z3ext.formatter/trunk/src/z3ext/formatter/README.txt	2009-12-22 23:44:08 UTC (rev 106968)
@@ -5,15 +5,6 @@
 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
-</product-config>
-
-Values for timezoneFormat are:
-    1: No timezone
-
 We need register controlpanel configlet
 
   >>> from zope.configuration import xmlconfig
@@ -28,30 +19,14 @@
   ...     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)
+   >>> configlet.timezone = u'UTC'
+   >>> configlet.timezoneFormat = 2
 
 Setup request
 
@@ -191,6 +166,19 @@
    </html>
 
 
+Unknow value
+
+   >>> print fpage.render(request, now=u'Unknwon string')
+   <html>
+     <body>
+       Unknwon string
+       Unknwon string
+       Unknwon string
+       Unknwon string
+     </body>
+   </html>
+
+
 Date formatter
 --------------
 
@@ -215,7 +203,15 @@
      </body>
    </html>
 
+   >>> print datepage.render(request, today=u'Unknown string')
+   <html>
+     <body>
+       Unknown string
+       Unknown string
+     </body>
+   </html>
 
+
 Also you can get formatter from python code
 
    >>> from z3ext.formatter.utils import getFormatter
@@ -275,7 +271,15 @@
      </body>
    </html>
 
+   >>> print datepage.render(request, time=u'Unknown string')
+   <html>
+     <body>
+       Unknown string
+       Unknown string
+     </body>
+   </html>
 
+
 Custom formatter
 ================
 
@@ -530,4 +534,5 @@
         <span class="z3ext-formatter-humandatetime" value="...">in 1 year(s)</span>
         <span class="z3ext-formatter-humandatetime" value="...">in 1 year(s)</span>
       </body>
-    </html>
\ No newline at end of file
+    </html>
+

Deleted: z3ext.formatter/trunk/src/z3ext/formatter/config.py
===================================================================
--- z3ext.formatter/trunk/src/z3ext/formatter/config.py	2009-12-22 23:44:08 UTC (rev 106967)
+++ z3ext.formatter/trunk/src/z3ext/formatter/config.py	2009-12-22 23:44:08 UTC (rev 106968)
@@ -1,42 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-""" default IFormatterConfiglet utility
-
-$Id$
-"""
-
-from zope import interface, component
-from zope.component import getGlobalSiteManager
-from zope.app.appsetup.product import getProductConfiguration
-from zope.app.appsetup.interfaces import IDatabaseOpenedEvent
-
-import vocabulary
-from interfaces import IFormatterConfiglet
-
-
- at component.adapter(IDatabaseOpenedEvent)
-def initFormatter(event):
-    config = getProductConfiguration('z3ext.formatter')
-    if config is None:
-        config = {}
-
-    sm = getGlobalSiteManager()
-
-    try:
-        timezone = vocabulary.timezones.getTermByToken(
-            config.get('timezone', u'US/Pacific')).value
-    except LookupError:
-        timezone = u'US/Pacific'
-
-    IFormatterConfiglet['timezone'].default = timezone

Modified: z3ext.formatter/trunk/src/z3ext/formatter/configure.zcml
===================================================================
--- z3ext.formatter/trunk/src/z3ext/formatter/configure.zcml	2009-12-22 23:44:08 UTC (rev 106967)
+++ z3ext.formatter/trunk/src/z3ext/formatter/configure.zcml	2009-12-22 23:44:08 UTC (rev 106968)
@@ -6,9 +6,6 @@
    xmlns:browser="http://namespaces.zope.org/browser"
    i18n_domain="z3ext.formatter">
 
-  <!-- zope.conf configuration -->
-  <subscriber handler=".config.initFormatter" />
-
   <!-- formatter: chameleon expression -->
   <utility
      name="formatter"
@@ -41,50 +38,34 @@
      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">
+  <z3ext:configlet
+     name="system.formatter"
+     schema=".interfaces.IFormatterConfiglet"
+     title="Portal formatters"
+     description="Configure portal formatters.">
+    <allow interface=".interfaces.IFormatterConfiglet" />
+  </z3ext:configlet>
 
-    <include package="z3ext.controlpanel" file="meta.zcml" />
-    <include package="z3ext.controlpanel" />
+  <browser:icon
+     name="zmi_icon"
+     for=".interfaces.IFormatterConfiglet"
+     file="preferences-formatter.png" />
 
-    <z3ext:configlet
-       name="system.formatter"
-       schema=".interfaces.IFormatterConfiglet"
-       title="Portal formatters"
-       description="Configure portal formatters.">
-      <allow interface=".interfaces.IFormatterConfiglet" />
-    </z3ext:configlet>
+  <!-- ecmascripts -->
+  <z3ext:resourceinclude
+     name="humandatetime.js"
+     type="javascript"
+     library="z3ext"
+     require="jquery-plugins"
+     file="resources/humandatetime.js" />
 
-    <browser:icon
-       name="zmi_icon"
-       for=".interfaces.IFormatterConfiglet"
-       file="preferences-formatter.png" />
-  </configure>
+  <z3ext:resourceinclude
+     name="fancydatetime.js"
+     type="javascript"
+     library="z3ext"
+     require="jquery-plugins"
+     file="resources/fancydatetime.js" />
 
-  <configure
-     xmlns:zcml="http://namespaces.zope.org/zcml"
-     xmlns:browser="http://namespaces.zope.org/browser"
-     zcml:condition="installed z3ext.resourcepackage">
-
-    <!-- ecmascripts -->
-    <z3ext:resourceinclude
-       name="humandatetime.js"
-       type="javascript"
-       library="z3ext"
-       require="jquery-plugins"
-       file="resources/humandatetime.js" />
-
-    <z3ext:resourceinclude
-       name="fancydatetime.js"
-       type="javascript"
-       library="z3ext"
-       require="jquery-plugins"
-       file="resources/fancydatetime.js" />
-
-  </configure>
-
   <!-- Registering documentation with API doc -->
   <configure
      xmlns:apidoc="http://namespaces.zope.org/apidoc"

Modified: z3ext.formatter/trunk/src/z3ext/formatter/fancydatetime.py
===================================================================
--- z3ext.formatter/trunk/src/z3ext/formatter/fancydatetime.py	2009-12-22 23:44:08 UTC (rev 106967)
+++ z3ext.formatter/trunk/src/z3ext/formatter/fancydatetime.py	2009-12-22 23:44:08 UTC (rev 106968)
@@ -54,7 +54,7 @@
 
         fdate = unicode(value.strftime(str(getattr(configlet,'date_'+self.tp))))
         ftime = unicode(value.strftime(str(getattr(configlet,'time_'+self.tp))))
- 
+
         return u'<span class="z3ext-formatter-fancydatetime" date="%s" time="%s">%s</span>' \
             % (fdate, ftime, value.strftime('%B %d, %Y %H:%M:%S %z'))
 



More information about the checkins mailing list