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:
--- 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', (
I actually copied that particular bit of code from OFS.Container. How was it fixed there? That's probably how it should be fixed in LocalFS. --jfarr ----- Original Message ----- From: "Michael Best" <mbest@emergence.com> To: <zope@zope.org> Sent: Friday, November 09, 2001 3:15 PM Subject: [Zope] LocalFS and 2.4.x
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:
--------------------------------------------------------------------------------
--- 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', (
Jonothan Farr wrote:
I actually copied that particular bit of code from OFS.Container. How was it fixed there? That's probably how it should be fixed in LocalFS.
Here is an updated patch with the code from lib/python/OFS/ObjectManager.py The only real difference from the previous patch is: if bad_id(id) != None: becomes: if bad_id(id) is not None: -- Michael Best Systems Administrator ph 780-413-6397 x230 Emergence By Design fax 780-433-7548 #200, 11209 Jasper Avenue toll 866-860-2666 Edmonton, Alberta, T5K 0L5 --- LocalFS.py Fri Nov 9 16:26:37 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) is not None: + if bad_id(id) != -1: raise 'Bad Request', ( 'The id %s contains characters illegal in filenames.' % id) if id[0]=='_': raise 'Bad Request', (
ObjectManager. Right. Been a while since I mucked around inside Zope. ;) Thanks for the patch. I'll see that it gets in... --jfarr ----- Original Message ----- From: "Michael Best" <mbest@emergence.com> To: "Jonothan Farr" <jfarr@real.com> Cc: <zope@zope.org> Sent: Friday, November 09, 2001 3:36 PM Subject: Re: [Zope] LocalFS and 2.4.x
Jonothan Farr wrote:
I actually copied that particular bit of code from OFS.Container. How was it fixed there? That's probably how it should be fixed in LocalFS.
Here is an updated patch with the code from lib/python/OFS/ObjectManager.py
The only real difference from the previous patch is:
if bad_id(id) != None:
becomes:
if bad_id(id) is not None:
-- Michael Best Systems Administrator ph 780-413-6397 x230 Emergence By Design fax 780-433-7548 #200, 11209 Jasper Avenue toll 866-860-2666 Edmonton, Alberta, T5K 0L5
--------------------------------------------------------------------------------
--- LocalFS.py Fri Nov 9 16:26:37 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) is not None: + if bad_id(id) != -1: raise 'Bad Request', ( 'The id %s contains characters illegal in filenames.' % id) if id[0]=='_': raise 'Bad Request', (
participants (3)
-
Dieter Maurer -
Jonothan Farr -
Michael Best