[z3-checkins] r7221 - z3/bdbxml
philikon at codespeak.net
philikon at codespeak.net
Thu Nov 11 17:10:26 MET 2004
Author: philikon
Date: Thu Nov 11 17:10:26 2004
New Revision: 7221
Modified:
z3/bdbxml/__init__.py
z3/bdbxml/configure.zcml
Log:
get rid of the custom factory thing. this is not needed, just overcomplicates things
move some thigns around to make it clearer in which order they are needed
DBXMLFolder should in the end become a persistent class while the objects it returns via
__getitem__ should be non-persistent (sinc ethey are fetched from dbxml)
Modified: z3/bdbxml/__init__.py
==============================================================================
--- z3/bdbxml/__init__.py (original)
+++ z3/bdbxml/__init__.py Thu Nov 11 17:10:26 2004
@@ -13,6 +13,32 @@
from zope.interface import implementedBy, directlyProvides, directlyProvidedBy
from zope.component.interfaces import IFactory
+
+class IDBXMLDocument(Interface):
+ """Take an XML document from DBXML and make a component"""
+
+class IDBXMLFolder(IFolder):
+ """Marker for folders whose contained items keys are case insensitive.
+
+ When traversing in this folder, all names will be converted to lower
+ case. For example, if the traverser requests an item called 'Foo', in
+ reality the first item matching 'foo' or any upper-and-lowercase variants
+ are looked up in the container."""
+
+
+# things inside a container should be locatable (that means, provide
+# ILocation and have __name__ and __parent__ attributes). For the stub
+# content object we have here, we just derive from Contained, which is
+# an ILocation
+class DBXMLDocument(Contained):
+ __doc__ = IDBXMLDocument.__doc__
+
+ implements(IDBXMLDocument)
+
+ title="Class title"
+ body = "Class body"
+
+
class DBXMLFolder(Contained):
"""Sample container implementation suitable for testing.
@@ -32,8 +58,16 @@
The value returned is a mapping object that also has `get`,
`has_key`, `keys`, `items`, and `values` methods.
"""
+ from zope.app.location import locate
+
+ # contained objects should be located
+
first = DBXMLDocument()
+ locate(first, self, 'first')
+
second = DBXMLDocument()
+ locate(second, self, 'second')
+
return {'first': first, 'second': second}
def keys(self):
@@ -77,50 +111,3 @@
'''See interface `IWriteContainer`'''
uncontained(self.__data[key], self, key)
del self.__data[key]
-
-
-class IDBXMLFolder(IFolder):
- """Marker for folders whose contained items keys are case insensitive.
-
- When traversing in this folder, all names will be converted to lower
- case. For example, if the traverser requests an item called 'Foo', in
- reality the first item matching 'foo' or any upper-and-lowercase variants
- are looked up in the container."""
-
-
-class DBXMLFolderFactory(object):
- """A Factory that creates case-insensitive Folders."""
- implements(IFactory)
-
- title = "Case-Insensitive Folder Factory"
- description = "A Factory that creates case-insensitive Folders."
-
- def __call__(self):
- """See zope.component.interfaces.IFactory
-
- Create a folder and mark it as case insensitive.
- """
- folder = Folder()
- directlyProvides(folder, directlyProvidedBy(folder),
- IDBXMLFolder)
- return folder
-
- def getInterfaces(self):
- """See zope.component.interfaces.IFactory"""
- return implementedBy(Folder) + IDBXMLFolder
-
-DBXMLFolderFactory = DBXMLFolderFactory()
-
-
-class IDBXMLDocument(Interface):
- """Take an XML document from DBXML and make a component"""
-
-
-class DBXMLDocument:
- __doc__ = IDBXMLDocument.__doc__
-
- implements(IDBXMLDocument)
-
- title="Class title"
- body = "Class body"
-
Modified: z3/bdbxml/configure.zcml
==============================================================================
--- z3/bdbxml/configure.zcml (original)
+++ z3/bdbxml/configure.zcml Thu Nov 11 17:10:26 2004
@@ -3,29 +3,25 @@
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="zope">
-<!--
- <view
- for=".IDBXMLFolder"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- factory=".DBXMLContainerTraverser"
- provides="zope.publisher.interfaces.browser.IBrowserPublisher"
- permission="zope.Public"
- />
-<factory
- id="zope.DBXMLFolder"
- component=".caseInsensitiveFolderFactory"
- />
--->
-
<content class="dbxmlfolder.DBXMLFolder">
<implements interface="dbxmlfolder.IDBXMLFolder"/>
+
+ <!-- ignore security just for test purposes -->
+ <allow interface="zope.app.container.interfaces.IContainer" />
</content>
-<factory
- id="zope.DBXMLFolder"
- component=".DBXMLFolderFactory"
+<browser:addMenuItem
+ class=".DBXMLFolder"
+ title="DBXML Folder"
+ description="A folder whose contents from from Berkeley DB XML"
+ permission="zope.ManageContent"
/>
+<browser:icon
+ name="zmi_icon"
+ for=".IDBXMLFolder"
+ file="cifolder_icon.png"
+ />
<browser:page
name="details.html"
@@ -51,18 +47,4 @@
<implements interface="dbxmlfolder.IDBXMLDocument"/>
</content>
-<browser:addMenuItem
- factory="zope.DBXMLFolder"
- title="DBXML Folder"
- description="A folder whose contents from from Berkeley DB XML"
- permission="zope.ManageContent"
- />
-
-<browser:icon
- name="zmi_icon"
- for=".IDBXMLFolder"
- file="cifolder_icon.png"
- />
-
-
</configure>
More information about the z3-checkins
mailing list