# HG changeset patch # User Thierry Florac # Date 1323700370 -3600 # Node ID 088a873802df4bda3c8116c592b7edd762a2efd5 # Parent bf59a3d6e43752b1e46c45499a96b802dc3f9645# Parent 6f0fb6086bf396ea9083db6edd5d468612f85be0 Merge with 6f0fb6086bf396ea9083db6edd5d468612f85be0 diff -r 6f0fb6086bf3 -r 088a873802df .hgtags --- a/.hgtags Mon Dec 12 15:31:23 2011 +0100 +++ b/.hgtags Mon Dec 12 15:32:50 2011 +0100 @@ -4,3 +4,4 @@ 35d95d221249504767e536df4aca0c012be147ad 0.3.0 a8072195e0c6b9a9da43c1ec4239f08cdd0617cb 0.3.1 96e344fe61666bcf26f9f0529f6efd761ab11b28 0.3.2 +165f37f89e5a3f5763cc59125d47e4cd7fc38ae6 0.3.3 diff -r 6f0fb6086bf3 -r 088a873802df .pydevproject --- a/.pydevproject Mon Dec 12 15:31:23 2011 +0100 +++ b/.pydevproject Mon Dec 12 15:32:50 2011 +0100 @@ -2,10 +2,42 @@ -python 2.5 +python 2.6 -/ZTFY.utils (hg)/ztfy +/ZTFY.utils (hg) -Python 2.5 +Python 2.6 (BB) + +/var/local/eggs/zope.testing-3.10.2-py2.6.egg +/var/local/eggs/zope.tales-3.5.1-py2.6.egg +/var/local/eggs/zope.interface-3.6.1-py2.6-linux-x86_64.egg +/var/local/eggs/zope.datetime-3.4.0-py2.6.egg +/var/local/eggs/zope.i18n-3.7.4-py2.6.egg +/var/local/eggs/z3c.form-2.4.3-py2.6.egg +/var/local/eggs/zope.app.file-3.6.1-py2.6.egg +/var/local/eggs/zope.schema-3.7.1-py2.6.egg +/var/local/eggs/zope.component-3.10.0-py2.6.egg +/var/local/eggs/zope.annotation-3.5.0-py2.6.egg +/var/local/eggs/zope.catalog-3.8.1-py2.6.egg +/var/local/eggs/zope.container-3.12.0-py2.6-linux-x86_64.egg +/var/local/eggs/zope.intid-3.7.2-py2.6.egg +/var/local/eggs/zope.publisher-3.12.6-py2.6.egg +/var/local/eggs/zope.security-3.8.0-py2.6-linux-x86_64.egg +/var/local/eggs/ZODB3-3.10.2-py2.6-linux-x86_64.egg +/var/local/eggs/zc.set-0.1dev_r75642-py2.6.egg +/var/local/eggs/zope.session-3.9.3-py2.6.egg +/var/local/eggs/zope.location-3.9.0-py2.6.egg +/var/local/eggs/zope.index-3.6.1-py2.6-linux-x86_64.egg +/var/local/eggs/zopyx.txng3.core-3.5.3-py2.6.egg +/var/local/eggs/zopyx.txng3.ext-3.3.2-py2.6-linux-x86_64.egg +/var/local/eggs/hurry.query-1.1.0-py2.6.egg +/var/local/eggs/pytz-2010l-py2.6.egg +/var/local/eggs/zope.authentication-3.7.1-py2.6.egg +/var/local/eggs/zc.set-0.1dev_r75642-py2.6.egg +/var/local/eggs/zope.pluggableauth-1.2-py2.6.egg +/var/local/eggs/zc.set-0.1dev_r75642-py2.6.egg +/var/local/eggs/zope.deprecation-3.4.1-py2.6.egg +/var/local/eggs/fanstatic-0.11.3-py2.6.egg + diff -r 6f0fb6086bf3 -r 088a873802df .settings/org.eclipse.core.resources.prefs --- a/.settings/org.eclipse.core.resources.prefs Mon Dec 12 15:31:23 2011 +0100 +++ b/.settings/org.eclipse.core.resources.prefs Mon Dec 12 15:32:50 2011 +0100 @@ -1,4 +1,4 @@ -#Tue Oct 18 08:26:00 CEST 2011 +#Sun Nov 20 00:28:15 CET 2011 eclipse.preferences.version=1 encoding//build/lib/ztfy/utils/site.py=utf-8 encoding//build/lib/ztfy/utils/tal/html.py=utf-8 @@ -18,6 +18,7 @@ encoding//ztfy/utils/security.py=utf-8 encoding//ztfy/utils/session.py=utf-8 encoding//ztfy/utils/site.py=utf-8 +encoding//ztfy/utils/tal/fanstatic.py=utf-8 encoding//ztfy/utils/tal/html.py=utf-8 encoding//ztfy/utils/tal/interfaces.py=utf-8 encoding//ztfy/utils/tal/request.py=utf-8 diff -r 6f0fb6086bf3 -r 088a873802df bin/i18ncompile --- a/bin/i18ncompile Mon Dec 12 15:31:23 2011 +0100 +++ b/bin/i18ncompile Mon Dec 12 15:32:50 2011 +0100 @@ -35,6 +35,7 @@ '/var/local/eggs/z3c.form-2.4.3-py2.6.egg', '/var/local/eggs/pytz-2011g-py2.6.egg', '/var/local/eggs/hurry.query-1.1.0-py2.6.egg', + '/var/local/eggs/fanstatic-0.11.3-py2.6.egg', '/var/local/eggs/zope.traversing-3.14.0-py2.6.egg', '/var/local/eggs/zope.site-3.9.2-py2.6.egg', '/var/local/eggs/zope.processlifetime-1.0-py2.6.egg', @@ -67,6 +68,8 @@ '/var/local/eggs/zope.pagetemplate-3.5.2-py2.6.egg', '/var/local/eggs/zope.contentprovider-3.7.2-py2.6.egg', '/var/local/eggs/zc.catalog-1.5-py2.6.egg', + '/var/local/eggs/WebOb-1.2b2-py2.6.egg', + '/var/local/env/bb-2.6/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg', '/var/local/eggs/zdaemon-2.0.4-py2.6.egg', '/var/local/eggs/ZConfig-2.8.0-py2.6.egg', '/var/local/eggs/zc.lockfile-1.0.0-py2.6.egg', diff -r 6f0fb6086bf3 -r 088a873802df bin/i18nextract --- a/bin/i18nextract Mon Dec 12 15:31:23 2011 +0100 +++ b/bin/i18nextract Mon Dec 12 15:32:50 2011 +0100 @@ -35,6 +35,7 @@ '/var/local/eggs/z3c.form-2.4.3-py2.6.egg', '/var/local/eggs/pytz-2011g-py2.6.egg', '/var/local/eggs/hurry.query-1.1.0-py2.6.egg', + '/var/local/eggs/fanstatic-0.11.3-py2.6.egg', '/var/local/eggs/zope.traversing-3.14.0-py2.6.egg', '/var/local/eggs/zope.site-3.9.2-py2.6.egg', '/var/local/eggs/zope.processlifetime-1.0-py2.6.egg', @@ -67,6 +68,8 @@ '/var/local/eggs/zope.pagetemplate-3.5.2-py2.6.egg', '/var/local/eggs/zope.contentprovider-3.7.2-py2.6.egg', '/var/local/eggs/zc.catalog-1.5-py2.6.egg', + '/var/local/eggs/WebOb-1.2b2-py2.6.egg', + '/var/local/env/bb-2.6/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg', '/var/local/eggs/zdaemon-2.0.4-py2.6.egg', '/var/local/eggs/ZConfig-2.8.0-py2.6.egg', '/var/local/eggs/zc.lockfile-1.0.0-py2.6.egg', diff -r 6f0fb6086bf3 -r 088a873802df bin/i18nmergeall --- a/bin/i18nmergeall Mon Dec 12 15:31:23 2011 +0100 +++ b/bin/i18nmergeall Mon Dec 12 15:32:50 2011 +0100 @@ -35,6 +35,7 @@ '/var/local/eggs/z3c.form-2.4.3-py2.6.egg', '/var/local/eggs/pytz-2011g-py2.6.egg', '/var/local/eggs/hurry.query-1.1.0-py2.6.egg', + '/var/local/eggs/fanstatic-0.11.3-py2.6.egg', '/var/local/eggs/zope.traversing-3.14.0-py2.6.egg', '/var/local/eggs/zope.site-3.9.2-py2.6.egg', '/var/local/eggs/zope.processlifetime-1.0-py2.6.egg', @@ -67,6 +68,8 @@ '/var/local/eggs/zope.pagetemplate-3.5.2-py2.6.egg', '/var/local/eggs/zope.contentprovider-3.7.2-py2.6.egg', '/var/local/eggs/zc.catalog-1.5-py2.6.egg', + '/var/local/eggs/WebOb-1.2b2-py2.6.egg', + '/var/local/env/bb-2.6/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg', '/var/local/eggs/zdaemon-2.0.4-py2.6.egg', '/var/local/eggs/ZConfig-2.8.0-py2.6.egg', '/var/local/eggs/zc.lockfile-1.0.0-py2.6.egg', diff -r 6f0fb6086bf3 -r 088a873802df bin/i18nstats --- a/bin/i18nstats Mon Dec 12 15:31:23 2011 +0100 +++ b/bin/i18nstats Mon Dec 12 15:32:50 2011 +0100 @@ -35,6 +35,7 @@ '/var/local/eggs/z3c.form-2.4.3-py2.6.egg', '/var/local/eggs/pytz-2011g-py2.6.egg', '/var/local/eggs/hurry.query-1.1.0-py2.6.egg', + '/var/local/eggs/fanstatic-0.11.3-py2.6.egg', '/var/local/eggs/zope.traversing-3.14.0-py2.6.egg', '/var/local/eggs/zope.site-3.9.2-py2.6.egg', '/var/local/eggs/zope.processlifetime-1.0-py2.6.egg', @@ -67,6 +68,8 @@ '/var/local/eggs/zope.pagetemplate-3.5.2-py2.6.egg', '/var/local/eggs/zope.contentprovider-3.7.2-py2.6.egg', '/var/local/eggs/zc.catalog-1.5-py2.6.egg', + '/var/local/eggs/WebOb-1.2b2-py2.6.egg', + '/var/local/env/bb-2.6/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg', '/var/local/eggs/zdaemon-2.0.4-py2.6.egg', '/var/local/eggs/ZConfig-2.8.0-py2.6.egg', '/var/local/eggs/zc.lockfile-1.0.0-py2.6.egg', diff -r 6f0fb6086bf3 -r 088a873802df bin/test --- a/bin/test Mon Dec 12 15:31:23 2011 +0100 +++ b/bin/test Mon Dec 12 15:32:50 2011 +0100 @@ -29,6 +29,7 @@ '/var/local/eggs/z3c.form-2.4.3-py2.6.egg', '/var/local/eggs/pytz-2011g-py2.6.egg', '/var/local/eggs/hurry.query-1.1.0-py2.6.egg', + '/var/local/eggs/fanstatic-0.11.3-py2.6.egg', '/var/local/eggs/zopyx.txng3.ext-3.3.2-py2.6-linux-x86_64.egg', '/var/local/eggs/zope.tal-3.5.2-py2.6.egg', '/var/local/eggs/zope.minmax-1.1.2-py2.6.egg', @@ -60,6 +61,8 @@ '/var/local/eggs/zope.pagetemplate-3.5.2-py2.6.egg', '/var/local/eggs/zope.contentprovider-3.7.2-py2.6.egg', '/var/local/eggs/zc.catalog-1.5-py2.6.egg', + '/var/local/eggs/WebOb-1.2b2-py2.6.egg', + '/var/local/env/bb-2.6/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg', '/var/local/eggs/zdaemon-2.0.4-py2.6.egg', '/var/local/eggs/ZConfig-2.8.0-py2.6.egg', '/var/local/eggs/zc.lockfile-1.0.0-py2.6.egg', diff -r 6f0fb6086bf3 -r 088a873802df setup.py --- a/setup.py Mon Dec 12 15:31:23 2011 +0100 +++ b/setup.py Mon Dec 12 15:32:50 2011 +0100 @@ -25,7 +25,7 @@ README = os.path.join(DOCS, 'README.txt') HISTORY = os.path.join(DOCS, 'HISTORY.txt') -version = '0.3.2' +version = '0.3.3' long_description = open(README).read() + '\n\n' + open(HISTORY).read() tests_require = [ @@ -60,6 +60,7 @@ install_requires=[ 'setuptools', # -*- Extra requirements: -*- + 'fanstatic', 'hurry.query', 'pytz', 'z3c.form', diff -r 6f0fb6086bf3 -r 088a873802df ztfy.utils.egg-info/PKG-INFO --- a/ztfy.utils.egg-info/PKG-INFO Mon Dec 12 15:31:23 2011 +0100 +++ b/ztfy.utils.egg-info/PKG-INFO Mon Dec 12 15:32:50 2011 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: ztfy.utils -Version: 0.3.2 +Version: 0.3.3 Summary: ZTFY utility functions and classes for Zope3 Home-page: http://trac.ztfy.org/ztfy.utils Author: Thierry Florac @@ -41,33 +41,37 @@ Changelog ========= + 0.3.3 + ----- + - Added "fanstatic:" TALES expression + 0.3.2 ----- - - Mark ztfy.utils.security functions and classes as deprecated + - Mark ztfy.utils.security functions and classes as deprecated 0.3.1 ----- - - Updated signature in ztfy.utils.catalog.index to match last hurry.query release + - Updated signature in ztfy.utils.catalog.index to match last hurry.query release 0.3 --- - - Switched to ZTK-1.1.2 - - Added "getAge" function in date module - - Added session module and TALES adapter to get/set session values - - Check None value in catalog.getObjectId(...) and catalog.getObject(...) methods + - Switched to ZTK-1.1.2 + - Added "getAge" function in date module + - Added session module and TALES adapter to get/set session values + - Check None value in catalog.getObjectId(...) and catalog.getObject(...) methods 0.2.1 ----- - - Added 'site.locateAndRegister' facility function - - Update ServerTimezoneUtility parent classes + - Added 'site.locateAndRegister' facility function + - Update ServerTimezoneUtility parent classes 0.2 --- - - Added 'data' namespace to access request data + - Added 'data' namespace to access request data 0.1 --- - - Initial release + - Initial release Keywords: ZTFY utilities for Zope3 Platform: UNKNOWN diff -r 6f0fb6086bf3 -r 088a873802df ztfy.utils.egg-info/SOURCES.txt --- a/ztfy.utils.egg-info/SOURCES.txt Mon Dec 12 15:31:23 2011 +0100 +++ b/ztfy.utils.egg-info/SOURCES.txt Mon Dec 12 15:32:50 2011 +0100 @@ -54,6 +54,7 @@ ztfy/utils/protocol/xmlrpc.py ztfy/utils/tal/__init__.py ztfy/utils/tal/configure.zcml +ztfy/utils/tal/fanstatic.py ztfy/utils/tal/html.py ztfy/utils/tal/interfaces.py ztfy/utils/tal/request.py diff -r 6f0fb6086bf3 -r 088a873802df ztfy.utils.egg-info/requires.txt --- a/ztfy.utils.egg-info/requires.txt Mon Dec 12 15:31:23 2011 +0100 +++ b/ztfy.utils.egg-info/requires.txt Mon Dec 12 15:32:50 2011 +0100 @@ -1,4 +1,5 @@ setuptools +fanstatic hurry.query pytz z3c.form diff -r 6f0fb6086bf3 -r 088a873802df ztfy/utils/catalog/__init__.py --- a/ztfy/utils/catalog/__init__.py Mon Dec 12 15:31:23 2011 +0100 +++ b/ztfy/utils/catalog/__init__.py Mon Dec 12 15:32:50 2011 +0100 @@ -42,11 +42,11 @@ def getIntIdUtility(name='', request=None, context=None): """Look for a named IIntIds utility""" if request is None: - request = request_utils.getRequest() + request = request_utils.queryRequest() intids = request_utils.getRequestData('IntIdsUtility::' + name, request) if intids is None: intids = queryUtility(IIntIds, name, context=context) - if intids is not None: + if (request is not None) and (intids is not None): request_utils.setRequestData('IntIdsUtility::' + name, intids, request) return intids @@ -56,7 +56,7 @@ if object is None: return None if request is None: - request = request_utils.getRequest() + request = request_utils.queryRequest() intids = getIntIdUtility(intids_name, request, context) if intids is not None: return intids.queryId(object) diff -r 6f0fb6086bf3 -r 088a873802df ztfy/utils/docs/HISTORY.txt --- a/ztfy/utils/docs/HISTORY.txt Mon Dec 12 15:31:23 2011 +0100 +++ b/ztfy/utils/docs/HISTORY.txt Mon Dec 12 15:32:50 2011 +0100 @@ -1,30 +1,34 @@ Changelog ========= +0.3.3 +----- + - Added "fanstatic:" TALES expression + 0.3.2 ----- -- Mark ztfy.utils.security functions and classes as deprecated + - Mark ztfy.utils.security functions and classes as deprecated 0.3.1 ----- -- Updated signature in ztfy.utils.catalog.index to match last hurry.query release + - Updated signature in ztfy.utils.catalog.index to match last hurry.query release 0.3 --- -- Switched to ZTK-1.1.2 -- Added "getAge" function in date module -- Added session module and TALES adapter to get/set session values -- Check None value in catalog.getObjectId(...) and catalog.getObject(...) methods + - Switched to ZTK-1.1.2 + - Added "getAge" function in date module + - Added session module and TALES adapter to get/set session values + - Check None value in catalog.getObjectId(...) and catalog.getObject(...) methods 0.2.1 ----- -- Added 'site.locateAndRegister' facility function -- Update ServerTimezoneUtility parent classes + - Added 'site.locateAndRegister' facility function + - Update ServerTimezoneUtility parent classes 0.2 --- -- Added 'data' namespace to access request data + - Added 'data' namespace to access request data 0.1 --- -- Initial release + - Initial release diff -r 6f0fb6086bf3 -r 088a873802df ztfy/utils/request.py --- a/ztfy/utils/request.py Mon Dec 12 15:31:23 2011 +0100 +++ b/ztfy/utils/request.py Mon Dec 12 15:32:50 2011 +0100 @@ -28,6 +28,7 @@ # import local packages from ztfy.utils import _ +from zope.security.interfaces import NoInteraction def getRequest(): @@ -39,6 +40,13 @@ raise RuntimeError, _("No Request in interaction !") +def queryRequest(): + try: + return getRequest() + except NoInteraction: + return None + + def getRequestPrincipal(request=None): """Get principal from given request""" if request is None: diff -r 6f0fb6086bf3 -r 088a873802df ztfy/utils/tal/configure.zcml --- a/ztfy/utils/tal/configure.zcml Mon Dec 12 15:31:23 2011 +0100 +++ b/ztfy/utils/tal/configure.zcml Mon Dec 12 15:32:50 2011 +0100 @@ -1,5 +1,6 @@ + + \ No newline at end of file diff -r 6f0fb6086bf3 -r 088a873802df ztfy/utils/tal/fanstatic.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ztfy/utils/tal/fanstatic.py Mon Dec 12 15:32:50 2011 +0100 @@ -0,0 +1,38 @@ +### -*- coding: utf-8 -*- #################################################### +############################################################################## +# +# Copyright (c) 2008-2011 Thierry Florac +# 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. +# +############################################################################## + +__docformat__ = "restructuredtext" + +# import standard packages + +# import Zope3 interfaces + +# import local interfaces + +# import Zope3 packages +from zope.tales.expressions import StringExpr + +# import local packages +from ztfy.utils.traversing import resolve + + +class FanstaticTalesExpression(StringExpr): + + def __call__(self, econtext): + lib, res = self._expr.split('#') + module = resolve(lib) + resource = getattr(module, res) + resource.need() + return '' diff -r 6f0fb6086bf3 -r 088a873802df ztfy/utils/traversing.py --- a/ztfy/utils/traversing.py Mon Dec 12 15:31:23 2011 +0100 +++ b/ztfy/utils/traversing.py Mon Dec 12 15:32:50 2011 +0100 @@ -37,3 +37,29 @@ return interface(parent) parent = getattr(parent, '__parent__', None) return None + + +# copied from fanstatic (which copied it from zope.dottedname !) +def resolve(name, module=None): + name = name.split('.') + if not name[0]: + if module is None: + raise ValueError("relative name without base module") + module = module.split('.') + name.pop(0) + while not name[0]: + module.pop() + name.pop(0) + name = module + name + + used = name.pop(0) + found = __import__(used) + for n in name: + used += '.' + n + try: + found = getattr(found, n) + except AttributeError: + __import__(used) + found = getattr(found, n) + + return found