[Zope] LocalFS and 2.4.x
Michael Best
mbest@emergence.com
Fri, 09 Nov 2001 16:15:20 -0700
This is a multi-part message in MIME format.
--------------A694F97EE85BE9BDCF35DC45
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I was having no luck running LocalFS in 2.4
As a result I looked at the source code, and after some experimentation
discovered that ts_regex which comes from ts_regex in the Zope
distribution was causing this product to fail.
As regex is depricated in the Python 2.1, will a replacement to ts_regex
be written, or ts_regex modified? I was under the impression that ts_
meant Thread Safe. Perhaps re in Python 2.1 is thread safe already and
so it would be okay to use it?
I prepared a patch to make it work, but I don't know if there are any
hidden caveats and I should follow a different approach?
Here is a basic diff, with a patch as an attachment.
< import AccessControl, re
> import AccessControl, ts_regex
< bad_id=re.compile('[^a-zA-Z0-9-_~,. ]').search #TS
> bad_id=ts_regex.compile('[^a-zA-Z0-9-_~,. ]').search #TS
< if bad_id(id) != None:
> if bad_id(id) != -1:
--------------A694F97EE85BE9BDCF35DC45
Content-Type: text/plain; charset=us-ascii;
name="LocalFS-0.10.1.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="LocalFS-0.10.1.patch"
--- LocalFS.py Fri Nov 9 15:58:22 2001
+++ LocalFS.py.orig Fri Nov 9 15:57:17 2001
@@ -44,7 +44,7 @@
import sys, os, string, re, stat, urllib, glob, errno, time, tempfile
import App, Globals, Acquisition, Persistence, OFS
-import AccessControl, re
+import AccessControl, ts_regex
from App.Extensions import getObject
from webdav.NullResource import NullResource
from ZPublisher.HTTPResponse import HTTPResponse
@@ -400,7 +400,7 @@
if id == os.curdir or id == os.pardir or id[0] == '_': return 0
return 1
-bad_id=re.compile('[^a-zA-Z0-9-_~,. ]').search #TS
+bad_id=ts_regex.compile('[^a-zA-Z0-9-_~,. ]').search #TS
def absattr(attr):
if callable(attr): return attr()
@@ -556,7 +556,7 @@
# only check that the id string contains no illegal chars.
if not id:
raise 'Bad Request', 'No id was specified'
- if bad_id(id) != None:
+ if bad_id(id) != -1:
raise 'Bad Request', (
'The id %s contains characters illegal in filenames.' % id)
if id[0]=='_': raise 'Bad Request', (
--------------A694F97EE85BE9BDCF35DC45--