[Zope3-checkins] SVN: Zope3/trunk/ Fixed classregistry.txt in zope.app.apidoc to write to a temporary directory rather than the source tree.

Brian Sutherland jinty at web.de
Mon Mar 5 11:22:41 EST 2007


Log message for revision 72992:
  Fixed classregistry.txt in zope.app.apidoc to write to a temporary directory rather than the source tree.

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/src/zope/app/apidoc/classregistry.txt

-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2007-03-05 14:43:23 UTC (rev 72991)
+++ Zope3/trunk/doc/CHANGES.txt	2007-03-05 16:22:41 UTC (rev 72992)
@@ -365,6 +365,9 @@
       - Resolved http://www.zope.org/Collectors/Zope3-dev/655 by having
         zope.app.form use the transaction.doom() interface.
 
+      - Fixed classregistry.txt in zope.app.apidoc to write to a temporary
+        directory rather than the source tree.
+
     Much thanks to everyone who contributed to this release:
 
       Jim Fulton, Dmitry Vasiliev, Martijn Faassen, Christian Theune, Wolfgang

Modified: Zope3/trunk/src/zope/app/apidoc/classregistry.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/classregistry.txt	2007-03-05 14:43:23 UTC (rev 72991)
+++ Zope3/trunk/src/zope/app/apidoc/classregistry.txt	2007-03-05 16:22:41 UTC (rev 72992)
@@ -84,7 +84,7 @@
 `getSubclassesOf(klass)`
 ~~~~~~~~~~~~~~~~~~~~~~~~
 
-This method will find all classes that inherit the specified class: 
+This method will find all classes that inherit the specified class:
 
   >>> pprint(reg.getSubclassesOf(A))
   [('A2', <class 'A2'>)]
@@ -123,15 +123,17 @@
 For this example, we'll create a dummy module:
 
   >>> import os
-  >>> here = os.path.dirname(__file__)
-  >>> filename = os.path.join(here, 'testmodule.py')
+  >>> import tempfile
+  >>> dir = tempfile.mkdtemp()
+  >>> filename = os.path.join(dir, 'testmodule.py')
+  >>> sys.path.insert(0, dir)
   >>> f = open(filename, 'w')
   >>> f.write('# dummy module\n')
   >>> f.close()
 
 The temporary module is not already imported:
 
-  >>> module_name = 'zope.app.apidoc.testmodule'
+  >>> module_name = 'testmodule'
   >>> module_name in sys.modules
   False
 
@@ -153,28 +155,21 @@
 
 Now clean up the temporary module, just to play nice:
 
-  >>> os.unlink(filename)
-  >>> if os.path.exists(filename + 'c'):
-  ...     os.unlink(filename + 'c')
-  >>> if os.path.exists(filename + 'o'):
-  ...     os.unlink(filename + 'o')
+  >>> del sys.modules[module_name]
 
-  >>> del sys.modules['zope.app.apidoc.testmodule']
-
 Importing some code we cannot control, such as twisted, might raise errors
 when imported without having a certain environment. In those cases, the safe
 import should prevent the error from penetrating:
 
-  >>> import os, tempfile
-  >>> dir = tempfile.mkdtemp()
   >>> open(os.path.join(dir, 'alwaysfail.py'), 'w').write('raise ValueError\n')
   >>> sys.path.insert(0, dir)
 
   >>> safe_import('alwaysfail') is None
   True
 
-  >>> del sys.path[0]
+Let's clean up the python path and temporary files:
 
+  >>> del sys.path[0]
   >>> import shutil
   >>> shutil.rmtree(dir)
 



More information about the Zope3-Checkins mailing list