• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 22. Object-to-Filesystem Mapping... > Step 4: Putting the Icing on the Cak...

Step 4: Putting the Icing on the Cake: A Special Directory Factory

While you were playing around with the new filesystem support, you might have tried to create a directory to see what happened, and it probably just caused a system error because no adapter was found from IMessage/IMessageBoard to IDirectoryFactory. Because such behavior is undesirable, you should create a custom adapter that provides IDirectoryFactory. The IWriteDirectory adapter of any container object will then know how to make use of this factory adapter. You should therefore add the following trivial factory to the filerepresentation module:

01 from zope.app.filerepresentation.interfaces import IDirectoryFactory
02 from message import Message
03
04 class MessageFactory(object):
05     """A simple message factory for file system representations."""
06
07     implements(IDirectoryFactory)
08
09     def __init__(self, context):
10         self.context = context
11
12     def __call__(self, name):
13         """See IDirectoryFactory interface."""
14         return Message()


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint