Issue 2141835
Created on 2008-10-02 06:16 by anonymous, last changed 2016-06-26 22:41 by rouilj.
| Messages | |||
|---|---|---|---|
| msg2588 | Author: [hidden] (anonymous) | Date: 2008-10-02 06:16 | |
It's a little one but it does the trick...
Index: __init__.py
===================================================================
--- __init__.py (revision 3505)
+++ __init__.py (working copy)
@@ -48,7 +48,7 @@
)
# set up the icon
-from ImageFile import ImageFile
+from App.ImageFile import ImageFile
misc_ = {
'icon': ImageFile('icons/tick_symbol.gif', path),
}
cheers,
Chris
|
|||
| msg2589 | Author: [hidden] (fresh) | Date: 2008-10-02 08:38 | |
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)
|
|||
| msg5639 | Author: [hidden] (rouilj) | Date: 2016-06-26 22:41 | |
I asked on the roundup user mailing list if anybody is using zope and can test this. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2016-06-26 22:41:36 | rouilj | set | keywords:
+ patch nosy: + rouilj messages: + msg5639 |
| 2008-10-02 06:16:57 | anonymous | create | |