Message2589
Here's a more extensive one that's needed for things like @@file to work in Zope 2.10+:
Index: ZRoundup.py
===================================================================
--- ZRoundup.py (revision 3505)
+++ ZRoundup.py (working copy)
@@ -99,6 +99,9 @@
def keys(self):
return self.form.keys()
+import logging
+logger = logging.getLogger('zroundup')
+
class ZRoundup(Item, PropertyManager, Implicit, Persistent):
'''An instance of this class provides an interface between Zope and
roundup for one roundup instance
@@ -150,61 +153,37 @@
form = FormWrapper(self.REQUEST.form)
return instance.Client(instance, request, env, form)
- security.declareProtected('View', 'index_html')
- def index_html(self):
- '''Alias index_html to roundup's index
- '''
- # Redirect misdirected requests -- bugs 558867 , 565992
- # PATH_INFO, as defined by the CGI spec, has the *real* request path
- orig_path = self.REQUEST.environ['PATH_INFO']
- if orig_path[-1] != '/' :
- url = urlparse.urlparse( self.absolute_url() )
- url = list( url ) # make mutable
- url[2] = url[2]+'/' # patch
- url = urlparse.urlunparse( url ) # reassemble
- RESPONSE = self.REQUEST.RESPONSE
- RESPONSE.setStatus( "MovedPermanently" ) # 301
- RESPONSE.setHeader( "Location" , url )
- return RESPONSE
+ def __before_publishing_traverse__(self, self2, request):
+ # have we already been called?
+ if 'roundup_path' in request.other:
+ return
+ # suck up the whole path into one variable
+ path = request['TraversalRequestNameStack']
+ # but leave vhm stuff alone
+ maybe_vhm = getattr(self,path[-1],None)
+ if maybe_vhm is not None and maybe_vhm.meta_type=='Virtual Host Monster':
+ roundup_path = path[:-2]
+ else:
+ roundup_path = path
+ roundup_path = '/'.join(reversed(roundup_path))
+ path[:-2] = []
+ request.set('roundup_path', roundup_path)
+ security.declareProtected('View', 'index_html')
+ def index_html(self):
+ "Handle calls to roundup"
client = self.roundup_opendb()
# fake the path that roundup should use
- client.split_path = ['index']
- return client.main()
-
- def __getitem__(self, item):
- '''All other URL accesses are passed throuh to roundup
- '''
- return PathElement(self, item).__of__(self)
-
-class PathElement(Item, Implicit):
- def __init__(self, zr, path):
- self.zr = zr
- self.path = path
-
- def __getitem__(self, item):
- ''' Get a subitem.
- '''
- return PathElement(self.zr, self.path + '/' + item).__of__(self)
-
- def index_html(self, REQUEST=None):
- ''' Actually call through to roundup to handle the request.
- '''
+ roundup_path = self.REQUEST.get('roundup_path')
+ if roundup_path:
+ client.path = roundup_path
+ else:
+ client.split_path = ['index']
try:
- client = self.zr.roundup_opendb()
- # fake the path that roundup should use
- client.path = self.path
- # and call roundup to do something
- client.main()
- return ''
+ return client.main()
except NotFound:
- raise 'NotFound', REQUEST.URL
- pass
- except:
- import traceback
- traceback.print_exc()
- # all other exceptions in roundup are valid
- raise
+ # maybe it should be s file acquired from Zope?
+ return self.restrictedTraverse(roundup_path).index_html(self.REQUEST,self.REQUEST.RESPONSE)
|
|
Date |
User |
Action |
Args |
2009-02-03 14:22:20 | admin | link | issue2141835 messages |
2009-02-03 14:22:20 | admin | create | |
|