Skip to content

Commit

Permalink
Only use plone.uuid if object is IUUIDAware (otherwise, fall …
Browse files Browse the repository at this point in the history
…back to ``UID()`` method.

svn path=/archetypes.schemaextender/trunk/; revision=13673
  • Loading branch information
malthe committed Jun 8, 2011
1 parent b478f25 commit fd12161
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.txt
Expand Up @@ -4,11 +4,15 @@ Changelog
2.1.1 - Unreleased 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 * Acquire request object via local site hook if object is not
acquisition-wrapped (in ``cachingInstanceSchemaFactory``). This acquisition-wrapped (in ``cachingInstanceSchemaFactory``). This
fixes caching issues with objects rendered using DTML. Note that fixes caching issues with objects rendered using DTML. Note that
this is likely a bug in the ``DocumentTemplate`` code. Ideally, the this is likely a bug in the ``DocumentTemplate`` code. Ideally, the
issue should be resolved there. issue should be resolved there.
[malthe]


2.1 - 2011-01-03 2.1 - 2011-01-03
---------------- ----------------
Expand Down
9 changes: 8 additions & 1 deletion archetypes/schemaextender/extender.py
Expand Up @@ -141,7 +141,14 @@ def cachingInstanceSchemaFactory(context):
# If the object is just being created, we use its id() as a # If the object is just being created, we use its id() as a
# fallback. Generally the id() is not stable, as it changes # fallback. Generally the id() is not stable, as it changes
# with Acquisition wrappers and ZODB ghosting # 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) schema = cache.get(key, None)
if schema is None: if schema is None:
schema = cache[key] = instanceSchemaFactory(context) schema = cache[key] = instanceSchemaFactory(context)
Expand Down

0 comments on commit fd12161

Please sign in to comment.