"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "frontends/ZRoundup/ZRoundup.py" between
roundup-1.6.1.tar.gz and roundup-2.0.0.tar.gz

About: Roundup is an highly customisable issue-tracking system with command-line, web and e-mail interfaces (written in Python).

ZRoundup.py  (roundup-1.6.1):ZRoundup.py  (roundup-2.0.0)
skipping to change at line 29 skipping to change at line 29
This frontend works by providing a thin layer that sits between Zope and the This frontend works by providing a thin layer that sits between Zope and the
regular CGI interface of roundup, providing the web frontend with the minimum regular CGI interface of roundup, providing the web frontend with the minimum
of effort. of effort.
This means that the regular CGI interface does all authentication quite This means that the regular CGI interface does all authentication quite
independently of Zope. The roundup code is kept in memory though, and it independently of Zope. The roundup code is kept in memory though, and it
runs in the same server as all your other Zope stuff, so it does have _some_ runs in the same server as all your other Zope stuff, so it does have _some_
advantages over regular CGI :) advantages over regular CGI :)
''' '''
import urlparse from roundup.anypy import urllib_
from Globals import InitializeClass, HTMLFile from Globals import InitializeClass, HTMLFile
from OFS.SimpleItem import Item from OFS.SimpleItem import Item
from OFS.PropertyManager import PropertyManager from OFS.PropertyManager import PropertyManager
from Acquisition import Explicit, Implicit from Acquisition import Explicit, Implicit
from Persistence import Persistent from Persistence import Persistent
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl import ModuleSecurityInfo from AccessControl import ModuleSecurityInfo
modulesecurity = ModuleSecurityInfo() modulesecurity = ModuleSecurityInfo()
skipping to change at line 91 skipping to change at line 91
self.value = self.value.read() self.value = self.value.read()
class FormWrapper: class FormWrapper:
'''Make a Zope form dict look like a cgi.py one '''Make a Zope form dict look like a cgi.py one
''' '''
def __init__(self, form): def __init__(self, form):
self.__form = form self.__form = form
def __getitem__(self, item): def __getitem__(self, item):
entry = self.__form[item] entry = self.__form[item]
if isinstance(entry, type([])): if isinstance(entry, type([])):
entry = map(FormItem, entry) entry = list(map(FormItem, entry))
else: else:
entry = FormItem(entry) entry = FormItem(entry)
return entry return entry
def __iter__(self): def __iter__(self):
return iter(self.__form) return iter(self.__form)
def getvalue(self, key, default=None): def getvalue(self, key, default=None):
if self.__form.has_key(key): if key in self.__form:
return self.__form[key] return self.__form[key]
else: else:
return default return default
def has_key(self, item): def has_key(self, item):
return self.__form.has_key(item) return item in self.__form
def keys(self): def keys(self):
return self.__form.keys() return list(self.__form.keys())
def __repr__(self): def __repr__(self):
return '<ZRoundup.FormWrapper %r>'%self.__form return '<ZRoundup.FormWrapper %r>'%self.__form
class ZRoundup(Item, PropertyManager, Implicit, Persistent): class ZRoundup(Item, PropertyManager, Implicit, Persistent):
'''An instance of this class provides an interface between Zope and '''An instance of this class provides an interface between Zope and
roundup for one roundup instance roundup for one roundup instance
''' '''
meta_type = 'Z Roundup' meta_type = 'Z Roundup'
security = ClassSecurityInfo() security = ClassSecurityInfo()
skipping to change at line 144 skipping to change at line 144
security.declarePrivate('roundup_opendb') security.declarePrivate('roundup_opendb')
def roundup_opendb(self): def roundup_opendb(self):
'''Open the roundup instance database for a transaction. '''Open the roundup instance database for a transaction.
''' '''
tracker = roundup.instance.open(self.instance_home) tracker = roundup.instance.open(self.instance_home)
request = RequestWrapper(self.REQUEST['RESPONSE']) request = RequestWrapper(self.REQUEST['RESPONSE'])
env = self.REQUEST.environ env = self.REQUEST.environ
# figure out the path components to set # figure out the path components to set
url = urlparse.urlparse( self.absolute_url() ) url = urllib_.urlparse( self.absolute_url() )
path = url[2] path = url[2]
path_components = path.split( '/' ) path_components = path.split( '/' )
# special case when roundup is '/' in this virtual host, # special case when roundup is '/' in this virtual host,
if path == "/" : if path == "/" :
env['SCRIPT_NAME'] = "/" env['SCRIPT_NAME'] = "/"
env['TRACKER_NAME'] = '' env['TRACKER_NAME'] = ''
else : else :
# all but the last element is the path # all but the last element is the path
env['SCRIPT_NAME'] = '/'.join( path_components[:-1] ) env['SCRIPT_NAME'] = '/'.join( path_components[:-1] )
skipping to change at line 171 skipping to change at line 171
return client.Client(tracker, request, env, form) return client.Client(tracker, request, env, form)
security.declareProtected('View', 'index_html') security.declareProtected('View', 'index_html')
def index_html(self): def index_html(self):
'''Alias index_html to roundup's index '''Alias index_html to roundup's index
''' '''
# Redirect misdirected requests -- bugs 558867 , 565992 # Redirect misdirected requests -- bugs 558867 , 565992
# PATH_INFO, as defined by the CGI spec, has the *real* request path # PATH_INFO, as defined by the CGI spec, has the *real* request path
orig_path = self.REQUEST.environ['PATH_INFO'] orig_path = self.REQUEST.environ['PATH_INFO']
if orig_path[-1] != '/' : if orig_path[-1] != '/' :
url = urlparse.urlparse( self.absolute_url() ) url = urllib_.urlparse( self.absolute_url() )
url = list( url ) # make mutable url = list( url ) # make mutable
url[2] = url[2]+'/' # patch url[2] = url[2]+'/' # patch
url = urlparse.urlunparse( url ) # reassemble url = urllib_.urlunparse( url ) # reassemble
RESPONSE = self.REQUEST.RESPONSE RESPONSE = self.REQUEST.RESPONSE
RESPONSE.setStatus( "MovedPermanently" ) # 301 RESPONSE.setStatus( "MovedPermanently" ) # 301
RESPONSE.setHeader( "Location" , url ) RESPONSE.setHeader( "Location" , url )
return RESPONSE return RESPONSE
client = self.roundup_opendb() client = self.roundup_opendb()
# fake the path that roundup should use # fake the path that roundup should use
client.split_path = ['index'] client.split_path = ['index']
return client.main() return client.main()
skipping to change at line 211 skipping to change at line 211
''' Actually call through to roundup to handle the request. ''' Actually call through to roundup to handle the request.
''' '''
try: try:
client = self.zr.roundup_opendb() client = self.zr.roundup_opendb()
# fake the path that roundup should use # fake the path that roundup should use
client.path = self.path client.path = self.path
# and call roundup to do something # and call roundup to do something
client.main() client.main()
return '' return ''
except client.NotFound: except client.NotFound:
raise 'NotFound', REQUEST.URL raise Exception('NotFound ' + REQUEST.URL)
pass pass
except: except:
import traceback import traceback
traceback.print_exc() traceback.print_exc()
# all other exceptions in roundup are valid # all other exceptions in roundup are valid
raise raise
InitializeClass(ZRoundup) InitializeClass(ZRoundup)
modulesecurity.apply(globals()) modulesecurity.apply(globals())
 End of changes. 9 change blocks. 
9 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)