[Zope3-checkins] SVN: Zope3/branches/zipimport-support/src/zope/filereference/ when creating a reference from a reference object, just return the original

Fred L. Drake, Jr. fdrake at gmail.com
Thu Nov 10 14:54:38 EST 2005


Log message for revision 40037:
  when creating a reference from a reference object, just return the original

Changed:
  U   Zope3/branches/zipimport-support/src/zope/filereference/README.txt
  U   Zope3/branches/zipimport-support/src/zope/filereference/reference.py

-=-
Modified: Zope3/branches/zipimport-support/src/zope/filereference/README.txt
===================================================================
--- Zope3/branches/zipimport-support/src/zope/filereference/README.txt	2005-11-10 19:41:31 UTC (rev 40036)
+++ Zope3/branches/zipimport-support/src/zope/filereference/README.txt	2005-11-10 19:54:38 UTC (rev 40037)
@@ -34,6 +34,13 @@
 
   >>> ref = zope.filereference.new("README.txt", package=zope.filereference)
 
+When a file reference is passed to `new()`, it is returned instead of
+generating a new reference::
+
+  >>> ref2 = zope.filereference.new(ref)
+  >>> ref2 is ref
+  True
+
 If we examine the reference as a string, we get a path that points
 into the package::
 

Modified: Zope3/branches/zipimport-support/src/zope/filereference/reference.py
===================================================================
--- Zope3/branches/zipimport-support/src/zope/filereference/reference.py	2005-11-10 19:41:31 UTC (rev 40036)
+++ Zope3/branches/zipimport-support/src/zope/filereference/reference.py	2005-11-10 19:54:38 UTC (rev 40037)
@@ -71,6 +71,9 @@
 
 def new(path, package=None, basepath=None):
 
+    if IFileReference.providedBy(path):
+        return path
+
     if os.path.isabs(path):
         return PathReference(os.path.normpath(path))
 



More information about the Zope3-Checkins mailing list