r13673 - in archetypes.schemaextender/trunk: . archetypes/schemaextender

"Malthe Borch" <[email protected]> Wed, 08 Jun 2011 11:24:28 +0000
Newsgroups gmane.comp.web.zope.plone.archetypes.cvs
Message-ID <[email protected]>
Author: mborch
Date: Wed Jun  8 11:24:28 2011
New Revision: 13673

Modified:
   archetypes.schemaextender/trunk/CHANGES.txt
   archetypes.schemaextender/trunk/archetypes/schemaextender/extender.py
Log:
Only use ``plone.uuid`` if object is ``IUUIDAware`` (otherwise, fall back to ``UID()`` method.

Modified: archetypes.schemaextender/trunk/CHANGES.txt
==============================================================================
--- archetypes.schemaextender/trunk/CHANGES.txt	(original)
+++ archetypes.schemaextender/trunk/CHANGES.txt	Wed Jun  8 11:24:28 2011
@@ -4,11 +4,15 @@
 2.1.1 - Unreleased
 ------------------
 
+* Only use plone.uuid to look up content UUIDs if objets are aware.
+  [malthe]
+
 * Acquire request object via local site hook if object is not
   acquisition-wrapped (in ``cachingInstanceSchemaFactory``). This
   fixes caching issues with objects rendered using DTML. Note that
   this is likely a bug in the ``DocumentTemplate`` code. Ideally, the
   issue should be resolved there.
+  [malthe]
 
 2.1 - 2011-01-03
 ----------------

Modified: archetypes.schemaextender/trunk/archetypes/schemaextender/extender.py
==============================================================================
--- archetypes.schemaextender/trunk/archetypes/schemaextender/extender.py	(original)
+++ archetypes.schemaextender/trunk/archetypes/schemaextender/extender.py	Wed Jun  8 11:24:28 2011
@@ -141,7 +141,14 @@
                 # If the object is just being created, we use its id() as a
                 # fallback. Generally the id() is not stable, as it changes
                 # with Acquisition wrappers and ZODB ghosting
-                key = IUUID(context, str(id(context)))
+                fallback = str(id(context))
+
+                # Use ``plone.uuid`` only if applicable (object is aware)
+                if IUUIDAware.providedBy(context):
+                    key = IUUID(context, fallback)
+                else:
+                    key = context.UID() or fallback
+
                 schema = cache.get(key, None)
                 if schema is None:
                     schema = cache[key] = instanceSchemaFactory(context)

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev