[Zope] LocalFS and 2.4.x

Jonothan Farr jfarr@real.com
Fri, 9 Nov 2001 15:22:02 -0800


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', (
> 
>