[Checkins] SVN: z3c.filetype/trunk/src/z3c/filetype/ put event handler into api to prevent circular imports

Bernd Dorn bernd.dorn at fhv.at
Fri Aug 11 11:49:27 EDT 2006


Log message for revision 69406:
  put event handler into api to prevent circular imports

Changed:
  U   z3c.filetype/trunk/src/z3c/filetype/README.txt
  U   z3c.filetype/trunk/src/z3c/filetype/TODO.txt
  U   z3c.filetype/trunk/src/z3c/filetype/api.py
  U   z3c.filetype/trunk/src/z3c/filetype/configure.zcml
  U   z3c.filetype/trunk/src/z3c/filetype/event.py

-=-
Modified: z3c.filetype/trunk/src/z3c/filetype/README.txt
===================================================================
--- z3c.filetype/trunk/src/z3c/filetype/README.txt	2006-08-11 15:38:34 UTC (rev 69405)
+++ z3c.filetype/trunk/src/z3c/filetype/README.txt	2006-08-11 15:49:27 UTC (rev 69406)
@@ -79,6 +79,9 @@
   [<InterfaceClass z3c.filetype.interfaces.filetypes.ITARFile>]
 
 
+Applying filetype interfaces to objects
+=======================================
+
 There is also a convinience function which applies filetype interfaces
 to an object. This object needs to implement ITypeableFile. This also
 fires events, so let us setup the event handling.
@@ -94,7 +97,7 @@
   ...         self.data = f
   >>> foo = Foo(f)
 
-The applInterfaces method returns a boolean if changes occured.
+The applyInterfaces method returns a boolean if changes occured.
 
   >>> api.applyInterfaces(foo)
   True
@@ -130,9 +133,8 @@
 There is also an event handler registered on IObjectModified for
 ITypeableFile. We register it here in the test.
 
-  >>> from z3c.filetype.event import handleModified
   >>> from zope import component
-  >>> component.provideHandler(handleModified)
+  >>> component.provideHandler(api.handleModified)
   >>> foo.data = file(os.path.join(testData,'test.html'))
 
 So we need to fire an IObjectModifiedevent. Which is normally done by

Modified: z3c.filetype/trunk/src/z3c/filetype/TODO.txt
===================================================================
--- z3c.filetype/trunk/src/z3c/filetype/TODO.txt	2006-08-11 15:38:34 UTC (rev 69405)
+++ z3c.filetype/trunk/src/z3c/filetype/TODO.txt	2006-08-11 15:49:27 UTC (rev 69406)
@@ -2,8 +2,9 @@
 TODOs
 =====
 
-Add more filetypes
+Add more filetypes, espacially test xls and msword
 
 Adapters from IFileType to IImage, IFile
 
 Freeze api and write interface
+

Modified: z3c.filetype/trunk/src/z3c/filetype/api.py
===================================================================
--- z3c.filetype/trunk/src/z3c/filetype/api.py	2006-08-11 15:38:34 UTC (rev 69405)
+++ z3c.filetype/trunk/src/z3c/filetype/api.py	2006-08-11 15:49:27 UTC (rev 69406)
@@ -2,7 +2,8 @@
 import interfaces
 from interfaces import filetypes
 from zope.contenttype import guess_content_type
-from zope import interface
+from zope import interface, component
+from zope.lifecycleevent.interfaces import IObjectModifiedEvent
 from zope.event import notify
 from event import FileTypeModifiedEvent
 
@@ -100,3 +101,11 @@
 
         return iter(self._data)
 
+ at component.adapter(interfaces.ITypeableFile,IObjectModifiedEvent)
+def handleModified(typeableFile, event):
+    """handles modification of data"""
+    #import pdb;pdb.set_trace()
+    if interfaces.IFileTypeModifiedEvent.providedBy(event):
+        # do nothing if this is already a filetype modification event
+        return
+    applyInterfaces(typeableFile)

Modified: z3c.filetype/trunk/src/z3c/filetype/configure.zcml
===================================================================
--- z3c.filetype/trunk/src/z3c/filetype/configure.zcml	2006-08-11 15:38:34 UTC (rev 69405)
+++ z3c.filetype/trunk/src/z3c/filetype/configure.zcml	2006-08-11 15:49:27 UTC (rev 69406)
@@ -5,6 +5,6 @@
 
  <subscriber for=".interfaces.ITypeableFile
                   zope.lifecycleevent.interfaces.IObjectModifiedEvent"
-             handler=".event.handleModified"/>
+             handler=".api.handleModified"/>
  
 </configure>

Modified: z3c.filetype/trunk/src/z3c/filetype/event.py
===================================================================
--- z3c.filetype/trunk/src/z3c/filetype/event.py	2006-08-11 15:38:34 UTC (rev 69405)
+++ z3c.filetype/trunk/src/z3c/filetype/event.py	2006-08-11 15:49:27 UTC (rev 69406)
@@ -1,19 +1,9 @@
 from zope.lifecycleevent import ObjectModifiedEvent
-from zope.lifecycleevent.interfaces import IObjectModifiedEvent
-from zope import interface, component
+from zope import interface
 import interfaces
-import api
 
 class FileTypeModifiedEvent(ObjectModifiedEvent):
     interface.implements(interfaces.IFileTypeModifiedEvent)
 
 
- at component.adapter(interfaces.ITypeableFile,IObjectModifiedEvent)
-def handleModified(typeableFile, event):
-    """handles modification of data"""
-    #import pdb;pdb.set_trace()
-    if interfaces.IFileTypeModifiedEvent.providedBy(event):
-        # do nothing if this is already a filetype modification event
-        return
-    api.applyInterfaces(typeableFile)
     



More information about the Checkins mailing list