[Zope-Checkins] SVN: Zope/trunk/lib/python/ZPublisher/ Fix for #2288: do not quote + and @ characters when forming BaseRequest and HTTPRequest URL variables
Log message for revision 72971: Fix for #2288: do not quote + and @ characters when forming BaseRequest and HTTPRequest URL variables Changed: U Zope/trunk/lib/python/ZPublisher/BaseRequest.py U Zope/trunk/lib/python/ZPublisher/HTTPRequest.py U Zope/trunk/lib/python/ZPublisher/tests/testBaseRequest.py -=- Modified: Zope/trunk/lib/python/ZPublisher/BaseRequest.py === --- Zope/trunk/lib/python/ZPublisher/BaseRequest.py 2007-03-04 16:15:18 UTC (rev 72970) +++ Zope/trunk/lib/python/ZPublisher/BaseRequest.py 2007-03-04 16:25:31 UTC (rev 72971) @@ -14,7 +14,7 @@ $Id$ -from urllib import quote +from urllib import quote as urllib_quote import xmlrpc from zExceptions import Forbidden, Unauthorized, NotFound from Acquisition import aq_base @@ -35,6 +35,10 @@ UNSPECIFIED_ROLES='' +def quote(text): +# quote url path segments, but leave + and @ intact +return urllib_quote(text, '/+@') + try: from ExtensionClass import Base class RequestContainer(Base): Modified: Zope/trunk/lib/python/ZPublisher/HTTPRequest.py === --- Zope/trunk/lib/python/ZPublisher/HTTPRequest.py 2007-03-04 16:15:18 UTC (rev 72970) +++ Zope/trunk/lib/python/ZPublisher/HTTPRequest.py 2007-03-04 16:25:31 UTC (rev 72971) @@ -15,10 +15,10 @@ import re, sys, os, time, random, codecs, inspect from types import StringType, UnicodeType -from BaseRequest import BaseRequest +from BaseRequest import BaseRequest, quote from HTTPResponse import HTTPResponse from cgi import FieldStorage, escape -from urllib import quote, unquote, splittype, splitport +from urllib import unquote, splittype, splitport from copy import deepcopy from Converters import get_converter from TaintedString import TaintedString Modified: Zope/trunk/lib/python/ZPublisher/tests/testBaseRequest.py === --- Zope/trunk/lib/python/ZPublisher/tests/testBaseRequest.py 2007-03-04 16:15:18 UTC (rev 72970) +++ Zope/trunk/lib/python/ZPublisher/tests/testBaseRequest.py 2007-03-04 16:25:31 UTC (rev 72971) @@ -385,7 +385,17 @@ # using default view self.setDefaultViewName('methonly') self.assertRaises(NotFound, r.traverse, 'folder2/obj2') + +def test_quoting(self): +View markers should not be quoted +r = self.makeBaseRequest() +r.traverse('folder/obj/@@meth') +self.assertEqual(r['URL'], '/folder/obj/@@meth') +r = self.makeBaseRequest() +r.traverse('folder/obj/++view++meth') +self.assertEqual(r['URL'], '/folder/obj/++view++meth') + def test_suite(): return TestSuite( ( makeSuite(TestBaseRequest), makeSuite(TestBaseRequestZope3Views), ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.10/ Merge fix for #2288: do not quote + and @ characters when forming BaseRequest and HTTPRequest URL variables
Log message for revision 72972: Merge fix for #2288: do not quote + and @ characters when forming BaseRequest and HTTPRequest URL variables Changed: U Zope/branches/2.10/doc/CHANGES.txt U Zope/branches/2.10/lib/python/ZPublisher/BaseRequest.py U Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py U Zope/branches/2.10/lib/python/ZPublisher/tests/testBaseRequest.py -=- Modified: Zope/branches/2.10/doc/CHANGES.txt === --- Zope/branches/2.10/doc/CHANGES.txt 2007-03-04 16:25:31 UTC (rev 72971) +++ Zope/branches/2.10/doc/CHANGES.txt 2007-03-04 16:33:00 UTC (rev 72972) @@ -8,6 +8,9 @@ Bugs fixed + - Collector #2288: @ and + should not be quoted when forming +request URLs in BaseRequest and HTTPRequest + - Undeprecated 'zLOG', which will remain a backward-compatibility shim for the Python logging module. Modified: Zope/branches/2.10/lib/python/ZPublisher/BaseRequest.py === --- Zope/branches/2.10/lib/python/ZPublisher/BaseRequest.py 2007-03-04 16:25:31 UTC (rev 72971) +++ Zope/branches/2.10/lib/python/ZPublisher/BaseRequest.py 2007-03-04 16:33:00 UTC (rev 72972) @@ -14,7 +14,7 @@ $Id$ -from urllib import quote +from urllib import quote as urllib_quote import xmlrpc from zExceptions import Forbidden, Unauthorized, NotFound from Acquisition import aq_base @@ -35,6 +35,10 @@ UNSPECIFIED_ROLES='' +def quote(text): +# quote url path segments, but leave + and @ intact +return urllib_quote(text, '/+@') + try: from ExtensionClass import Base class RequestContainer(Base): Modified: Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py === --- Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py 2007-03-04 16:25:31 UTC (rev 72971) +++ Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py 2007-03-04 16:33:00 UTC (rev 72972) @@ -15,10 +15,10 @@ import re, sys, os, time, random, codecs, inspect from types import StringType, UnicodeType -from BaseRequest import BaseRequest +from BaseRequest import BaseRequest, quote from HTTPResponse import HTTPResponse from cgi import FieldStorage, escape -from urllib import quote, unquote, splittype, splitport +from urllib import unquote, splittype, splitport from copy import deepcopy from Converters import get_converter from TaintedString import TaintedString Modified: Zope/branches/2.10/lib/python/ZPublisher/tests/testBaseRequest.py === --- Zope/branches/2.10/lib/python/ZPublisher/tests/testBaseRequest.py 2007-03-04 16:25:31 UTC (rev 72971) +++ Zope/branches/2.10/lib/python/ZPublisher/tests/testBaseRequest.py 2007-03-04 16:33:00 UTC (rev 72972) @@ -385,7 +385,17 @@ # using default view self.setDefaultViewName('methonly') self.assertRaises(NotFound, r.traverse, 'folder2/obj2') + +def test_quoting(self): +View markers should not be quoted +r = self.makeBaseRequest() +r.traverse('folder/obj/@@meth') +self.assertEqual(r['URL'], '/folder/obj/@@meth') +r = self.makeBaseRequest() +r.traverse('folder/obj/++view++meth') +self.assertEqual(r['URL'], '/folder/obj/++view++meth') + def test_suite(): return TestSuite( ( makeSuite(TestBaseRequest), makeSuite(TestBaseRequestZope3Views), ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/ Backport fix for 2288, together with part of the 2.10 tests for z3 views
Log message for revision 72974: Backport fix for 2288, together with part of the 2.10 tests for z3 views Changed: U Zope/branches/2.9/doc/CHANGES.txt U Zope/branches/2.9/lib/python/ZPublisher/BaseRequest.py U Zope/branches/2.9/lib/python/ZPublisher/HTTPRequest.py U Zope/branches/2.9/lib/python/ZPublisher/tests/testBaseRequest.py -=- Modified: Zope/branches/2.9/doc/CHANGES.txt === --- Zope/branches/2.9/doc/CHANGES.txt 2007-03-04 18:59:23 UTC (rev 72973) +++ Zope/branches/2.9/doc/CHANGES.txt 2007-03-04 20:50:42 UTC (rev 72974) @@ -8,6 +8,9 @@ Bugs fixed + - Collector #2288: @ and + should not be quoted when forming +request URLs in BaseRequest and HTTPRequest + - Undeprectated 'zLOG' package, which is going to remain a backward-compatibility shim for the Python logger. Modified: Zope/branches/2.9/lib/python/ZPublisher/BaseRequest.py === --- Zope/branches/2.9/lib/python/ZPublisher/BaseRequest.py 2007-03-04 18:59:23 UTC (rev 72973) +++ Zope/branches/2.9/lib/python/ZPublisher/BaseRequest.py 2007-03-04 20:50:42 UTC (rev 72974) @@ -14,7 +14,7 @@ $Id$ -from urllib import quote +from urllib import quote as urllib_quote import xmlrpc from zExceptions import Forbidden @@ -23,6 +23,10 @@ UNSPECIFIED_ROLES='' +def quote(text): +# quote url path segments, but leave + and @ intact +return urllib_quote(text, '/+@') + try: from ExtensionClass import Base class RequestContainer(Base): Modified: Zope/branches/2.9/lib/python/ZPublisher/HTTPRequest.py === --- Zope/branches/2.9/lib/python/ZPublisher/HTTPRequest.py 2007-03-04 18:59:23 UTC (rev 72973) +++ Zope/branches/2.9/lib/python/ZPublisher/HTTPRequest.py 2007-03-04 20:50:42 UTC (rev 72974) @@ -15,10 +15,10 @@ import re, sys, os, time, random, codecs from types import StringType, UnicodeType -from BaseRequest import BaseRequest +from BaseRequest import BaseRequest, quote from HTTPResponse import HTTPResponse from cgi import FieldStorage, escape -from urllib import quote, unquote, splittype, splitport +from urllib import unquote, splittype, splitport from copy import deepcopy from Converters import get_converter from TaintedString import TaintedString Modified: Zope/branches/2.9/lib/python/ZPublisher/tests/testBaseRequest.py === --- Zope/branches/2.9/lib/python/ZPublisher/tests/testBaseRequest.py 2007-03-04 18:59:23 UTC (rev 72973) +++ Zope/branches/2.9/lib/python/ZPublisher/tests/testBaseRequest.py 2007-03-04 20:50:42 UTC (rev 72974) @@ -248,6 +248,76 @@ self.assertRaises(NotFound, r.traverse, 'folder/simpleFrozenSet') +import zope.interface +import zope.component +import zope.testing.cleanup +import zope.app.traversing.namespace +from zope.publisher.browser import IBrowserRequest +from zope.publisher.browser import IDefaultBrowserLayer +from zope.app.traversing.interfaces import ITraversable + + +class IDummy(zope.interface.Interface): +IDummy + +class DummyObjectZ3(DummyObjectBasic): +zope.interface.implements(IDummy) +def __init__(self, name): +self.name = name + +class DummyView(Implicit): +def __init__(self, content, request): +self.content = content +self.request = request +def __call__(self): +return 'view on %s' % (self.content.name) + +class TestBaseRequestZope3Views(TestCase): + +def setUp(self): +zope.testing.cleanup.cleanUp() +self.root = DummyObjectBasic() +folder = self.root._setObject('folder', DummyObjectZ3('folder')) +folder._setObject('obj', DummyObjectZ3('obj')) +gsm = zope.component.getGlobalSiteManager() + +# The request needs to implement the proper interface +zope.interface.classImplements(BaseRequest, IDefaultBrowserLayer) + +# Define our 'meth' view +gsm.registerAdapter(DummyView, (IDummy, IDefaultBrowserLayer), None, +'meth') + +# Bind the 'view' namespace (for @@ traversal) +gsm.registerAdapter(zope.traversing.namespace.view, +(IDummy, IDefaultBrowserLayer), ITraversable, +'view') + +def tearDown(self): +zope.testing.cleanup.cleanUp() + +def makeBaseRequest(self): +response = HTTPResponse() +environment = { +'URL': '', +'PARENTS': [self.root], +'steps': [], +'_hacked_path': 0, +'_test_counter': 0, +'response': response, +} +return BaseRequest(environment) + +def test_quoting(self): +View markers should not be quoted +r = self.makeBaseRequest() +
[Zope-dev] Zope Tests: 7 OK
Summary of messages to the zope-tests list. Period Sat Mar 3 12:00:00 2007 UTC to Sun Mar 4 12:00:00 2007 UTC. There were 7 messages: 7 from Zope Unit Tests. Tests passed OK --- Subject: OK : Zope-2.6 Python-2.1.3 : Linux From: Zope Unit Tests Date: Sat Mar 3 21:03:46 EST 2007 URL: http://mail.zope.org/pipermail/zope-tests/2007-March/007377.html Subject: OK : Zope-2.6 Python-2.3.6 : Linux From: Zope Unit Tests Date: Sat Mar 3 21:05:16 EST 2007 URL: http://mail.zope.org/pipermail/zope-tests/2007-March/007378.html Subject: OK : Zope-2.7 Python-2.3.6 : Linux From: Zope Unit Tests Date: Sat Mar 3 21:06:46 EST 2007 URL: http://mail.zope.org/pipermail/zope-tests/2007-March/007379.html Subject: OK : Zope-2.8 Python-2.3.6 : Linux From: Zope Unit Tests Date: Sat Mar 3 21:08:16 EST 2007 URL: http://mail.zope.org/pipermail/zope-tests/2007-March/007380.html Subject: OK : Zope-2.9 Python-2.4.4 : Linux From: Zope Unit Tests Date: Sat Mar 3 21:09:46 EST 2007 URL: http://mail.zope.org/pipermail/zope-tests/2007-March/007381.html Subject: OK : Zope-2.10 Python-2.4.4 : Linux From: Zope Unit Tests Date: Sat Mar 3 21:11:16 EST 2007 URL: http://mail.zope.org/pipermail/zope-tests/2007-March/007382.html Subject: OK : Zope-trunk Python-2.4.4 : Linux From: Zope Unit Tests Date: Sat Mar 3 21:12:47 EST 2007 URL: http://mail.zope.org/pipermail/zope-tests/2007-March/007383.html ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] TypesTool speedup
I'm forwarding a message from limi here, since it makes much more sense here than it does on plone-developers. To summarize it: while analying performance of the Plone 3 codebase they noticed a lot of time was spent trying to figure out which types could be added at a location. Part of that logic uses the TypesTool _queryFactoryMethod function, which goes through the dispatcher to get to the factory method for a type, which is apparently very slow in Zope 2.10, and much faster in Zope 2.9. They came up with http://paste.plone.org/13211 which is an imho somewhat evil approach which introduces a thread-local cache for App.FactoryDispatcher._product_packages. As described below the speedup as a result of that is huge. Since Zope startup is as far as I know the only time the result of _product_packages is change perhaps it would be useful to generate that result on speedup. Or perhaps to make _product_packages cache its output. I certainly do want any monkey patches in Plone for this since it should be fixed in either Zope or CMF. Wichert. - Forwarded message from Alexander Limi [EMAIL PROTECTED] - From: Alexander Limi [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [Plone-developers] Plone 3 - now 3x faster for logged-in users Date: Sat, 03 Mar 2007 19:37:54 -0800 Message-ID: [EMAIL PROTECTED] Hello from the optimization sprint :) Just thought I'd keep you updated on some of the stuff we've been up to here. The main news for the day is that we found a combination of slowness in Zope 2.10 and CMF using that method in a less-than-optimal way. The result was that rendering the content menu (the one that decides what types you can add where etc) was eating an amazing amount of time. Explained in my usual UI designer hand-wavy way, every time we load a page in logged in mode, it checks the list of Products to figure out what you can add. So, by caching this locally in TypesTool so it doesn't get looked up every time (the list of Products doesn't change with every request, after all), we get a significant speedup. Let's see some numbers of loading the front page of a fresh plone : Before types tool optimization (10 requests): Products/CMFPlone/skins/plone_content/document_view.pt 8.54s lib/python/plone/app/contentmenu/contentmenu.pt6.26s After types tool optimization: Products/CMFPlone/skins/plone_content/document_view.pt 2.55s lib/python/plone/app/contentmenu/contentmenu.pt0.29s That makes every logged in page over 3 times faster. I like it. :) Patch for CMFCore TypesTool included. -- Alexander Limi · http://limi.net ___ Plone-developers mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/plone-developers - End forwarded message - -- Wichert Akkerman [EMAIL PROTECTED]It is simple to make things. http://www.wiggy.net/ It is hard to make things simple. ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] TypesTool speedup
--On 4. März 2007 13:57:23 +0100 Wichert Akkerman [EMAIL PROTECTED] wrote: I'm forwarding a message from limi here, since it makes much more sense here than it does on plone-developers. To summarize it: while analying performance of the Plone 3 codebase they noticed a lot of time was spent trying to figure out which types could be added at a location. Part of that logic uses the TypesTool _queryFactoryMethod function, which goes through the dispatcher to get to the factory method for a type, which is apparently very slow in Zope 2.10, and much faster in Zope 2.9. Any idea why the code is different between 2.9 and 2.10? They came up with http://paste.plone.org/13211 which is an imho somewhat evil approach which introduces a thread-local cache for App.FactoryDispatcher._product_packages. As described below the speedup as a result of that is huge. I would not be opposed against such a speedup patch as long as it does not raise other problems. However I don't know App.* enough to be evaluate the patch. Andreas pgp4nEbEdRjxB.pgp Description: PGP signature ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] TypesTool speedup
Previously Andreas Jung wrote: --On 4. März 2007 13:57:23 +0100 Wichert Akkerman [EMAIL PROTECTED] wrote: I'm forwarding a message from limi here, since it makes much more sense here than it does on plone-developers. To summarize it: while analying performance of the Plone 3 codebase they noticed a lot of time was spent trying to figure out which types could be added at a location. Part of that logic uses the TypesTool _queryFactoryMethod function, which goes through the dispatcher to get to the factory method for a type, which is apparently very slow in Zope 2.10, and much faster in Zope 2.9. Any idea why the code is different between 2.9 and 2.10? Rocky modified it in changeset 67869 to be able to support external methods outside of products. The problem with the new code is that it imports all products to figure out some of their details. So for every factory dispatcher access we now have an import for each product, which means lots of filesystem accesses and python interpreter work being done. They came up with http://paste.plone.org/13211 which is an imho somewhat evil approach which introduces a thread-local cache for App.FactoryDispatcher._product_packages. As described below the speedup as a result of that is huge. I would not be opposed against such a speedup patch as long as it does not raise other problems. However I don't know App.* enough to be evaluate the patch. http://paste.plone.org/13217 should do the trick. It makes _product_packages cache its result using the list of products in Control_Panel as a cache key. That makes sure that removing or adding products there will not result in stale data being returned by the dispatcher. Wichert. -- Wichert Akkerman [EMAIL PROTECTED]It is simple to make things. http://www.wiggy.net/ It is hard to make things simple. ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] TypesTool speedup
Previously Wichert Akkerman wrote: http://paste.plone.org/13217 should do the trick. It makes _product_packages cache its result using the list of products in Control_Panel as a cache key. That makes sure that removing or adding products there will not result in stale data being returned by the dispatcher. Obvious and stupid mistake in that patch, http://paste.plone.org/13218 should be better. Wichert. -- Wichert Akkerman [EMAIL PROTECTED]It is simple to make things. http://www.wiggy.net/ It is hard to make things simple. ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] TypesTool speedup
Mutable default values are evil. I would get rid of that. -- Sidnei da Silva Enfold Systemshttp://enfoldsystems.com Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214 ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] TypesTool speedup
Previously Sidnei da Silva wrote: Mutable default values are evil. I would get rid of that. I modeled that on how get_module_info worked, so at least the pattern is not new in the Zope2 codebase. It could just as easily be done in a global value as well. I'm more interested in seeing if people agree with the basic approach though. Wichert. -- Wichert Akkerman [EMAIL PROTECTED]It is simple to make things. http://www.wiggy.net/ It is hard to make things simple. ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] TypesTool speedup
Looking at the changes rocky made, I don't see why allowing external methods from non-Products should require making the whole process completely dynamic on every call. The old mechanism of storing the product list should be put back in place, along with the addition of non-Product information to these results. Alec ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: TypesTool speedup
On Mar 4, 1:49 pm, Alec Mitchell [EMAIL PROTECTED] wrote: Looking at the changes rocky made, I don't see why allowing external methods from non-Products should require making the whole process completely dynamic on every call. The old mechanism of storing the product list should be put back in place, along with the addition of non-Product information to these results. Following this message are two patches I'm ready to apply. One for Five and one for Zope2. The lookup is still dynamic, but at least it doesn't open a zodb connection everytime anymore. It more closely resembles what was trying to be done originally, and that is to look up factory info from the Products.* package. I'm prepared to commit this but posting it here for review first. Plus ... what is the policy for updating the Five svn:external for Zope ? (ie right now it points at Five 1.5.2 tag) Regards, Rocky Five Patch: Index: fiveconfigure.py === --- fiveconfigure.py(revision 72973) +++ fiveconfigure.py(working copy) @@ -218,6 +218,11 @@ if init_func is not None: newContext = ProductContext(product, app, module_) init_func(newContext) + +registered_packages = getattr(Products, '_registered_packages', None) +if registered_packages is None: +registered_packages = Products._registered_packages = [] +registered_packages.append(module_) finally: try: import transaction Index: tests/test_registerpackage.py === --- tests/test_registerpackage.py (revision 72973) +++ tests/test_registerpackage.py (working copy) @@ -65,7 +65,11 @@ 'pythonproduct2' in product_listing True +Make sure it also shows up in ``Products._registered_packages``. + [x.__name__ for x in getattr(Products, '_registered_packages', [])] + ['pythonproduct2'] + Clean up: tearDown() Index: CHANGES.txt === --- CHANGES.txt (revision 72973) +++ CHANGES.txt (working copy) @@ -2,6 +2,14 @@ Five Changes +Five 1.5.x (svn/unreleased) +=== + +* Added change to registerPackage directive so that it stores the newly + registered packages on the Products package object for faster reference. + This means code that looks this up (ie Zope2's FactoryDispatcher) no longer + has to open a zodb connection each time. + Five 1.5.2 (2007-01-10) === Zope2 Patch: Index: lib/python/App/FactoryDispatcher.py === --- lib/python/App/FactoryDispatcher.py (revision 72972) +++ lib/python/App/FactoryDispatcher.py (working copy) @@ -26,32 +26,15 @@ zope2 packages and those without the Products namespace package. -old_product_packages = {} +packages = {} for x in dir(Products): m = getattr(Products, x) if isinstance(m, types.ModuleType): -old_product_packages[x] = m +packages[x] = m + +for m in getattr(Products, '_registered_packages', []): +packages[m.__name__] = m -packages = {} -app = Zope2.app() -try: -products = app.Control_Panel.Products - -for product_id in products.objectIds(): -product = products[product_id] -if hasattr(product, 'package_name'): -pos = product.package_name.rfind('.') -if pos -1: -packages[product_id] = __import__(product.package_name, - globals(), {}, - product.package_name[pos+1:]) -else: -packages[product_id] = __import__(product.package_name) -elif old_product_packages.has_key(product_id): -packages[product_id] = old_product_packages[product_id] -finally: -app._p_jar.close() - return packages class ProductDispatcher(Acquisition.Implicit): ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope] datetime format
I have 'datetime-format international' set in zope.conf but the date output is still rendered in the format (y,m,d) when using ZopeTime or when returning dates from python scripts. How can I change this behaviour? My server config is: Zope Version (Zope 2.9.0, python 2.4.2, win32) Python Version 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] System Platform win32 Regards Garry ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] datetime format
--On 4. März 2007 12:45:20 + Garry Saddington [EMAIL PROTECTED] wrote: I have 'datetime-format international' set in zope.conf but the date output is still rendered in the format (y,m,d) Reading helps.. # Directive: datetime-format # # Description: # Set this variable either to us or international to force the # DateTime module to parse date strings either with # month-before-days-before-year (us) or # days-before-month-before-year (international). The default # behaviour of DateTime (when this setting is left unset) is to # parse dates as US dates. # The documentation only speaks for parsing... -aj pgpUQNymH6f37.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Resizing Images In Page Templates
Hi; I saw somewhere someone adding code like this: img src=myimage.jpg/resize / that would automatically resize his image according to a predetermined standard. Does anyone know how this or something similar is done? TIA, Tony AOL now offers free email to everyone. Find out more about what's free from AOL at AOL.com. ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Resizing Images In Page Templates
--On 4. März 2007 09:10:13 -0500 [EMAIL PROTECTED] wrote: Hi; I saw somewhere someone adding code like this: img src=myimage.jpg/resize / that would automatically resize his image according to a predetermined standard. Does anyone know how this or something similar is done? TIA, This is nonsense. This code will generate an image with a fixed URL without any additional functionality - neither on the server nor on the client side. -aj pgpopbg58NVSi.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Resizing Images In Page Templates
Hmm. I have it working on the server from which I am moving to another server. I didn't build the code. But it sure does work just fine. Sorry. Not nonsense. Anyone else have any ideas? TIA, Tony -Original Message- From: [EMAIL PROTECTED] To: [EMAIL PROTECTED]; zope@zope.org Sent: Sun, 4 Mar 2007 10:16 AM Subject: Re: [Zope] Resizing Images In Page Templates --On 4. März 2007 09:10:13 -0500 [EMAIL PROTECTED] wrote: Hi; I saw somewhere someone adding code like this: img src=myimage.jpg/resize / that would automatically resize his image according to a predetermined standard. Does anyone know how this or something similar is done? TIA, This is nonsense. This code will generate an image with a fixed URL without any additional functionality - neither on the server nor on the client side. -aj AOL now offers free email to everyone. Find out more about what's free from AOL at AOL.com. ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] datetime format
On Sunday 04 March 2007 13:32, Andreas Jung wrote: --On 4. März 2007 12:45:20 + Garry Saddington [EMAIL PROTECTED] wrote: I have 'datetime-format international' set in zope.conf but the date output is still rendered in the format (y,m,d) Reading helps.. Yes, indeed it does, how did you suppose I knew how to set the format in the first place. I presume that I will have to explicitly format the date output then, or is there a way for Zope to automatically do this? Garry ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] datetime format
--On 4. März 2007 15:57:44 + Garry Saddington [EMAIL PROTECTED] wrote: On Sunday 04 March 2007 13:32, Andreas Jung wrote: --On 4. März 2007 12:45:20 + Garry Saddington [EMAIL PROTECTED] wrote: I have 'datetime-format international' set in zope.conf but the date output is still rendered in the format (y,m,d) Reading helps.. Yes, indeed it does, how did you suppose I knew how to set the format in the first place. DateTime has a documentation and there is strftime() method to provide support for custom format. The *string* representation of a DateTIme instance as returned through the __str__() is unlikely a good choice for application level usage. -aj pgp897ZryeQHe.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Resizing Images In Page Templates
(Sun, Mar 04, 2007 at 09:20:06AM -0500) [EMAIL PROTECTED] wrote/schrieb/egrapse: Hmm. I have it working on the server from which I am moving to another server. I didn't build the code. But it sure does work just fine. Sorry. Not nonsense. Anyone else have any ideas? There is a photo resizing product that IIRC works like that. It lets you specify sizes and even some simple image manipulations in the image path. It's a bit older and I think it worked with PIL. It's in the products list on zope.org. You might want to look through those products. Regards, Sascha ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Resizing Images In Page Templates
Hmm. I have it working on the server from which I am moving to another server. I didn't build the code. But it sure does work just fine. Sorry. Not nonsense. Anyone else have any ideas? Ehm... but this code is a nonsense or rather, you made a mistake when you've written previous e-mail img src=myimage.jpg/resize / It is plain html. something like: img tal:attributes=src myimage.jpg/resize / may do something 'dynamic'. -- Maciej Wisniowski ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Re: ImportError: cannot import name base_hasattr
Take a look at pathes in your traceback: /usr/local/www/zope/278/lib/python /usr/local/zope/278/lib/python /usr/local/zope/instance1/Products Why there are two different(!) lib/python/ folders? I see the problem! And I know what caused it. So I rebuilt Zope from source and tried again. Unfortunately, I got the same_darn_error, just without the www dir: In general it still seems to me that you have two ...Products/CMFPlone/utils.py in your system. Try to search your filesystem for utils.py. Have you tried debugging via zopectl like I suggested in previous email? -- Maciej Wisniowski ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Resizing Images In Page Templates
Hmm. I have it working on the server from which I am moving to another server. I didn't build the code. But it sure does work just fine. Sorry. Not nonsense. Anyone else have any ideas? Ehm... but this code is a nonsense or rather, you made a mistake when you've written previous e-mail img src=myimage.jpg/resize / OK, I thinked again about this. This may work :) You may have object with id 'myimage.jpg' with resize method, and it may be referenced this 'hardcoced' way. -- Maciej Wisniowski ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Resizing Images In Page Templates
ImageTag_Hotfix. Got it! Thanks! Tony -Original Message- From: [EMAIL PROTECTED] To: zope@zope.org Sent: Sun, 4 Mar 2007 4:41 PM Subject: Re: [Zope] Resizing Images In Page Templates (Sun, Mar 04, 2007 at 09:20:06AM -0500) [EMAIL PROTECTED] wrote/schrieb/egrapse: Hmm. I have it working on the server from which I am moving to another server. I didn't build the code. But it sure does work just fine. Sorry. Not nonsense. Anyone else have any ideas? There is a photo resizing product that IIRC works like that. It lets you specify sizes and even some simple image manipulations in the image path. It's a bit older and I think it worked with PIL. It's in the products list on zope.org. You might want to look through those products. Regards, Sascha ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) AOL now offers free email to everyone. Find out more about what's free from AOL at AOL.com. ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] datetime format
Garry Saddington schrieb: I have 'datetime-format international' set in zope.conf but the date output is still rendered in the format (y,m,d) when using ZopeTime or when returning dates from python scripts. How can I change this behaviour? My server config is: Well what you see is not the date but one representation of the DateTime object. You can use the strftime() method to render your date object to string in any form you want. This should also answer your question on postgres list. Your database adaptor turns database types into zope types. Regards Tino ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Re: ImportError: cannot import name base_hasattr
[EMAIL PROTECTED] wrote: Hi: This really should go to the Plone list, but seeing as how I can't hit their site from either of my browsers, how can I subscribe to the list? I couldn't download Plone, either, so I just built it from tarballs from an earlier installation, tarballing all the products associated with it (Plone 2.1.4, I think). Then I loaded them up in Zope 2.7.8 and got this error: Traceback (most recent call last): File /usr/local/www/zope/278/lib/python/OFS/Application.py, line 673, in import_product File /usr/local/zope/instance1/Products/ATContentTypes/__init__.py, line 54, in ? import Products.ATContentTypes.content File /usr/local/zope/instance1/Products/ATContentTypes/content/__init__.py, line 34, in ? import Products.ATContentTypes.content.topic File /usr/local/zope/instance1/Products/ATContentTypes/content/topic.py, line 33, in ? from Products.CMFPlone.CatalogTool import CatalogTool File /usr/local/zope/instance1/Products/CMFPlone/CatalogTool.py, line 27, in ? from Products.CMFPlone.utils import base_hasattr ImportError: cannot import name base_hasattr Traceback (most recent call last): File /usr/local/zope/278/lib/python/Zope/Startup/run.py, line 50, in ? run() File /usr/local/zope/278/lib/python/Zope/Startup/run.py, line 19, in run start_zope(opts.configroot) File /usr/local/zope/278/lib/python/Zope/Startup/__init__.py, line 52, in start_zope starter.startZope() File /usr/local/zope/278/lib/python/Zope/Startup/__init__.py, line 231, in startZope Zope.startup() File /usr/local/zope/278/lib/python/Zope/Startup/__init__.py, line 47, in startup # drop privileges after setting up servers File /usr/local/www/zope/278/lib/python/Zope/App/startup.py, line 45, in startup File /usr/local/www/zope/278/lib/python/OFS/Application.py, line 650, in import_products File /usr/local/www/zope/278/lib/python/OFS/Application.py, line 673, in import_product File /usr/local/zope/instance1/Products/ATContentTypes/__init__.py, line 54, in ? import Products.ATContentTypes.content File /usr/local/zope/instance1/Products/ATContentTypes/content/__init__.py, line 34, in ? import Products.ATContentTypes.content.topic File /usr/local/zope/instance1/Products/ATContentTypes/content/topic.py, line 33, in ? from Products.CMFPlone.CatalogTool import CatalogTool File /usr/local/zope/instance1/Products/CMFPlone/CatalogTool.py, line 27, in ? from Products.CMFPlone.utils import base_hasattr ImportError: cannot import name base_hasattr I am getting the same problem with Zope 2.8.8 installed with the Windows Installer and Plone 2.1.4 for all platforms. I removed all the pyc files and the problem persists. This is on Win 2K. Suresh ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Re: Resizing Images In Page Templates
Maciej Wisniowski [EMAIL PROTECTED] writes: img src=myimage.jpg/resize / OK, I thinked again about this. This may work :) You may have object with id 'myimage.jpg' with resize method, and it may be referenced this 'hardcoced' way. Or there exists another object named 'resize' which can be acquired this way. That's how I have done this sometimes (e.g. resize is a python script which expects to be called with an image or file object as it's context) stefan. ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] datetime format
--On 5. März 2007 07:12:23 +0100 Tino Wildenhain [EMAIL PROTECTED] wrote: Garry Saddington schrieb: I have 'datetime-format international' set in zope.conf but the date output is still rendered in the format (y,m,d) when using ZopeTime or when returning dates from python scripts. How can I change this behaviour? My server config is: Well what you see is not the date but one representation of the DateTime object. You can use the strftime() method to render your date object to string in any form you want. This should also answer your question on postgres list. Your database adaptor turns database types into zope types. In addition: SQL also provides support converting a date type of the database into a string. See TO_DATE(...). -aj pgpjFyPtlAG35.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )