[Checkins] SVN: five.clids/trunk/ adapter for objects in Zope2 Items

Godefroid Chapelle gotcha at bubblenet.be
Sat Oct 11 17:35:04 EDT 2008


Log message for revision 92059:
  adapter for objects in Zope2 Items

Changed:
  U   five.clids/trunk/buildout.cfg
  A   five.clids/trunk/five/clids/configure.zcml
  A   five.clids/trunk/five/clids/zodb.py

-=-
Modified: five.clids/trunk/buildout.cfg
===================================================================
--- five.clids/trunk/buildout.cfg	2008-10-11 21:03:23 UTC (rev 92058)
+++ five.clids/trunk/buildout.cfg	2008-10-11 21:35:03 UTC (rev 92059)
@@ -45,6 +45,7 @@
 # e.g. eggs = ${buildout:eggs} ${plone:eggs} my.package
 eggs =
     ${buildout:eggs}
+    five.clids
 
 # If you want to register ZCML slugs for any packages, list them here.
 # e.g. zcml = my.package my.other.package

Added: five.clids/trunk/five/clids/configure.zcml
===================================================================
--- five.clids/trunk/five/clids/configure.zcml	                        (rev 0)
+++ five.clids/trunk/five/clids/configure.zcml	2008-10-11 21:35:03 UTC (rev 92059)
@@ -0,0 +1,10 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:grok="http://namespaces.zope.org/grok"
+    xmlns:browser="http://namespaces.zope.org/browser">
+
+    <include package="plone.clids" />
+
+    <grok:grok package=".zodb" />
+
+</configure>

Added: five.clids/trunk/five/clids/zodb.py
===================================================================
--- five.clids/trunk/five/clids/zodb.py	                        (rev 0)
+++ five.clids/trunk/five/clids/zodb.py	2008-10-11 21:35:03 UTC (rev 92059)
@@ -0,0 +1,42 @@
+from OFS.interfaces import IItem
+
+from zope.interface import implements
+
+import grokcore.component
+
+from plone.clids.interfaces import IUniqueId
+from plone.clids.interfaces import IResolver
+from plone.clids.interfaces import IResolvable
+
+from Zope2 import App
+
+
+class Resolver(object):
+    implements(IResolver)
+
+    def resolve(self, data):
+        return App().restrictedTraverse('/'.join(data))
+
+resolver = Resolver()
+
+
+class Resolvable(grokcore.component.Adapter):
+    grokcore.component.context(IItem)
+    grokcore.component.implements(IResolvable)
+
+    @property
+    def data(self):
+        return self.context.getPhysicalPath()
+
+    @property
+    def resolver(self):
+        return resolver
+
+
+class UniqueForSimpleItem(grokcore.component.Adapter):
+    grokcore.component.context(IItem)
+    grokcore.component.implements(IUniqueId)
+
+    @property
+    def id(self):
+        return '/'.join(self.context.getPhysicalPath())



More information about the Checkins mailing list