rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
ndx = self.getview(1).append(rowdict)
|
ndx = self.getview(READWRITE).append(rowdict)
|
def create_inner(self, **propvalues): rowdict = {} rowdict['id'] = newid = self.maxid self.maxid += 1 ndx = self.getview(1).append(rowdict) propvalues['#ISNEW'] = 1 try: self.set(str(newid), **propvalues) except Exception: self.maxid -= 1 raise return str(newid)
|
return oldnode[propname]
|
raw = oldnode[propname] converter = _converters.get(rutyp.__class__, None) if converter: return converter(raw) return raw
|
def get(self, nodeid, propname, default=_marker, cache=1): ''' 'cache' exists for backwards compatibility, and is not used. '''
|
view = self.getview(1)
|
view = self.getview(READWRITE)
|
def set(self, nodeid, **propvalues): isnew = 0 if propvalues.has_key('#ISNEW'): isnew = 1 del propvalues['#ISNEW'] if not isnew: self.fireAuditors('set', nodeid, propvalues) if not propvalues: return propvalues if propvalues.has_key('id'): raise KeyError, '"id" is reserved' if self.db.journaltag is None: raise hyperdb.DatabaseError, 'Database open read-only' view = self.getview(1)
|
if key == self.keyname: iv = self.getindexview(1)
|
if key == self.key: iv = self.getindexview(READWRITE)
|
def set(self, nodeid, **propvalues): isnew = 0 if propvalues.has_key('#ISNEW'): isnew = 1 del propvalues['#ISNEW'] if not isnew: self.fireAuditors('set', nodeid, propvalues) if not propvalues: return propvalues if propvalues.has_key('id'): raise KeyError, '"id" is reserved' if self.db.journaltag is None: raise hyperdb.DatabaseError, 'Database open read-only' view = self.getview(1)
|
value = 0 try: v = int(value) except ValueError: raise TypeError, "%s (%s) is not numeric"%(key, repr(value))
|
v = 0 else: try: v = int(value) except ValueError: raise TypeError, "%s (%s) is not numeric"%(key, repr(value)) if not BACKWARDS_COMPATIBLE: if v >=0: v = v + 1
|
def set(self, nodeid, **propvalues): isnew = 0 if propvalues.has_key('#ISNEW'): isnew = 1 del propvalues['#ISNEW'] if not isnew: self.fireAuditors('set', nodeid, propvalues) if not propvalues: return propvalues if propvalues.has_key('id'): raise KeyError, '"id" is reserved' if self.db.journaltag is None: raise hyperdb.DatabaseError, 'Database open read-only' view = self.getview(1)
|
bv = value
|
bv = value if not BACKWARDS_COMPATIBLE: bv += 1
|
def set(self, nodeid, **propvalues): isnew = 0 if propvalues.has_key('#ISNEW'): isnew = 1 del propvalues['#ISNEW'] if not isnew: self.fireAuditors('set', nodeid, propvalues) if not propvalues: return propvalues if propvalues.has_key('id'): raise KeyError, '"id" is reserved' if self.db.journaltag is None: raise hyperdb.DatabaseError, 'Database open read-only' view = self.getview(1)
|
view = self.getview(1)
|
view = self.getview(READWRITE)
|
def retire(self, nodeid): if self.db.journaltag is None: raise hyperdb.DatabaseError, 'Database open read-only' self.fireAuditors('retire', nodeid, None) view = self.getview(1) ndx = view.find(id=int(nodeid)) if ndx < 0: raise KeyError, "nodeid %s not found" % nodeid
|
if self.keyname: iv = self.getindexview(1) ndx = iv.find(k=getattr(row, self.keyname),i=row.id)
|
if self.key: iv = self.getindexview(READWRITE) ndx = iv.find(k=getattr(row, self.key),i=row.id)
|
def retire(self, nodeid): if self.db.journaltag is None: raise hyperdb.DatabaseError, 'Database open read-only' self.fireAuditors('retire', nodeid, None) view = self.getview(1) ndx = view.find(id=int(nodeid)) if ndx < 0: raise KeyError, "nodeid %s not found" % nodeid
|
'''Restpre a retired node.
|
"""Restore a retired node.
|
def restore(self, nodeid): '''Restpre a retired node.
|
'''
|
"""
|
def restore(self, nodeid): '''Restpre a retired node.
|
view = self.getview(1)
|
view = self.getview(READWRITE)
|
def restore(self, nodeid): '''Restpre a retired node.
|
if self.keyname: iv = self.getindexview(1) ndx = iv.find(k=getattr(row, self.keyname),i=row.id)
|
if self.key: iv = self.getindexview(READWRITE) ndx = iv.find(k=getattr(row, self.key),i=row.id)
|
def restore(self, nodeid): '''Restpre a retired node.
|
view = self.getview(1)
|
view = self.getview(READWRITE)
|
def is_retired(self, nodeid): view = self.getview(1) # node must exist & not be retired id = int(nodeid) ndx = view.find(id=id) if ndx < 0: raise IndexError, "%s has no node %s" % (self.classname, nodeid) row = view[ndx] return row._isdel
|
if self.keyname: if propname == self.keyname:
|
if self.key: if propname == self.key:
|
def setkey(self, propname): if self.keyname: if propname == self.keyname: return raise ValueError, "%s already indexed on %s"%(self.classname, self.keyname) prop = self.properties.get(propname, None) if prop is None: prop = self.privateprops.get(propname, None) if prop is None: raise KeyError, "no property %s" % propname if not isinstance(prop, hyperdb.String): raise TypeError, "%s is not a String" % propname
|
self.keyname)
|
self.key)
|
def setkey(self, propname): if self.keyname: if propname == self.keyname: return raise ValueError, "%s already indexed on %s"%(self.classname, self.keyname) prop = self.properties.get(propname, None) if prop is None: prop = self.privateprops.get(propname, None) if prop is None: raise KeyError, "no property %s" % propname if not isinstance(prop, hyperdb.String): raise TypeError, "%s is not a String" % propname
|
self.keyname = propname
|
self.key = propname
|
def setkey(self, propname): if self.keyname: if propname == self.keyname: return raise ValueError, "%s already indexed on %s"%(self.classname, self.keyname) prop = self.properties.get(propname, None) if prop is None: prop = self.privateprops.get(propname, None) if prop is None: raise KeyError, "no property %s" % propname if not isinstance(prop, hyperdb.String): raise TypeError, "%s is not a String" % propname
|
return self.keyname
|
return self.key
|
def getkey(self): return self.keyname
|
raise TypeError, "%r is not a string" % keyvalue
|
raise TypeError, '%r is not a string'%keyvalue
|
def lookup(self, keyvalue): if type(keyvalue) is not _STRINGTYPE: raise TypeError, "%r is not a string" % keyvalue iv = self.getindexview() if iv: ndx = iv.find(k=keyvalue) if ndx > -1: return str(iv[ndx].i) else: view = self.getview() ndx = view.find({self.keyname:keyvalue, '_isdel':0}) if ndx > -1: return str(view[ndx].id) raise KeyError, keyvalue
|
return str(iv[ndx].i)
|
view = self.getview() ndx = view.find(id=iv[ndx].i) if ndx > -1: row = view[ndx] if not row._isdel: return str(row.id)
|
def lookup(self, keyvalue): if type(keyvalue) is not _STRINGTYPE: raise TypeError, "%r is not a string" % keyvalue iv = self.getindexview() if iv: ndx = iv.find(k=keyvalue) if ndx > -1: return str(iv[ndx].i) else: view = self.getview() ndx = view.find({self.keyname:keyvalue, '_isdel':0}) if ndx > -1: return str(view[ndx].id) raise KeyError, keyvalue
|
ndx = view.find({self.keyname:keyvalue, '_isdel':0})
|
ndx = view.find({self.key:keyvalue})
|
def lookup(self, keyvalue): if type(keyvalue) is not _STRINGTYPE: raise TypeError, "%r is not a string" % keyvalue iv = self.getindexview() if iv: ndx = iv.find(k=keyvalue) if ndx > -1: return str(iv[ndx].i) else: view = self.getview() ndx = view.find({self.keyname:keyvalue, '_isdel':0}) if ndx > -1: return str(view[ndx].id) raise KeyError, keyvalue
|
return str(view[ndx].id)
|
row = view[ndx] if not row._isdel: return str(row.id)
|
def lookup(self, keyvalue): if type(keyvalue) is not _STRINGTYPE: raise TypeError, "%r is not a string" % keyvalue iv = self.getindexview() if iv: ndx = iv.find(k=keyvalue) if ndx > -1: return str(iv[ndx].i) else: view = self.getview() ndx = view.find({self.keyname:keyvalue, '_isdel':0}) if ndx > -1: return str(view[ndx].id) raise KeyError, keyvalue
|
view = self.getview(1)
|
view = self.getview(READWRITE)
|
def destroy(self, id): view = self.getview(1) ndx = view.find(id=int(id)) if ndx > -1: if self.keyname: keyvalue = getattr(view[ndx], self.keyname) iv = self.getindexview(1) if iv: ivndx = iv.find(k=keyvalue) if ivndx > -1: iv.delete(ivndx) view.delete(ndx) self.db.destroyjournal(self.classname, id) self.db.dirty = 1
|
if self.keyname: keyvalue = getattr(view[ndx], self.keyname) iv = self.getindexview(1)
|
if self.key: keyvalue = getattr(view[ndx], self.key) iv = self.getindexview(READWRITE)
|
def destroy(self, id): view = self.getview(1) ndx = view.find(id=int(id)) if ndx > -1: if self.keyname: keyvalue = getattr(view[ndx], self.keyname) iv = self.getindexview(1) if iv: ivndx = iv.find(k=keyvalue) if ivndx > -1: iv.delete(ivndx) view.delete(ndx) self.db.destroyjournal(self.classname, id) self.db.dirty = 1
|
sv = getattr(row, nm) for sr in sv: if ids.has_key(sr.fid): return 1
|
if not row._isdel: sv = getattr(row, nm) for sr in sv: if ids.has_key(sr.fid): return 1
|
def ff(row, nm=propname, ids=ids): sv = getattr(row, nm) for sr in sv: if ids.has_key(sr.fid): return 1 return 0
|
return ids.has_key(getattr(row, nm))
|
return not row._isdel and ids.has_key(getattr(row, nm))
|
def ff(row, nm=propname, ids=ids): return ids.has_key(getattr(row, nm))
|
view = self.getview(1)
|
view = self.getview(READWRITE)
|
def import_list(self, propnames, proplist): ''' Import a node - all information including "id" is present and should not be sanity checked. Triggers are not triggered. The journal should be initialised using the "creator" and "creation" information.
|
sv.append(int(entry))
|
sv.append((int(entry),))
|
def import_list(self, propnames, proplist): ''' Import a node - all information including "id" is present and should not be sanity checked. Triggers are not triggered. The journal should be initialised using the "creator" and "creation" information.
|
view = self.getview(1)
|
view = self.getview(READWRITE)
|
def _clear(self): view = self.getview(1) if len(view): view[:] = [] self.db.dirty = 1 iv = self.getindexview(1) if iv: iv[:] = []
|
iv = self.getindexview(1)
|
iv = self.getindexview(READWRITE)
|
def _clear(self): view = self.getview(1) if len(view): view[:] = [] self.db.dirty = 1 iv = self.getindexview(1) if iv: iv[:] = []
|
mktyp = _typmap[rutyp.__class__]
|
mktyp = _typmap[rutyp.__class__].upper() if nm in _columns and _columns[nm] != mktyp: raise MKBackendError("column %s for table %sis defined with multiple types"%(nm, self.classname)) _columns[nm] = mktyp
|
def __getview(self): ''' Find the interface for a specific Class in the hyperdb.
|
v = self.db._db.getas(','.join(s))
|
view = self.db._db.getas(','.join(s))
|
def __getview(self): ''' Find the interface for a specific Class in the hyperdb.
|
return v.ordered(1)
|
return view.ordered(1)
|
def __getview(self): ''' Find the interface for a specific Class in the hyperdb.
|
hyperdb.Boolean : lambda n: n, hyperdb.Number : lambda n: n,
|
hyperdb.Boolean : getBoolean, hyperdb.Number : getNumber,
|
def _fetchInterval(n): ''' Convert to a date.Interval unless the interval is '' which is our sentinel for "unset". ''' if n == '': return None return date.Interval(n)
|
if self.TRACKER_HOMES.has_key(tracker_name): tracker_home = self.TRACKER_HOMES[tracker_name] tracker = roundup.instance.open(tracker_home) else: raise client.NotFound
|
def inner_run_cgi(self): ''' This is the inner part of the CGI handling ''' rest = self.path
|
|
tracker = self.get_tracker(tracker_name)
|
def inner_run_cgi(self): ''' This is the inner part of the CGI handling ''' rest = self.path
|
|
TRACKER_HOMES = dict(self.trackers())
|
TRACKER_HOMES = dict(tracker_homes) TRACKERS = trackers
|
def get_server(self): """Return HTTP server object to run""" # redirect stdout/stderr to our logfile # this is done early to have following messages go to this logfile if self["LOGFILE"]: # appending, unbuffered sys.stdout = sys.stderr = open(self["LOGFILE"], 'a', 0) # we don't want the cgi module interpreting the command-line args ;) sys.argv = sys.argv[:1] # build customized request handler class class RequestHandler(RoundupRequestHandler): LOG_IPADDRESS = not self["LOG_HOSTNAMES"] TRACKER_HOMES = dict(self.trackers()) # obtain request server class if self["MULTIPROCESS"] not in MULTIPROCESS_TYPES: print _("Multiprocess mode \"%s\" is not available, " "switching to single-process") % self["MULTIPROCESS"] self["MULTIPROCESS"] = "none" server_class = BaseHTTPServer.HTTPServer elif self["MULTIPROCESS"] == "fork": class ForkingServer(SocketServer.ForkingMixIn, BaseHTTPServer.HTTPServer): pass server_class = ForkingServer elif self["MULTIPROCESS"] == "thread": class ThreadingServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer): pass server_class = ThreadingServer else: server_class = BaseHTTPServer.HTTPServer # obtain server before changing user id - allows to # use port < 1024 if started as root try: httpd = server_class((self["HOST"], self["PORT"]), RequestHandler) except socket.error, e: if e[0] == errno.EADDRINUSE: raise socket.error, \ _("Unable to bind to port %s, port already in use.") \ % self["PORT"] raise # change user and/or group setgid(self["GROUP"]) setuid(self["USER"]) # return the server return httpd
|
self.instance.config.TRACKER_NAME
|
config['TRACKER_NAME']
|
def handle_message(self, message): ''' message - a Message instance
|
elif hasattr(self.instance.config, 'MAIL_DEFAULT_CLASS') and \ self.instance.config.MAIL_DEFAULT_CLASS: classname = self.instance.config.MAIL_DEFAULT_CLASS
|
def handle_message(self, message): ''' message - a Message instance
|
|
m = None
|
classname = config['MAILGW_DEFAULT_CLASS'] if not classname: m = None
|
def handle_message(self, message): ''' message - a Message instance
|
'''%(self.instance.config.ADMIN_EMAIL, current_class)
|
''' % (config['ADMIN_EMAIL'], current_class)
|
def handle_message(self, message): ''' message - a Message instance
|
'''%(self.instance.config.ADMIN_EMAIL, errors)
|
'''%(config['ADMIN_EMAIL'], errors)
|
def handle_message(self, message): ''' message - a Message instance
|
tracker_email = self.instance.config.TRACKER_EMAIL.lower()
|
tracker_email = config['TRACKER_EMAIL'].lower()
|
def handle_message(self, message): ''' message - a Message instance
|
classname, nodeid, self.instance.config.MAIL_DOMAIN)
|
classname, nodeid, config['MAIL_DOMAIN'])
|
def handle_message(self, message): ''' message - a Message instance
|
keep_citations = getattr(self.instance.config, 'EMAIL_KEEP_QUOTED_TEXT', 'no') == 'yes' keep_body = getattr(self.instance.config, 'EMAIL_LEAVE_BODY_UNCHANGED', 'no') == 'yes'
|
keep_citations = config['MAILGW_KEEP_QUOTED_TEXT'] keep_body = config['MAILGW_LEAVE_BODY_UNCHANGED']
|
def handle_message(self, message): ''' message - a Message instance
|
self.opendb('admin')
|
def determine_context(self, dre=re.compile(r'([^\d]+)0*(\d+)')): """Determine the context of this page from the URL:
|
|
self.opendb('admin')
|
def serve_file(self, designator, dre=re.compile(r'([^\d]+)(\d+)')): ''' Serve the file from the content property of the designated item. ''' m = dre.match(str(designator)) if not m: raise NotFound, str(designator) classname, nodeid = m.group(1), m.group(2)
|
|
def opendb(self, username): ''' Open the database and set the current user. Opens a database once. On subsequent calls only the user is set on the database object the instance.optimize is set. If we are in "Development Mode" (cf. roundup_server) then the database is always re-opened. ''' if hasattr(self, 'db') and self.db.isCurrentUser(username): return if not hasattr(self, 'db'): self.db = self.instance.open(username) else: if self.instance.optimize: self.db.setCurrentUser(username) else: self.db.close() self.db = self.instance.open(username)
|
def opendb(self, username): ''' Open the database and set the current user.
|
|
elif isinstance(propclass, String) and p.sort_type < 2: if not isinstance(v, type([])): v = [v] v = ['%%'+self.db.sql_stringquote(s)+'%%' for s in v] where.append('(' +' and '.join(["_%s._%s LIKE '%s'"%(pln, k, s) for s in v]) +')')
|
elif isinstance(propclass, String): if p.sort_type < 2: if not isinstance(v, type([])): v = [v] v = ['%%'+self.db.sql_stringquote(s)+'%%' for s in v] where.append('(' +' and '.join(["_%s._%s LIKE '%s'"%(pln, k, s) for s in v]) +')') if p.sort_type > 0: oc = ac = 'lower(_%s._%s)'%(pln, k)
|
def filter(self, search_matches, filterspec, sort=[], group=[]): '''Return a list of the ids of the active nodes in this class that match the 'filter' spec, sorted by the group spec and then the sort spec
|
if not self.editItemPermission(props):
|
if not self.editItemPermission(props, classname=cn, itemid=nodeid):
|
def _changenode(self, cn, nodeid, props): """Change the node based on the contents of the form.""" # check for permission if not self.editItemPermission(props): raise exceptions.Unauthorised, self._( 'You do not have permission to edit %(class)s' ) % {'class': cn}
|
if not self.newItemPermission(props):
|
if not self.newItemPermission(props, classname=cn):
|
def _createnode(self, cn, props): """Create a node based on the contents of the form.""" # check for permission if not self.newItemPermission(props): raise exceptions.Unauthorised, self._( 'You do not have permission to create %(class)s' ) % {'class': cn}
|
def editItemPermission(self, props):
|
_cn_marker = [] def editItemPermission(self, props, classname=_cn_marker, itemid=None):
|
def editItemPermission(self, props): """Determine whether the user has permission to edit this item.
|
if self.hasPermission('Edit', itemid=self.nodeid):
|
if itemid is None: itemid = self.nodeid if classname is self._cn_marker: classname = self.classname if self.hasPermission('Edit', itemid=itemid, classname=classname):
|
def editItemPermission(self, props): """Determine whether the user has permission to edit this item.
|
def newItemPermission(self, props):
|
def newItemPermission(self, props, classname=None):
|
def newItemPermission(self, props): """Determine whether the user has permission to create this item.
|
return self.hasPermission('Create')
|
if not classname : classname = self.client.classname return self.hasPermission('Create', classname=classname)
|
def newItemPermission(self, props): """Determine whether the user has permission to create this item.
|
try: reload(cgitb)
|
if self.DEBUG_MODE: try: reload(cgitb) self.wfile.write(cgitb.breaker()) self.wfile.write(cgitb.html()) except: s = StringIO.StringIO() traceback.print_exc(None, s) self.wfile.write("<pre>") self.wfile.write(cgi.escape(s.getvalue())) self.wfile.write("</pre>\n") else:
|
def run_cgi(self): """ Execute the CGI command. Wrap an innner call in an error handler so all errors can be caught. """ save_stdin = sys.stdin sys.stdin = self.rfile try: self.inner_run_cgi() except client.NotFound: self.send_error(404, self.path) except client.Unauthorised, message: self.send_error(403, '%s (%s)'%(self.path, message)) except: exc, val, tb = sys.exc_info() if hasattr(socket, 'timeout') and isinstance(val, socket.timeout): self.log_error('timeout') else: # it'd be nice to be able to detect if these are going to have # any effect... self.send_response(400) self.send_header('Content-Type', 'text/html') self.end_headers() try: reload(cgitb) self.wfile.write(cgitb.breaker()) self.wfile.write(cgitb.html()) except: s = StringIO.StringIO() traceback.print_exc(None, s) self.wfile.write("<pre>") self.wfile.write(cgi.escape(s.getvalue())) self.wfile.write("</pre>\n") sys.stdin = save_stdin
|
self.wfile.write(cgitb.html()) except: s = StringIO.StringIO() traceback.print_exc(None, s) self.wfile.write("<pre>") self.wfile.write(cgi.escape(s.getvalue())) self.wfile.write("</pre>\n")
|
ts = time.ctime() self.wfile.write('''<p>%s: An error occurred. Please check the server log for more infomation.</p>'''%ts) print 'EXCEPTION AT', ts traceback.print_exc()
|
def run_cgi(self): """ Execute the CGI command. Wrap an innner call in an error handler so all errors can be caught. """ save_stdin = sys.stdin sys.stdin = self.rfile try: self.inner_run_cgi() except client.NotFound: self.send_error(404, self.path) except client.Unauthorised, message: self.send_error(403, '%s (%s)'%(self.path, message)) except: exc, val, tb = sys.exc_info() if hasattr(socket, 'timeout') and isinstance(val, socket.timeout): self.log_error('timeout') else: # it'd be nice to be able to detect if these are going to have # any effect... self.send_response(400) self.send_header('Content-Type', 'text/html') self.end_headers() try: reload(cgitb) self.wfile.write(cgitb.breaker()) self.wfile.write(cgitb.html()) except: s = StringIO.StringIO() traceback.print_exc(None, s) self.wfile.write("<pre>") self.wfile.write(cgi.escape(s.getvalue())) self.wfile.write("</pre>\n") sys.stdin = save_stdin
|
def lock(file, flags): hfile = win32file._get_osfhandle(file.fileno()) win32file.LockFileEx(hfile, flags, 0, 0xffff0000, __overlapped) def unlock(file): hfile = win32file._get_osfhandle(file.fileno()) win32file.UnlockFileEx(hfile, 0, 0xffff0000, __overlapped)
|
def lock(file, flags): hfile = win32file._get_osfhandle(file.fileno()) try: win32file.LockFileEx(hfile, flags, 0, 0xffff0000, __overlapped) except win32file.error, e: import winerror if e[0] != winerror.ERROR_CALL_NOT_IMPLEMENTED: raise e if not flags & LOCK_EX: import warnings warnings.warn("PortaLocker does not support shared locking on Win9x", RuntimeWarning) if flags & LOCK_NB: win32file.LockFile(hfile, 0, 0, 0xffff0000, 0) else: import time while 1: try: win32file.LockFile(hfile, 0, 0, 0xffff0000, 0) break except win32file.error, e: if e[0] != winerror.ERROR_LOCK_VIOLATION: raise e time.sleep(0.1) def unlock(file): hfile = win32file._get_osfhandle(file.fileno()) try: win32file.UnlockFileEx(hfile, 0, 0xffff0000, __overlapped) except win32file.error, e: import winerror if e[0] != winerror.ERROR_CALL_NOT_IMPLEMENTED: raise e win32file.UnlockFile(hfile, 0, 0, 0xffff0000, 0)
|
def lock(file, flags): hfile = win32file._get_osfhandle(file.fileno()) win32file.LockFileEx(hfile, flags, 0, 0xffff0000, __overlapped)
|
try: user = os.getenv('REMOTE_USER') except KeyError: pass
|
if self.env.has_key('REMOTE_USER'): user = self.env['REMOTE_USER'] else: user = 'anonymous'
|
def determine_user(self): ''' Determine who the user is ''' # determine the uid to use self.opendb('admin')
|
linkcl.classname, itemid=id)]
|
linkcl.classname, itemid=opt)]
|
def menu(self, size=None, height=None, showid=0, additional=[], value=None, sort_on=None, **conditions): ''' Render a form select list for this property
|
linkcl.classname, itemid=id)]
|
linkcl.classname, itemid=opt)]
|
def menu(self, size=None, height=None, showid=0, additional=[], value=None, sort_on=None, **conditions): ''' Render a form <select> list for this property.
|
frum.append('_%s as _%s' % (cn, ln))
|
if p.sort_type == 0: frum.append('_%s as _%s' % (cn, ln))
|
def filter(self, search_matches, filterspec, sort=[], group=[]): '''Return a list of the ids of the active nodes in this class that match the 'filter' spec, sorted by the group spec and then the sort spec
|
if p.tree_sort_done and (p.sort_type == 2 or not p.children):
|
if p.tree_sort_done and p.sort_type > 0:
|
def filter(self, search_matches, filterspec, sort=[], group=[]): '''Return a list of the ids of the active nodes in this class that match the 'filter' spec, sorted by the group spec and then the sort spec
|
if not self.db.security.hasPermission('Edit', author, classname):
|
if not self.db.security.hasPermission('Edit', author, classname, itemid=nodeid):
|
def handle_message(self, message): ''' message - a Message instance
|
p = db.security.getPermission('View', 'issue') db.security.addPermissionToRole('Anonymous', p)
|
for cl in 'issue', 'file', 'msg', 'keyword': p = db.security.getPermission('View', cl) db.security.addPermissionToRole('Anonymous', p)
|
def open(name=None): ''' as from the roundupdb method openDB ''' from roundup.hyperdb import String, Password, Date, Link, Multilink from roundup.hyperdb import Interval, Boolean, Number # open the database db = Database(config, name) # # Now initialise the schema. Must do this each time the database is # opened. # # Class automatically gets these properties: # creation = Date() # activity = Date() # creator = Link('user') pri = Class(db, "priority", name=String(), order=String()) pri.setkey("name") stat = Class(db, "status", name=String(), order=String()) stat.setkey("name") keyword = Class(db, "keyword", name=String()) keyword.setkey("name") query = Class(db, "query", klass=String(), name=String(), url=String()) query.setkey("name") # add any additional database schema configuration here # Note: roles is a comma-separated string of Role names user = Class(db, "user", username=String(), password=Password(), address=String(), realname=String(), phone=String(), organisation=String(), alternate_addresses=String(), queries=Multilink('query'), roles=String(), timezone=String()) user.setkey("username") # FileClass automatically gets these properties: # content = String() [saved to disk in <tracker home>/db/files/] # (it also gets the Class properties creation, activity and creator) msg = FileClass(db, "msg", author=Link("user", do_journal='no'), recipients=Multilink("user", do_journal='no'), date=Date(), summary=String(), files=Multilink("file"), messageid=String(), inreplyto=String()) file = FileClass(db, "file", name=String(), type=String()) # IssueClass automatically gets these properties: # title = String() # messages = Multilink("msg") # files = Multilink("file") # nosy = Multilink("user") # superseder = Multilink("issue") # (it also gets the Class properties creation, activity and creator) issue = IssueClass(db, "issue", assignedto=Link("user"), topic=Multilink("keyword"), priority=Link("priority"), status=Link("status")) # # SECURITY SETTINGS # # See the configuration and customisation document for information # about security setup. # Add new Permissions for this schema for cl in 'issue', 'file', 'msg', 'user', 'query', 'keyword': db.security.addPermission(name="Edit", klass=cl, description="User is allowed to edit "+cl) db.security.addPermission(name="View", klass=cl, description="User is allowed to access "+cl) # Assign the access and edit Permissions for issue, file and message # to regular users now for cl in 'issue', 'file', 'msg', 'query', 'keyword': p = db.security.getPermission('View', cl) db.security.addPermissionToRole('User', p) p = db.security.getPermission('Edit', cl) db.security.addPermissionToRole('User', p) # and give the regular users access to the web and email interface p = db.security.getPermission('Web Access') db.security.addPermissionToRole('User', p) p = db.security.getPermission('Email Access') db.security.addPermissionToRole('User', p) # May users view other user information? Comment these lines out # if you don't want them to p = db.security.getPermission('View', 'user') db.security.addPermissionToRole('User', p) # Assign the appropriate permissions to the anonymous user's Anonymous # Role. Choices here are: # - Allow anonymous users to register through the web p = db.security.getPermission('Web Registration') db.security.addPermissionToRole('Anonymous', p) # - Allow anonymous (new) users to register through the email gateway p = db.security.getPermission('Email Registration') db.security.addPermissionToRole('Anonymous', p) # - Allow anonymous users access to the "issue" class of data # Note: this also grants access to related information like files, # messages, statuses etc that are linked to issues p = db.security.getPermission('View', 'issue') db.security.addPermissionToRole('Anonymous', p) # - Allow anonymous users access to edit the "issue" class of data # Note: this also grants access to create related information like # files and messages etc that are linked to issues #p = db.security.getPermission('Edit', 'issue') #db.security.addPermissionToRole('Anonymous', p) # oh, g'wan, let anonymous access the web interface too p = db.security.getPermission('Web Access') db.security.addPermissionToRole('Anonymous', p) import detectors detectors.init(db) # schema is set up - run any post-initialisation db.post_init() return db
|
def menu(self, size=None, height=None, showid=0, additional=[],
|
def menu(self, size=None, height=None, showid=0, additional=[], value=None,
|
def menu(self, size=None, height=None, showid=0, additional=[], sort_on=None, **conditions): ''' Render a form select list for this property
|
value = self._value
|
if value is None: value = self._value
|
def menu(self, size=None, height=None, showid=0, additional=[], sort_on=None, **conditions): ''' Render a form select list for this property
|
sort_on=None, **conditions):
|
value=None, sort_on=None, **conditions):
|
def menu(self, size=None, height=None, showid=0, additional=[], sort_on=None, **conditions): ''' Render a form <select> list for this property.
|
value = self._value
|
if value is None: value = self._value
|
def menu(self, size=None, height=None, showid=0, additional=[], sort_on=None, **conditions): ''' Render a form <select> list for this property.
|
authaddr = straddr( ('',authaddr) )
|
authaddr = " <%s>" % straddr( ('',authaddr) )
|
def send_message(self, nodeid, msgid, note, sendto): '''Actually send the nominated message from this node to the sendto recipients, with the note appended. ''' users = self.db.user messages = self.db.msg files = self.db.file
|
class TemplatingUtil: def __init__(self, utils, callable): self.utils = utils self.callable = callable def __call__(self, *args, **kw): args = (self.utils,)+args return self.callable(*args, **kw)
|
def next(self): try: self._sequence[self.end] except IndexError: return None return Batch(self.client, self._sequence, self._size, self.end - self.overlap, 0, self.orphan, self.overlap)
|
|
return TemplatingUtil(self, self.client.instance.templating_utils[name])
|
return self.client.instance.templating_utils[name]
|
def __getattr__(self, name): '''Try the tracker's templating_utils.''' if not hasattr(self.client.instance, 'templating_utils'): # backwards-compatibility raise AttributeError, name if not self.client.instance.templating_utils.has_key(name): raise AttributeError, name return TemplatingUtil(self, self.client.instance.templating_utils[name])
|
def translation(domain, localedir=None, languages=None, class_=None):
|
def find_translation(domain, localedir=None, languages=None, class_=None):
|
def translation(domain, localedir=None, languages=None, class_=None): """Always raise IOError (no message catalogs available)""" raise IOError(errno.ENOENT, "No translation file found for domain", domain)
|
translation = gettext_module.translation
|
find_translation = gettext_module.translation
|
def ungettext(self, singular, plural, count): if count == 1: _msg = singular else: _msg = plural return self.ugettext(_msg)
|
def get_translation(language=None, domain=DOMAIN): """Return Translation object for given language and domain"""
|
def get_translation(language=None, domain=DOMAIN, translation_class=RoundupTranslations, null_translation_class=RoundupNullTranslations ): """Return Translation object for given language and domain Arguments 'translation_class' and 'null_translation_class' specify the classes that are instantiated for existing and non-existing translations, respectively. """
|
def get_translation(language=None, domain=DOMAIN): """Return Translation object for given language and domain""" if language: _languages = [language] else: # use OS environment _languages = None # except for english ("en") language, add english fallback if available if language == "en": _fallback = None else: try: _fallback = translation(domain=domain, languages=["en"], class_=RoundupTranslations) except IOError: # no .mo files found _fallback = None # get the translation try: _translation = translation(domain=domain, languages=_languages, class_=RoundupTranslations) except IOError: _translation = None # see what's found if _translation and _fallback: _translation.add_fallback(_fallback) elif _fallback: _translation = _fallback elif not _translation: _translation = RoundupNullTranslations() return _translation
|
_fallback = translation(domain=domain, languages=["en"], class_=RoundupTranslations)
|
_fallback = find_translation(domain=domain, languages=["en"], class_=translation_class)
|
def get_translation(language=None, domain=DOMAIN): """Return Translation object for given language and domain""" if language: _languages = [language] else: # use OS environment _languages = None # except for english ("en") language, add english fallback if available if language == "en": _fallback = None else: try: _fallback = translation(domain=domain, languages=["en"], class_=RoundupTranslations) except IOError: # no .mo files found _fallback = None # get the translation try: _translation = translation(domain=domain, languages=_languages, class_=RoundupTranslations) except IOError: _translation = None # see what's found if _translation and _fallback: _translation.add_fallback(_fallback) elif _fallback: _translation = _fallback elif not _translation: _translation = RoundupNullTranslations() return _translation
|
_translation = translation(domain=domain, languages=_languages, class_=RoundupTranslations)
|
_translation = find_translation(domain=domain, languages=_languages, class_=translation_class)
|
def get_translation(language=None, domain=DOMAIN): """Return Translation object for given language and domain""" if language: _languages = [language] else: # use OS environment _languages = None # except for english ("en") language, add english fallback if available if language == "en": _fallback = None else: try: _fallback = translation(domain=domain, languages=["en"], class_=RoundupTranslations) except IOError: # no .mo files found _fallback = None # get the translation try: _translation = translation(domain=domain, languages=_languages, class_=RoundupTranslations) except IOError: _translation = None # see what's found if _translation and _fallback: _translation.add_fallback(_fallback) elif _fallback: _translation = _fallback elif not _translation: _translation = RoundupNullTranslations() return _translation
|
_translation = RoundupNullTranslations()
|
_translation = null_translation_class()
|
def get_translation(language=None, domain=DOMAIN): """Return Translation object for given language and domain""" if language: _languages = [language] else: # use OS environment _languages = None # except for english ("en") language, add english fallback if available if language == "en": _fallback = None else: try: _fallback = translation(domain=domain, languages=["en"], class_=RoundupTranslations) except IOError: # no .mo files found _fallback = None # get the translation try: _translation = translation(domain=domain, languages=_languages, class_=RoundupTranslations) except IOError: _translation = None # see what's found if _translation and _fallback: _translation.add_fallback(_fallback) elif _fallback: _translation = _fallback elif not _translation: _translation = RoundupNullTranslations() return _translation
|
'if NOT "%%_4ver%%" == "" %(python)s -O -c "from %(package)s.scripts.%(module)s import run; run()" %%$\n' 'if "%%_4ver%%" == "" %(python)s -O -c "from %(package)s.scripts.%(module)s import run; run()" %%*\n'
|
'if NOT "%%_4ver%%" == "" "%(python)s" -O -c "from %(package)s.scripts.%(module)s import run; run()" %%$\n' 'if "%%_4ver%%" == "" "%(python)s" -O -c "from %(package)s.scripts.%(module)s import run; run()" %%*\n'
|
def copy_scripts(self): """ Create each script listed in 'self.scripts' """ if not self.package_name: raise Exception("You have to inherit build_scripts_create and" " provide a package name") to_module = string.maketrans('-/', '_.')
|
if len(changed) > 1: plural = 's were' else: plural = ' was' summary = 'This %s has been created through the web.'%cn m.append('\n%s\n'%summary)
|
m.append('\nThis %s has been created through ' 'the web.\n'%cn)
|
def newissue(self, message=None): ''' add an issue ''' cn = self.classname cl = self.db.classes[cn]
|
if qids:
|
if qids and old_queryname:
|
def handle(self): """Mangle some of the form variables.
|
linkvalue = cgi.escape(linkcl.get(value, k))
|
linkvalue = cgi.escape(str(linkcl.get(value, k)))
|
def do_link(self, property=None, is_download=0, showid=0): '''For a Link or Multilink property, display the names of the linked nodes, hyperlinked to the item views on those nodes. For other properties, link to this node with the property as the text.
|
option = cgi.escape(linkcl.get(optionid, k))
|
option = cgi.escape(str(linkcl.get(optionid, k)))
|
def do_checklist(self, property, **args): ''' for a Link or Multilink property, display checkboxes for the available choices to permit filtering ''' propclass = self.properties[property] if (not isinstance(propclass, hyperdb.Link) and not isinstance(propclass, hyperdb.Multilink)): return _('[Checklist: not a link]')
|
if cl.get(nodeid, entry) is None:
|
if cl.get(nodeid, entry) is not None:
|
propdef = all_propdef[cn]
|
def extractUserFromList(users):
|
def extractUserFromList(userClass, users):
|
def extractUserFromList(users): '''Given a list of users, try to extract the first non-anonymous user and return that user, otherwise return None ''' if len(users) > 1: # make sure we don't match the anonymous or admin user for user in users: if user == '1': continue if self.user.get(user, 'username') == 'anonymous': continue # first valid match will do return user # well, I guess we have no choice return user[0] elif users: return users[0] return None
|
if self.user.get(user, 'username') == 'anonymous': continue
|
if userClass.get(user, 'username') == 'anonymous': continue
|
def extractUserFromList(users): '''Given a list of users, try to extract the first non-anonymous user and return that user, otherwise return None ''' if len(users) > 1: # make sure we don't match the anonymous or admin user for user in users: if user == '1': continue if self.user.get(user, 'username') == 'anonymous': continue # first valid match will do return user # well, I guess we have no choice return user[0] elif users: return users[0] return None
|
user = extractUserFromList(self.user.stringFind(address=address))
|
user = extractUserFromList(self.user, self.user.stringFind(address=address))
|
def uidFromAddress(self, address, create=1): ''' address is from the rfc822 module, and therefore is (name, addr)
|
user = extractUserFromList(users)
|
user = extractUserFromList(self.user, users)
|
def uidFromAddress(self, address, create=1): ''' address is from the rfc822 module, and therefore is (name, addr)
|
user = extractUserFromList(self.user.stringFind(username=address))
|
user = extractUserFromList(self.user, self.user.stringFind(username=address))
|
def uidFromAddress(self, address, create=1): ''' address is from the rfc822 module, and therefore is (name, addr)
|
prop = cl.properties[propname]
|
prop = props[propname]
|
def generateChangeNote(self, nodeid, oldvalues): """Generate a change note that lists property changes """ cn = self.classname cl = self.db.classes[cn] changed = {} props = cl.getprops(protected=0)
|
hal = self.env['HTTP_ACCEPT_LANGUAGE']
|
hal = self.env.get('HTTP_ACCEPT_LANGUAGE')
|
def determine_language(self): """Determine the language""" # look for language parameter # then for language cookie # last for the Accept-Language header if self.form.has_key("@language"): language = self.form["@language"].value if language.lower() == "none": language = "" self.add_cookie("roundup_language", language) elif self.cookie.has_key("roundup_language"): language = self.cookie["roundup_language"].value elif self.instance.config["WEB_USE_BROWSER_LANGUAGE"]: hal = self.env['HTTP_ACCEPT_LANGUAGE'] language = accept_language.parse(hal) else: language = ""
|
self.assertEqual(keys, ['assignedto', 'deadline', 'files', 'foo', 'messages', 'nosy', 'status', 'superseder', 'title']) self.assertEqual(None,params['deadline']) self.assertEqual(None,params['foo']) self.assertEqual([],params['nosy']) self.assertEqual('1',params['status']) self.assertEqual('spam',params['title'])
|
self.assertEqual(keys, [])
|
def testJournals(self): self.db.user.create(username="mary") self.db.user.create(username="pete") self.db.issue.create(title="spam", status='1') self.db.commit()
|
init.write_select_db(self.dirname, 'anydbm')
|
init.write_select_db(self.dirname, 'sqlite')
|
def setUp(self): MailgwTestCase.count = MailgwTestCase.count + 1 self.dirname = '_test_mailgw_%s'%self.count try: shutil.rmtree(self.dirname) except OSError, error: if error.errno not in (errno.ENOENT, errno.ESRCH): raise # create the instance init.install(self.dirname, 'templates/classic') init.write_select_db(self.dirname, 'anydbm') init.initialise(self.dirname, 'sekrit')
|
return handler.main(StringIO(message))
|
ret = handler.main(StringIO(message)) self.db = handler.db return ret
|
def _handle_mail(self, message): handler = self.instance.MailGW(self.instance, self.db) handler.trapExceptions = 0 return handler.main(StringIO(message))
|
if self._db.security.hasPermission('View', self._client.userid, self._classname): return 1 return self.is_edit_ok()
|
return self._db.security.hasPermission('View', self._client.userid, self._classname)
|
def is_view_ok(self): ''' Is the user allowed to View the current class? ''' if self._db.security.hasPermission('View', self._client.userid, self._classname): return 1 return self.is_edit_ok()
|
def plain(self, escape=0, hyperlink=1):
|
def plain(self, escape=0, hyperlink=0):
|
def plain(self, escape=0, hyperlink=1): ''' Render a "plain" representation of the property "escape" turns on/off HTML quoting "hyperlink" turns on/off in-text hyperlinking of URLs, email addresses and designators ''' if self._value is None: return '' if escape: s = cgi.escape(str(self._value)) else: s = self._value if hyperlink: s = self.url_re.sub(self._url_repl, s) s = self.email_re.sub(self._email_repl, s) s = self.designator_re.sub(self._designator_repl, s) return s
|
s = self._value
|
s = str(self._value)
|
def plain(self, escape=0, hyperlink=1): ''' Render a "plain" representation of the property "escape" turns on/off HTML quoting "hyperlink" turns on/off in-text hyperlinking of URLs, email addresses and designators ''' if self._value is None: return '' if escape: s = cgi.escape(str(self._value)) else: s = self._value if hyperlink: s = self.url_re.sub(self._url_repl, s) s = self.email_re.sub(self._email_repl, s) s = self.designator_re.sub(self._designator_repl, s) return s
|
messages.set(msgid, messageid=messageid)
|
if msgid is not None: messages.set(msgid, messageid=messageid)
|
def send_message(self, nodeid, msgid, note, sendto, from_address=None, bcc_sendto=[]): '''Actually send the nominated message from this node to the sendto recipients, with the note appended. ''' users = self.db.user messages = self.db.msg files = self.db.file
|
for key, value in propvalues.items():
|
journalvalues = {} for propname, value in propvalues.items():
|
def set(self, nodeid, **propvalues): """Modify a property on an existing node of this class. 'nodeid' must be the id of an existing node of this class or an IndexError is raised.
|
if key == self.key and node[key] != value:
|
if propname == self.key and node[propname] != value:
|
def set(self, nodeid, **propvalues): """Modify a property on an existing node of this class. 'nodeid' must be the id of an existing node of this class or an IndexError is raised.
|
prop = self.properties[key]
|
prop = self.properties[propname]
|
def set(self, nodeid, **propvalues): """Modify a property on an existing node of this class. 'nodeid' must be the id of an existing node of this class or an IndexError is raised.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.