[PEAK] config.fileNearModule() in peak.ini

Yaroslav Samchuk yarcat at ank-sia.com
Wed Apr 20 10:05:50 EDT 2005


Yaroslav Samchuk wrote:
> Yesterday I tried to execute application, which uses `peak.web` and is 
> distributed using py2exe. And noticed, that there were some problems 
> zip-importing `peak.web/resource_defaults.ini`.

And one more interesting thing. Trying to access any undefined resource, 
I always get an exception (traceback is attached to this mail), which is 
raised, cuz `os.listdir` can't list files in archives. Temporary, I had 
fixed peak/web/resources.py, until you'll do something there. On the off 
chance, a patch with my changes is also attached to this mail.

-- 
Best wishes,
Yaroslav
-------------- next part --------------
Traceback (most recent call last):
  File "wsgiref\handlers.pyo", line 92, in run
  File "peak\web\publish.pyo", line 233, in __call__
  File "peak\web\publish.pyo", line 258, in _handle_http
  File "peak\web\publish.pyo", line 138, in handleException
  File "peak\web\errors.pyo", line 64, in handleException
  File "C:\cygwin\home\pje\PEAK\src/peak/binding/_once.pyx", line 112, in _once.BaseDescriptor.__get__
  File "C:\cygwin\home\pje\PEAK\src/peak/binding/_once.pyx", line 100, in _once.__get__
  File "peak\binding\once.pyo", line 539, in <lambda>
  File "peak\web\errors.pyo", line 31, in template
  File "peak\web\skins.pyo", line 101, in getResource
  File "peak\web\publish.pyo", line 68, in traverse
  File "peak\web\environ.pyo", line 229, in traverseName
  File "peak\web\places.pyo", line 51, in traverseTo
  File "peak\web\environ.pyo", line 387, in traverseDefault
  File "peak\web\environ.pyo", line 348, in traverseItem
  File "peak\web\resources.pyo", line 125, in __getitem__
  File "C:\cygwin\home\pje\PEAK\src/peak/binding/_once.pyx", line 112, in _once.BaseDescriptor.__get__
  File "C:\cygwin\home\pje\PEAK\src/peak/binding/_once.pyx", line 100, in _once.__get__
  File "peak\binding\once.pyo", line 539, in <lambda>
  File "peak\web\resources.pyo", line 109, in filenames
WindowsError: [Errno 3] The system cannot find the path specified: 'E:\\TEMP\\web_test\\bin\\library.dat\\peak\\web/*.*'
-------------- next part --------------
--- resources.py.bak	2005-04-20 14:53:59.000000000 +0300
+++ resources.py	2005-04-20 17:01:03.906250000 +0300
@@ -106,7 +106,24 @@
 
     def filenames(self):    # XXX need a way to invalidate this!
         nms = {}
-        for filename in os.listdir(self.filename):
+        import errno
+        if sys.platform == "win32":
+            # os.listdir raises WindowsError on win32
+            exc = WindowsError
+            expectErrno = errno.ESRCH
+        else:
+            # and OSError on linux
+            # XXX: I don't know what happens on other platforms
+            exc = OSError
+            expectErrno = errno.ENOENT
+        try:
+            names = os.listdir(self.filename)
+        except exc, err:
+            # XXX: reraise always if we aren't zip-imported?
+            if err.errno == expectErrno:
+                return nms
+            raise
+        for filename in names:
             if filename in ('.','..'):
                 continue
             parts = filename.split('.')


More information about the PEAK mailing list