-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 08/01/2011 02:25 AM, Nikolay Kim wrote: > Log message for revision 122433: micro optimization > > Changed: U Zope/branches/2.13/src/OFS/ObjectManager.py U > Zope/branches/2.13/src/OFS/Traversable.py U > Zope/branches/2.13/src/Products/PageTemplates/Expressions.py U > Zope/branches/2.13/src/ZPublisher/HTTPRequest.py > > -=- Modified: Zope/branches/2.13/src/OFS/ObjectManager.py > =================================================================== > --- Zope/branches/2.13/src/OFS/ObjectManager.py 2011-07-30 11:49:07 > UTC (rev 122432) +++ Zope/branches/2.13/src/OFS/ObjectManager.py > 2011-08-01 06:25:44 UTC (rev 122433) @@ -425,7 +425,7 @@ # Returns a > list of actual subobjects of the current object. # If 'spec' is > specified, returns only objects whose meta_type # match 'spec'. - > return [ self._getOb(id) for id in self.objectIds(spec) ] + > return [ getattr(self, id) for id in self.objectIds(spec) ] > > security.declareProtected(access_contents_information, > 'objectItems') def objectItems(self, spec=None):
You cannot replace '_getOb' with 'getattr': subclasses (e.g., BTreeFolder) don't necessarily use attributes to store items. Even if all the subclasses in the Zope tree also override the affected methods, you cannot know that third-party code won't break here. > @@ -763,7 +763,7 @@ return self.manage_delObjects(ids=[name]) > > def __getitem__(self, key): - v=self._getOb(key, None) + > v=getattr(self, key, None) if v is not None: return v if > hasattr(self, 'REQUEST'): request=self.REQUEST Same here. > Modified: > Zope/branches/2.13/src/Products/PageTemplates/Expressions.py > =================================================================== > --- Zope/branches/2.13/src/Products/PageTemplates/Expressions.py > 2011-07-30 11:49:07 UTC (rev 122432) +++ > Zope/branches/2.13/src/Products/PageTemplates/Expressions.py > 2011-08-01 06:25:44 UTC (rev 122433) @@ -71,7 +71,7 @@ while > path_items: name = path_items.pop() if > OFS.interfaces.ITraversable.providedBy(object): - object = > object.restrictedTraverse(name) + object = > object.unrestrictedTraverse(name, restricted=True) else: object = > traversePathElement(object, name, path_items, request=request) This change defeats a security check: I don't believe it is suitable for a stable release (one might argue for such a change on the trunk, but it is *not* an "optimization"). > Modified: Zope/branches/2.13/src/ZPublisher/HTTPRequest.py > =================================================================== > --- Zope/branches/2.13/src/ZPublisher/HTTPRequest.py 2011-07-30 > 11:49:07 UTC (rev 122432) +++ > Zope/branches/2.13/src/ZPublisher/HTTPRequest.py 2011-08-01 06:25:44 > UTC (rev 122433) @@ -169,6 +169,9 @@ > > retry_max_count = 3 > > + def __conform__(self, iface): + return > iface.__adapt__(self) + def supports_retry(self): if self.retry_count > < self.retry_max_count: time.sleep(random.uniform(0, 2 ** > (self.retry_count))) '__conform__' is intended to allow an object to do something different than the standard adapation: it makes no sense (and cannot be faster, since it introduces another Python function call) to add a '__conform__' which returns exactly what the code in 'Interface.__call__' would do. Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tsea...@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk4231AACgkQ+gerLs4ltQ4xygCeLTa8LWRPlKuzhmxQBq4vkS5u 9RkAn3K7LXdDQ1Z5/HNIzjp9tK9a8NhB =1X2t -----END PGP SIGNATURE----- _______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )