rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
'''Usage: set [items] property=value property=value ...
|
'''Usage: set items property=value property=value ...
|
def do_set(self, args, pwre = re.compile(r'{(\w+)}(.+)')): '''Usage: set [items] property=value property=value ... Set the given properties of one or more items(s).
|
The items may be specified as a class or as a comma-separated
|
The items are specified as a class or as a comma-separated
|
def do_set(self, args, pwre = re.compile(r'{(\w+)}(.+)')): '''Usage: set [items] property=value property=value ... Set the given properties of one or more items(s).
|
for required in 'config open init Client MailGW'.split():
|
for required in 'open init Client MailGW'.split():
|
def open(self, tracker_home): ''' Open the tracker.
|
config = tracker.config if hasattr(config, 'LOGGING_CONFIG'): try: import logging config.logging = logging except ImportError, msg: raise TrackerError, 'Python logging module unavailable: %s'%msg config.logging.fileConfig(config.LOGGING_CONFIG) else: config.logging = rlog.BasicLogging() if hasattr(config, 'LOGGING_FILENAME'): config.logging.setFile(config.LOGGING_FILENAME) if hasattr(config, 'LOGGING_LEVEL'): config.logging.setLevel(config.LOGGING_LEVEL) else: config.logging.setLevel('ERROR')
|
tracker.config = configuration.Config(tracker_home) tracker.dbinit.config = tracker.config
|
def open(self, tracker_home): ''' Open the tracker.
|
def formatdate(timeval): return time.strftime("%a, %d %b %Y %H:%M:%S +0000", timeval)
|
def formatdate(): return time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())
|
def formatdate(timeval): return time.strftime("%a, %d %b %Y %H:%M:%S +0000", timeval)
|
writer.addheader('Date', formatdate(time.mktime(time.gmtime())))
|
writer.addheader('Date', formatdate())
|
def get_standard_message(self, to, subject, author=None): '''Form a standard email message from Roundup.
|
m = ['Subject: [%s%s] %s'%(cn, nodeid, title)] m.append('To: %s'%', '.join(sendto)) m.append('From: %s'%self.ISSUE_TRACKER_EMAIL) m.append('Reply-To: %s'%self.ISSUE_TRACKER_EMAIL) m.append('')
|
m = []
|
def sendmessage(self, nodeid, msgid): """Send a message to the members of an issue's nosy list.
|
smtp.sendmail(self.ISSUE_TRACKER_EMAIL, sendto, '\n'.join(m))
|
smtp.sendmail(self.ISSUE_TRACKER_EMAIL, sendto, message.getvalue())
|
def sendmessage(self, nodeid, msgid): """Send a message to the members of an issue's nosy list.
|
web = self.ISSUE_TRACKER_WEB
|
web = self.ISSUE_TRACKER_WEB + 'issue'+ nodeid
|
def email_footer(self, nodeid, msgid): ''' Add a footer to the e-mail with some useful information ''' web = self.ISSUE_TRACKER_WEB return '''%s
|
kwargs = rdbms_common.connection_dict(config)
|
kwargs = connection_dict(config)
|
def db_nuke(config): """Clear all database contents and drop database itself""" if db_exists(config): kwargs = rdbms_common.connection_dict(config) conn = MySQLdb.connect(**kwargs) try: conn.select_db(config.RDBMS_NAME) except: # no, it doesn't exist pass else: cursor = conn.cursor() cursor.execute("SHOW TABLES") tables = cursor.fetchall() # stupid MySQL bug requires us to drop all the tables first for table in tables: command = 'DROP TABLE %s'%table[0] if __debug__: config.logging.getLogger('hyperdb').debug(command) cursor.execute(command) command = "DROP DATABASE %s"%config.RDBMS_NAME config.logging.getLogger('hyperdb').info(command) cursor.execute(command) conn.commit() conn.close() if os.path.exists(config.DATABASE): shutil.rmtree(config.DATABASE)
|
kwargs = rdbms_common.connection_dict(config)
|
kwargs = connection_dict(config)
|
def db_create(config): """Create the database.""" kwargs = rdbms_common.connection_dict(config) conn = MySQLdb.connect(**kwargs) cursor = conn.cursor() command = "CREATE DATABASE %s"%config.RDBMS_NAME config.logging.getLogger('hyperdb').info(command) cursor.execute(command) conn.commit() conn.close()
|
kwargs = rdbms_common.connection_dict(config)
|
kwargs = connection_dict(config)
|
def db_exists(config): """Check if database already exists.""" kwargs = rdbms_common.connection_dict(config) conn = MySQLdb.connect(**kwargs) try: try: conn.select_db(config.RDBMS_NAME) except MySQLdb.OperationalError: return 0 finally: conn.close() return 1
|
kwargs = rdbms_common.connection_dict(config, 'db')
|
kwargs = connection_dict(self.config)
|
def sql_open_connection(self): kwargs = rdbms_common.connection_dict(config, 'db') self.config.logging.getLogger('hyperdb').info('open database %r'%( kwargs['db'],)) try: conn = MySQLdb.connect(**kwargs) except MySQLdb.OperationalError, message: raise DatabaseError, message cursor = conn.cursor() cursor.execute("SET AUTOCOMMIT=OFF") cursor.execute("START TRANSACTION") return (conn, cursor)
|
if str(message).find('"schema" does not exist') == -1:
|
if str(message).find('schema') == -1:
|
def open_connection(self): if not db_exists(self.config): db_create(self.config)
|
set = {}
|
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.
|
|
def Choice(name, *options): cl = Class(db, name, name=hyperdb.String(), order=hyperdb.String())
|
def Choice(name, db, *options): '''Quick helper to create a simple class with choices ''' cl = Class(db, name, name=String(), order=String())
|
def Choice(name, *options): cl = Class(db, name, name=hyperdb.String(), order=hyperdb.String()) for i in range(len(options)): cl.create(name=option[i], order=i) return hyperdb.Link(name)
|
cl.create(name=option[i], order=i)
|
cl.create(name=options[i], order=i)
|
def Choice(name, *options): cl = Class(db, name, name=hyperdb.String(), order=hyperdb.String()) for i in range(len(options)): cl.create(name=option[i], order=i) return hyperdb.Link(name)
|
w('<tr class="list-header">' '<td align=left colspan=%s><strong>%s</strong></td></tr>'%(
|
w('<tr class="section-bar">' '<td align=middle colspan=%s><strong>%s</strong></td></tr>'%(
|
def index(client, templates, db, classname, filterspec={}, filter=[], columns=[], sort=[], group=[], show_display_form=1, nodeids=None, col_re=re.compile(r'<property\s+name="([^>]+)">')): globals = { 'plain': Plain(db, templates, classname, form={}), 'field': Field(db, templates, classname, form={}), 'menu': Menu(db, templates, classname, form={}), 'link': Link(db, templates, classname, form={}), 'count': Count(db, templates, classname, form={}), 'reldate': Reldate(db, templates, classname, form={}), 'download': Download(db, templates, classname, form={}), 'checklist': Checklist(db, templates, classname, form={}), 'list': List(db, templates, classname, form={}), 'history': History(db, templates, classname, form={}), 'submit': Submit(db, templates, classname, form={}), 'note': Note(db, templates, classname, form={}) } cl = db.classes[classname] properties = cl.getprops() w = client.write try: template = open(os.path.join(templates, classname+'.filter')).read() all_filters = col_re.findall(template) except IOError, error: if error.errno != errno.ENOENT: raise template = None all_filters = [] if template and filter: # display the filter section w('<form>') w('<table width=100% border=0 cellspacing=0 cellpadding=2>') w('<tr class="location-bar">') w(' <th align="left" colspan="2">Filter specification...</th>') w('</tr>') replace = IndexTemplateReplace(globals, locals(), filter) w(replace.go(template)) if columns: w('<input type="hidden" name=":columns" value="%s">'%','.join(columns)) if filter: w('<input type="hidden" name=":filter" value="%s">'%','.join(filter)) if sort: w('<input type="hidden" name=":sort" value="%s">'%','.join(sort)) if group: w('<input type="hidden" name=":group" value="%s">'%','.join(group)) for k, v in filterspec.items(): if type(v) == type([]): v = ','.join(v) w('<input type="hidden" name="%s" value="%s">'%(k, v)) w('<tr class="location-bar"><td width="1%%"> </td>') w('<td><input type="submit" value="Redisplay"></td></tr>') w('</table>') w('</form>') # XXX deviate from spec here ... # load the index section template and figure the default columns from it template = open(os.path.join(templates, classname+'.index')).read() all_columns = col_re.findall(template) if not columns: columns = [] for name in all_columns: columns.append(name) else: # re-sort columns to be the same order as all_columns l = [] for name in all_columns: if name in columns: l.append(name) columns = l # now display the index section w('<table width=100% border=0 cellspacing=0 cellpadding=2>') w('<tr class="list-header">') for name in columns: cname = name.capitalize() if show_display_form: anchor = "%s?%s"%(classname, sortby(name, columns, filter, sort, group, filterspec)) w('<td><span class="list-item"><a href="%s">%s</a></span></td>'%( anchor, cname)) else: w('<td><span class="list-item">%s</span></td>'%cname) w('</tr>') # this stuff is used for group headings - optimise the group names old_group = None group_names = [] if group: for name in group: if name[0] == '-': group_names.append(name[1:]) else: group_names.append(name) # now actually loop through all the nodes we get from the filter and # apply the template if nodeids is None: nodeids = cl.filter(filterspec, sort, group) for nodeid in nodeids: # check for a group heading if group_names: this_group = [cl.get(nodeid, name) for name in group_names] if this_group != old_group: l = [] for name in group_names: prop = properties[name] if prop.isLinkType: group_cl = db.classes[prop.classname] key = group_cl.getkey() value = cl.get(nodeid, name) if value is None: l.append('[unselected %s]'%prop.classname) else: l.append(group_cl.get(cl.get(nodeid, name), key)) elif prop.isMultilinkType: group_cl = db.classes[prop.classname] key = group_cl.getkey() for value in cl.get(nodeid, name): l.append(group_cl.get(value, key)) else: value = cl.get(nodeid, name) if value is None: value = '[empty %s]'%name l.append(value) w('<tr class="list-header">' '<td align=left colspan=%s><strong>%s</strong></td></tr>'%( len(columns), ', '.join(l))) old_group = this_group # display this node's row for value in globals.values(): if hasattr(value, 'nodeid'): value.nodeid = nodeid replace = IndexTemplateReplace(globals, locals(), columns) w(replace.go(template)) w('</table>') if not show_display_form: return # now add in the filter/columns/group/etc config table form w('<p><form>') w('<table width=100% border=0 cellspacing=0 cellpadding=2>') for k,v in filterspec.items(): if type(v) == type([]): v = ','.join(v) w('<input type="hidden" name="%s" value="%s">'%(k, v)) if sort: w('<input type="hidden" name=":sort" value="%s">'%','.join(sort)) names = [] for name in cl.getprops().keys(): if name in all_filters or name in all_columns: names.append(name) w('<tr class="location-bar">') w('<th align="left" colspan=%s>View customisation...</th></tr>'% (len(names)+1)) w('<tr class="location-bar"><th> </th>') for name in names: w('<th>%s</th>'%name.capitalize()) w('</tr>') # filter if all_filters: w('<tr><th width="1%" align=right class="location-bar">Filters</th>') for name in names: if name not in all_filters: w('<td> </td>') continue if name in filter: checked=' checked' else: checked='' w('<td align=middle>') w('<input type="checkbox" name=":filter" value="%s" %s></td>'%(name, checked)) w('</tr>') # columns if all_columns: w('<tr><th width="1%" align=right class="location-bar">Columns</th>') for name in names: if name not in all_columns: w('<td> </td>') continue if name in columns: checked=' checked' else: checked='' w('<td align=middle>') w('<input type="checkbox" name=":columns" value="%s" %s></td>'%( name, checked)) w('</tr>') # group w('<tr><th width="1%" align=right class="location-bar">Grouping</th>') for name in names: prop = properties[name] if name not in all_columns: w('<td> </td>') continue if name in group: checked=' checked' else: checked='' w('<td align=middle>') w('<input type="checkbox" name=":group" value="%s" %s></td>'%( name, checked)) w('</tr>') w('<tr class="location-bar"><td width="1%"> </td>') w('<td colspan="%s">'%len(names)) w('<input type="submit" value="Redisplay"></td></tr>') w('</table>') w('</form>')
|
<td><input name="__newuser_realname"></td></tr>
|
<td><input name="realname"></td></tr>
|
def login(self, message=None): self.pagehead('Login to roundup', message) self.write('''
|
<td><input name="__newuser_organisation"></td></tr>
|
<td><input name="organisation"></td></tr>
|
def login(self, message=None): self.pagehead('Login to roundup', message) self.write('''
|
<td><input name="__newuser_address"></td></tr>
|
<td><input name="address"></td></tr>
|
def login(self, message=None): self.pagehead('Login to roundup', message) self.write('''
|
<td><input name="__newuser_phone"></td></tr>
|
<td><input name="phone"></td></tr>
|
def login(self, message=None): self.pagehead('Login to roundup', message) self.write('''
|
<td><input name="__newuser_username"></td></tr>
|
<td><input name="username"></td></tr>
|
def login(self, message=None): self.pagehead('Login to roundup', message) self.write('''
|
<td><input type="password" name="__newuser_password"></td></tr>
|
<td><input type="password" name="password"></td></tr>
|
def login(self, message=None): self.pagehead('Login to roundup', message) self.write('''
|
<td><input type="password" name="__newuser_confirm"></td></tr>
|
<td><input type="password" name="confirm"></td></tr>
|
def login(self, message=None): self.pagehead('Login to roundup', message) self.write('''
|
if self.ANONYMOUS_REGISTER == 'deny' and self.user is None: return self.login()
|
def main(self, dre=re.compile(r'([^\d]+)(\d+)'), nre=re.compile(r'new(\w+)')):
|
|
raise Unauthorized, '''
|
author = anonid if not self.db.security.hasPermission('Email Access', author): if author == anonid: raise Unauthorized, '''
|
def handle_message(self, message): ''' message - a Message instance
|
if not self.db.security.hasPermission('Email Access', author): raise Unauthorized, 'You are not permitted to access this tracker.'
|
else: raise Unauthorized, 'You are not permitted to access '\ 'this tracker.'
|
def handle_message(self, message): ''' message - a Message instance
|
s = '' s = s + '<%s' % tag
|
self.append_data('<%s' % tag) closeit = 1
|
def unknown_starttag(self, tag, attributes): s = '' s = s + '<%s' % tag for name, value in attributes: s = s + ' %s="%s"' % (name, value) s = s + '>' self.append_data(s)
|
s = s + ' %s="%s"' % (name, value) s = s + '>' self.append_data(s)
|
pos = value.find('<') if pos > -1: self.append_data(' %s="%s' % (name, value[:pos])) closeit = 0 else: self.append_data(' %s="%s"' % (name, value)) if closeit: self.append_data('>')
|
def unknown_starttag(self, tag, attributes): s = '' s = s + '<%s' % tag for name, value in attributes: s = s + ' %s="%s"' % (name, value) s = s + '>' self.append_data(s)
|
except MessageSendException, e:
|
except MessageSendError, e:
|
def standard_message(self, to, subject, body, author=None): try: self.mailer.standard_message(to, subject, body, author) return 1 except MessageSendException, e: self.error_message.append(str(e))
|
print `summary`, `content`
|
def testParagraphs(self): s = '''testing\n\ntesting\n\ntesting''' summary, content = parseContent(s) print `summary`, `content` self.assertEqual(summary, 'testing') self.assertEqual(content, 'testing\n\ntesting\n\ntesting')
|
|
r'(?P<item>(?P<class>[A-Za-z_]+)(\s*)?(?P<id>\d+)))')
|
r'(?P<item>(?P<class>[A-Za-z_]+)(\s*)(?P<id>\d+)))')
|
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, self._name, self._nodeid): return 1 return self.is_edit_ok()
|
if (props['status'] == unread_id or props['status'] == resolved_id and current_status == resolved_id):
|
if new_status == unread_id or (new_status == resolved_id and current_status == resolved_id):
|
def _changenode(self, props): ''' change the node based on the contents of the form ''' cl = self.db.classes[self.classname] # set status to chatting if 'unread' or 'resolved' try: # determine the id of 'unread','resolved' and 'chatting' unread_id = self.db.status.lookup('unread') resolved_id = self.db.status.lookup('resolved') chatting_id = self.db.status.lookup('chatting') current_status = cl.get(self.nodeid, 'status') except KeyError: pass else: if (props['status'] == unread_id or props['status'] == resolved_id and current_status == resolved_id): props['status'] = chatting_id # add assignedto to the nosy list if props.has_key('assignedto'): assignedto_id = props['assignedto'] if assignedto_id not in props['nosy']: props['nosy'].append(assignedto_id) # create the message message, files = self._handle_message() if message: props['messages'] = cl.get(self.nodeid, 'messages') + [message] if files: props['files'] = cl.get(self.nodeid, 'files') + files # make the changes cl.set(self.nodeid, **props)
|
if props.has_key('assignedto'): assignedto_id = props['assignedto'] if assignedto_id not in props['nosy']: props['nosy'].append(assignedto_id)
|
self._add_assignedto_to_nosy(props)
|
def _changenode(self, props): ''' change the node based on the contents of the form ''' cl = self.db.classes[self.classname] # set status to chatting if 'unread' or 'resolved' try: # determine the id of 'unread','resolved' and 'chatting' unread_id = self.db.status.lookup('unread') resolved_id = self.db.status.lookup('resolved') chatting_id = self.db.status.lookup('chatting') current_status = cl.get(self.nodeid, 'status') except KeyError: pass else: if (props['status'] == unread_id or props['status'] == resolved_id and current_status == resolved_id): props['status'] = chatting_id # add assignedto to the nosy list if props.has_key('assignedto'): assignedto_id = props['assignedto'] if assignedto_id not in props['nosy']: props['nosy'].append(assignedto_id) # create the message message, files = self._handle_message() if message: props['messages'] = cl.get(self.nodeid, 'messages') + [message] if files: props['files'] = cl.get(self.nodeid, 'files') + files # make the changes cl.set(self.nodeid, **props)
|
if props.has_key('assignedto'): assignedto_id = props['assignedto'] if props.has_key('nosy') and assignedto_id not in props['nosy']: props['nosy'].append(assignedto_id) else: props['nosy'] = [assignedto_id]
|
self._add_assignedto_to_nosy(props)
|
def _createnode(self): ''' create a node based on the contents of the form ''' cl = self.db.classes[self.classname] props, dummy = parsePropsFromForm(self.db, cl, self.form)
|
class_description = ""
|
def format(self): return "%(name)s = %(value)s\n" % { "name": self.setting, "value": self.value2str(self._value), }
|
def setuid(user): if not hasattr(os, 'getuid'): return # People can remove this check if they're really determined if user is None: if os.getuid(): return raise ValueError, _("Can't run as root!") if os.getuid(): print _('WARNING: ignoring "-u" argument, not root') try: import pwd except ImportError: raise ValueError, _("Can't change users - no pwd module") try: try: uid = int(user) except ValueError: uid = pwd.getpwnam(user)[2] else: pwd.getpwuid(uid) except KeyError: raise ValueError, _("User %(user)s doesn't exist")%locals() os.setuid(uid)
|
config.add_option( configuration.FilePathOption(config, "trackers", name))
|
config.add_option(TrackerHomeOption(config, "trackers", name))
|
def run(port=undefined, success_message=None): ''' Script entry point - handle args and figure out what to to. ''' # time out after a minute if we can import socket if hasattr(socket, 'setdefaulttimeout'): socket.setdefaulttimeout(60) config = ServerConfig() options = "hvS" if RoundupService: options += 'c' try: (optlist, args) = config.getopt(sys.argv[1:], options, ("help", "version", "save-config",), host="n:", port="p:", group="g:", user="u:", logfile="l:", pidfile="d:", log_hostnames="N") except (getopt.GetoptError), e: #, configuration.ConfigurationError), e: usage(str(e)) return # if running in windows service mode, don't do any other stuff if ("-c", "") in optlist: RoundupService.address = (config.HOST, config.PORT) # XXX why the 1st argument to the service is "-c" # instead of the script name??? return win32serviceutil.HandleCommandLine(RoundupService, argv=["-c"] + args) # add tracker names from command line. # this is done early to let '--save-config' handle the trackers. if args: for arg in args: try: name, home = arg.split('=') except ValueError: raise ValueError, _("Instances must be name=home") config.add_option( configuration.FilePathOption(config, "trackers", name)) config["TRACKERS_" + name.upper()] = home # handle remaining options if optlist: for (opt, arg) in optlist: if opt in ("-h", "--help"): usage() elif opt in ("-v", "--version"): print '%s (python %s)' % (roundup_version, sys.version.split()[0]) elif opt in ("-S", "--save-config"): config.save() print _("Configuration saved to %s") % config.filepath # any of the above options prevent server from running return RoundupRequestHandler.LOG_IPADDRESS = not config.LOG_HOSTNAMES # obtain server before changing user id - allows to use port < # 1024 if started as root try: httpd = server_class((config.HOST, config.PORT), RoundupRequestHandler) except socket.error, e: if e[0] == errno.EADDRINUSE: raise socket.error, \ _("Unable to bind to port %s, port already in use.") \ % config.PORT raise # change user and/or group setgid(config.GROUP) setuid(config.USER) # apply tracker specs for (name, home) in config.trackers(): home = os.path.abspath(home) RoundupRequestHandler.TRACKER_HOMES[name] = home # we don't want the cgi module interpreting the command-line args ;) sys.argv = sys.argv[:1] # fork the server from our parent if a pidfile is specified if config.PIDFILE: if not hasattr(os, 'fork'): print _("Sorry, you can't run the server as a daemon" " on this Operating System") sys.exit(0) else: daemonize(config.PIDFILE) # redirect stdout/stderr to our logfile if config.LOGFILE: # appending, unbuffered sys.stdout = sys.stderr = open(config.LOGFILE, 'a', 0) if success_message: print success_message else: print _('Roundup server started on %(HOST)s:%(PORT)s') \ % config try: httpd.serve_forever() except KeyboardInterrupt: print 'Keyboard Interrupt: exiting'
|
return str(msgid).upper()
|
def translate(self, domain, msgid, mapping=None, context=None, target_language=None, default=None): return str(msgid).upper() def repl(m, mapping=mapping): return ustr(mapping[m.group(m.lastindex)]) cre = re.compile(r'\$(?:(%s)|\{(%s)\})' % (NAME_RE, NAME_RE)) return cre.sub(repl, default or msgid)
|
|
class StaticTranslationService: """Translation service for application default language This service uses "static" translation, with single domain and target language, initialized from OS environment when roundup.i18n is loaded. 'domain' and 'target_language' parameters to 'translate()' are ignored. Returned strings are always utf8-encoded. """ OUTPUT_ENCODING = "utf-8" def translate(self, domain, msgid, mapping=None, context=None, target_language=None, default=None ): _msg = i18n.ugettext(msgid).encode(self.OUTPUT_ENCODING) return _msg translationService = StaticTranslationService()
|
translationService = DummyTranslationService()
|
def repl(m, mapping=mapping): return ustr(mapping[m.group(m.lastindex)])
|
<a href="issue?assignedto=%(userid)s&status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:filter=status,assignedto&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">My Issues</a> |
|
<a href="issue?assignedto=%(userid)s&status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:filter=status,assignedto&:sort=-activity&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">My Issues</a> |
|
def pagehead(self, title, message=None): url = self.env['SCRIPT_NAME'] + '/' machine = self.env['SERVER_NAME'] port = self.env['SERVER_PORT'] if port != '80': machine = machine + ':' + port base = urlparse.urlunparse(('http', machine, url, None, None, None)) if message is not None: message = _('<div class="system-msg">%(message)s</div>')%locals() else: message = '' style = open(os.path.join(self.TEMPLATES, 'style.css')).read() user_name = self.user or '' if self.user == 'admin': admin_links = _(' | <a href="list_classes">Class List</a>' \ ' | <a href="user">User List</a>') else: admin_links = '' if self.user not in (None, 'anonymous'): userid = self.db.user.lookup(self.user) user_info = _('''
|
<a href="issue?status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:filter=status&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">Issues</a>
|
<a href="issue?status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=-activity&:filter=status&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">Issues</a>
|
def pagehead(self, title, message=None): url = self.env['SCRIPT_NAME'] + '/' machine = self.env['SERVER_NAME'] port = self.env['SERVER_PORT'] if port != '80': machine = machine + ':' + port base = urlparse.urlunparse(('http', machine, url, None, None, None)) if message is not None: message = _('<div class="system-msg">%(message)s</div>')%locals() else: message = '' style = open(os.path.join(self.TEMPLATES, 'style.css')).read() user_name = self.user or '' if self.user == 'admin': admin_links = _(' | <a href="list_classes">Class List</a>' \ ' | <a href="user">User List</a>') else: admin_links = '' if self.user not in (None, 'anonymous'): userid = self.db.user.lookup(self.user) user_info = _('''
|
<a href="issue?assignedto=-1&status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:filter=status,assignedto&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">Issues</a>
|
<a href="issue?assignedto=-1&status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=-activity&:filter=status,assignedto&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">Issues</a>
|
def pagehead(self, title, message=None): url = self.env['SCRIPT_NAME'] + '/' machine = self.env['SERVER_NAME'] port = self.env['SERVER_PORT'] if port != '80': machine = machine + ':' + port base = urlparse.urlunparse(('http', machine, url, None, None, None)) if message is not None: message = _('<div class="system-msg">%(message)s</div>')%locals() else: message = '' style = open(os.path.join(self.TEMPLATES, 'style.css')).read() user_name = self.user or '' if self.user == 'admin': admin_links = _(' | <a href="list_classes">Class List</a>' \ ' | <a href="user">User List</a>') else: admin_links = '' if self.user not in (None, 'anonymous'): userid = self.db.user.lookup(self.user) user_info = _('''
|
return
|
return 1
|
def login(self, message=None, newuser_form=None, action='index'): self.pagehead(_('Login to roundup'), message) self.write(_('''
|
return self.login(message=_('No such user "%(name)s"')%locals())
|
action = self.form['__destination_url'].value return self.login(message=_('No such user "%(name)s"')%locals(), action=action)
|
def login_action(self, message=None): if not self.form.has_key('__login_name'): return self.login(message=_('Username required')) self.user = self.form['__login_name'].value if self.form.has_key('__login_password'): password = self.form['__login_password'].value else: password = '' # make sure the user exists try: uid = self.db.user.lookup(self.user) except KeyError: name = self.user self.make_user_anonymous() return self.login(message=_('No such user "%(name)s"')%locals())
|
return self.login(message=_('Incorrect password'))
|
action = self.form['__destination_url'].value return self.login(message=_('Incorrect password'), action=action)
|
def login_action(self, message=None): if not self.form.has_key('__login_name'): return self.login(message=_('Username required')) self.user = self.form['__login_name'].value if self.form.has_key('__login_password'): password = self.form['__login_password'].value else: password = '' # make sure the user exists try: uid = self.db.user.lookup(self.user) except KeyError: name = self.user self.make_user_anonymous() return self.login(message=_('No such user "%(name)s"')%locals())
|
<a href="issue?assignedto=%(userid)s&status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:filter=status,assignedto&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">My Issues</a> | <a href="support?assignedto=%(userid)s&status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:filter=status,assignedto&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername&show_customization=1">My Support</a> |
|
<a href="issue?assignedto=%(userid)s&status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:filter=status,assignedto&:sort=-activity&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">My Issues</a> | <a href="support?assignedto=%(userid)s&status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:filter=status,assignedto&:sort=-activity&:columns=id,activity,status,title,assignedto&:group=customername&show_customization=1">My Support</a> |
|
def pagehead(self, title, message=None): url = self.env['SCRIPT_NAME'] + '/' #self.env.get('PATH_INFO', '/') machine = self.env['SERVER_NAME'] port = self.env['SERVER_PORT'] if port != '80': machine = machine + ':' + port base = urlparse.urlunparse(('http', machine, url, None, None, None)) if message is not None: message = _('<div class="system-msg">%(message)s</div>')%locals() else: message = '' style = open(os.path.join(self.TEMPLATES, 'style.css')).read() user_name = self.user or '' if self.user == 'admin': admin_links = _(' | <a href="list_classes">Class List</a>' \ ' | <a href="user">User List</a>') else: admin_links = '' if self.user not in (None, 'anonymous'): userid = self.db.user.lookup(self.user) user_info = _('''
|
<a href="issue?assignedto=-1&status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:filter=status,assignedto&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">Issues</a>, <a href="support?assignedto=-1&status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:filter=status,assignedto&:columns=id,activity,status,title,assignedto&:group=customername&show_customization=1">Support</a>
|
<a href="issue?assignedto=-1&status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=-activity&:filter=status,assignedto&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">Issues</a>, <a href="support?assignedto=-1&status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=-activity&:filter=status,assignedto&:columns=id,activity,status,title,assignedto&:group=customername&show_customization=1">Support</a>
|
def pagehead(self, title, message=None): url = self.env['SCRIPT_NAME'] + '/' #self.env.get('PATH_INFO', '/') machine = self.env['SERVER_NAME'] port = self.env['SERVER_PORT'] if port != '80': machine = machine + ':' + port base = urlparse.urlunparse(('http', machine, url, None, None, None)) if message is not None: message = _('<div class="system-msg">%(message)s</div>')%locals() else: message = '' style = open(os.path.join(self.TEMPLATES, 'style.css')).read() user_name = self.user or '' if self.user == 'admin': admin_links = _(' | <a href="list_classes">Class List</a>' \ ' | <a href="user">User List</a>') else: admin_links = '' if self.user not in (None, 'anonymous'): userid = self.db.user.lookup(self.user) user_info = _('''
|
"""Usage: %(program)s [-v] [-c] [[-C class] -S field=value]* <instance home> [method]
|
"""Usage: %(program)s [-v] [-c class] [[-C class] -S field=value]* <instance home> [method]
|
def usage(args, message=None): if message is not None: print message print _(
|
optionsList, args = getopt.getopt(argv[1:], 'vcC:S:', ['set=',
|
optionsList, args = getopt.getopt(argv[1:], 'vc:C:S:', ['set=',
|
def main(argv): '''Handle the arguments to the program and initialise environment. ''' # take the argv array and parse it leaving the non-option # arguments in the args array. try: optionsList, args = getopt.getopt(argv[1:], 'vcC:S:', ['set=', 'class=']) except getopt.GetoptError: # print help information and exit: usage(argv) sys.exit(2) for (opt, arg) in optionsList: if opt == '-v': print '%s (python %s)'%(roundup_version, sys.version.split()[0]) return # figure the instance home if len(args) > 0: instance_home = args[0] else: instance_home = os.environ.get('ROUNDUP_INSTANCE', '') if not (instance_home and os.path.isdir(instance_home)): return usage(argv) # get the instance import roundup.instance instance = roundup.instance.open(instance_home) # get a mail handler db = instance.open('admin') # now wrap in try/finally so we always close the database try: if hasattr(instance, 'MailGW'): handler = instance.MailGW(instance, db, optionsList) else: handler = mailgw.MailGW(instance, db, optionsList) # if there's no more arguments, read a single message from stdin if len(args) == 1: return handler.do_pipe() # otherwise, figure what sort of mail source to handle if len(args) < 3: return usage(argv, _('Error: not enough source specification information')) source, specification = args[1:3] # time out net connections after a minute if we can if source not in ('mailbox', 'imaps'): if hasattr(socket, 'setdefaulttimeout'): socket.setdefaulttimeout(60) if source == 'mailbox': return handler.do_mailbox(specification) elif source == 'pop': m = re.match(r'((?P<user>[^:]+)(:(?P<pass>.+))?@)?(?P<server>.+)', specification) if m: return handler.do_pop(m.group('server'), m.group('user'), m.group('pass')) return usage(argv, _('Error: pop specification not valid')) elif source == 'apop': m = re.match(r'((?P<user>[^:]+)(:(?P<pass>.+))?@)?(?P<server>.+)', specification) if m: return handler.do_apop(m.group('server'), m.group('user'), m.group('pass')) return usage(argv, _('Error: apop specification not valid')) elif source == 'imap' or source == 'imaps': m = re.match(r'((?P<user>[^:]+)(:(?P<pass>.+))?@)?(?P<server>.+)', specification) if m: ssl = 0 if source == 'imaps': ssl = 1 mailbox = '' if len(args) > 3: mailbox = args[3] return handler.do_imap(m.group('server'), m.group('user'), m.group('pass'), mailbox, ssl) return usage(argv, _('Error: The source must be either "mailbox",' ' "pop", "apop", "imap" or "imaps"')) finally: # handler might have closed the initial db and opened a new one handler.db.close()
|
if classname != 'file':
|
self.opendb('admin') klass = self.db.getclass(classname) props = klass.getprops() if not pops.has_key('type'):
|
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) if classname != 'file': raise NotFound, designator
|
self.opendb('admin') file = self.db.file mime_type = file.get(nodeid, 'type') content = file.get(nodeid, 'content') lmt = file.get(nodeid, 'activity').timestamp()
|
if not pops.has_key('content'): raise NotFound, designator mime_type = klass.get(nodeid, 'type') content = klass.get(nodeid, 'content') lmt = klass.get(nodeid, 'activity').timestamp()
|
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) if classname != 'file': raise NotFound, designator
|
return pt.render(self, None, None, **args)
|
result = pt.render(self, None, None, **args) self.additional_headers['Content-Type'] = pt.content_type return result
|
def renderContext(self): ''' Return a PageTemplate for the named page ''' name = self.classname extension = self.template pt = Templates(self.instance.config.TEMPLATES).get(name, extension)
|
if self.error_message or self.ok_message: date = time.time() - 1 else: date = time.time() + 5
|
date = time.time() - 1
|
def inner_main(self): '''Process a request.
|
if 'status' not in changed.keys():
|
if not changed.has_key('status'):
|
def shownode(self, message=None): ''' display an item ''' cn = self.classname cl = self.db.classes[cn]
|
m.append(change_note)
|
if change_note: m.append(change_note)
|
def _post_editnode(self, nid, change_note=None): ''' do the linking and message sending part of the node creation ''' cn = self.classname cl = self.db.classes[cn] # link if necessary keys = self.form.keys() for key in keys: if key == ':multilink': value = self.form[key].value if type(value) != type([]): value = [value] for value in value: designator, property = value.split(':') link, nodeid = roundupdb.splitDesignator(designator) link = self.db.classes[link] value = link.get(nodeid, property) value.append(nid) link.set(nodeid, **{property: value}) elif key == ':link': value = self.form[key].value if type(value) != type([]): value = [value] for value in value: designator, property = value.split(':') link, nodeid = roundupdb.splitDesignator(designator) link = self.db.classes[link] link.set(nodeid, **{property: nid})
|
for key in cl.properties.keys():
|
keys = cl.properties.keys() keys.sort() for key in keys:
|
def do_display(self, args): '''Usage: display designator[,designator]* Show the property values for the given node(s).
|
if group is not None and hasattr(os, 'getgid'):
|
if group is not None and hasattr(os, 'getuid'):
|
def run(port=PORT, success_message=None): ''' Script entry point - handle args and figure out what to to. ''' # time out after a minute if we can import socket if hasattr(socket, 'setdefaulttimeout'): socket.setdefaulttimeout(60) hostname = HOSTNAME pidfile = PIDFILE logfile = LOGFILE user = ROUNDUP_USER group = ROUNDUP_GROUP svc_args = None try: # handle the command-line args options = 'n:p:g:u:d:l:hNv' if RoundupService: options += 'c' try: optlist, args = getopt.getopt(sys.argv[1:], options) except getopt.GetoptError, e: usage(str(e)) user = ROUNDUP_USER group = None for (opt, arg) in optlist: if opt == '-n': hostname = arg elif opt == '-v': print '%s (python %s)'%(roundup_version, sys.version.split()[0]) return elif opt == '-p': port = int(arg) elif opt == '-u': user = arg elif opt == '-g': group = arg elif opt == '-d': pidfile = os.path.abspath(arg) elif opt == '-l': logfile = os.path.abspath(arg) elif opt == '-h': usage() elif opt == '-N': RoundupRequestHandler.LOG_IPADDRESS = 0 elif opt == '-c': svc_args = [opt] + args; args = None if svc_args is not None and len(optlist) > 1: raise ValueError, _("windows service option must be the only one") if pidfile and not logfile: raise ValueError, _("logfile *must* be specified if pidfile is") # obtain server before changing user id - allows to use port < # 1024 if started as root address = (hostname, port) try: httpd = server_class(address, RoundupRequestHandler) except socket.error, e: if e[0] == errno.EADDRINUSE: raise socket.error, \ _("Unable to bind to port %s, port already in use." % port) raise if group is not None and hasattr(os, 'getgid'): # if root, setgid to the running user if not os.getgid() and user is not None: try: import pwd except ImportError: raise ValueError, _("Can't change groups - no pwd module") try: gid = pwd.getpwnam(user)[3] except KeyError: raise ValueError,_("Group %(group)s doesn't exist")%locals() os.setgid(gid) elif os.getgid() and user is not None: print _('WARNING: ignoring "-g" argument, not root') if hasattr(os, 'getuid'): # if root, setuid to the running user if not os.getuid() and user is not None: try: import pwd except ImportError: raise ValueError, _("Can't change users - no pwd module") try: uid = pwd.getpwnam(user)[2] except KeyError: raise ValueError, _("User %(user)s doesn't exist")%locals() os.setuid(uid) elif os.getuid() and user is not None: print _('WARNING: ignoring "-u" argument, not root') # People can remove this check if they're really determined if not os.getuid() and user is None: raise ValueError, _("Can't run as root!") # handle tracker specs if args: d = {} for arg in args: try: name, home = arg.split('=') except ValueError: raise ValueError, _("Instances must be name=home") d[name] = os.path.abspath(home) RoundupRequestHandler.TRACKER_HOMES = d except SystemExit: raise except ValueError: usage(error()) except: print error() sys.exit(1) # we don't want the cgi module interpreting the command-line args ;) sys.argv = sys.argv[:1] if pidfile: if not hasattr(os, 'fork'): print _("Sorry, you can't run the server as a daemon" " on this Operating System") sys.exit(0) else: daemonize(pidfile) if svc_args is not None: # don't do any other stuff return win32serviceutil.HandleCommandLine(RoundupService, argv=svc_args) # redirect stdout/stderr to our logfile if logfile: # appending, unbuffered sys.stdout = sys.stderr = open(logfile, 'a', 0) if success_message: print success_message else: print _('Roundup server started on %(address)s')%locals() try: httpd.serve_forever() except KeyboardInterrupt: print 'Keyboard Interrupt: exiting'
|
if not os.getgid() and user is not None: try: import pwd
|
if not os.getuid(): try: import grp
|
def run(port=PORT, success_message=None): ''' Script entry point - handle args and figure out what to to. ''' # time out after a minute if we can import socket if hasattr(socket, 'setdefaulttimeout'): socket.setdefaulttimeout(60) hostname = HOSTNAME pidfile = PIDFILE logfile = LOGFILE user = ROUNDUP_USER group = ROUNDUP_GROUP svc_args = None try: # handle the command-line args options = 'n:p:g:u:d:l:hNv' if RoundupService: options += 'c' try: optlist, args = getopt.getopt(sys.argv[1:], options) except getopt.GetoptError, e: usage(str(e)) user = ROUNDUP_USER group = None for (opt, arg) in optlist: if opt == '-n': hostname = arg elif opt == '-v': print '%s (python %s)'%(roundup_version, sys.version.split()[0]) return elif opt == '-p': port = int(arg) elif opt == '-u': user = arg elif opt == '-g': group = arg elif opt == '-d': pidfile = os.path.abspath(arg) elif opt == '-l': logfile = os.path.abspath(arg) elif opt == '-h': usage() elif opt == '-N': RoundupRequestHandler.LOG_IPADDRESS = 0 elif opt == '-c': svc_args = [opt] + args; args = None if svc_args is not None and len(optlist) > 1: raise ValueError, _("windows service option must be the only one") if pidfile and not logfile: raise ValueError, _("logfile *must* be specified if pidfile is") # obtain server before changing user id - allows to use port < # 1024 if started as root address = (hostname, port) try: httpd = server_class(address, RoundupRequestHandler) except socket.error, e: if e[0] == errno.EADDRINUSE: raise socket.error, \ _("Unable to bind to port %s, port already in use." % port) raise if group is not None and hasattr(os, 'getgid'): # if root, setgid to the running user if not os.getgid() and user is not None: try: import pwd except ImportError: raise ValueError, _("Can't change groups - no pwd module") try: gid = pwd.getpwnam(user)[3] except KeyError: raise ValueError,_("Group %(group)s doesn't exist")%locals() os.setgid(gid) elif os.getgid() and user is not None: print _('WARNING: ignoring "-g" argument, not root') if hasattr(os, 'getuid'): # if root, setuid to the running user if not os.getuid() and user is not None: try: import pwd except ImportError: raise ValueError, _("Can't change users - no pwd module") try: uid = pwd.getpwnam(user)[2] except KeyError: raise ValueError, _("User %(user)s doesn't exist")%locals() os.setuid(uid) elif os.getuid() and user is not None: print _('WARNING: ignoring "-u" argument, not root') # People can remove this check if they're really determined if not os.getuid() and user is None: raise ValueError, _("Can't run as root!") # handle tracker specs if args: d = {} for arg in args: try: name, home = arg.split('=') except ValueError: raise ValueError, _("Instances must be name=home") d[name] = os.path.abspath(home) RoundupRequestHandler.TRACKER_HOMES = d except SystemExit: raise except ValueError: usage(error()) except: print error() sys.exit(1) # we don't want the cgi module interpreting the command-line args ;) sys.argv = sys.argv[:1] if pidfile: if not hasattr(os, 'fork'): print _("Sorry, you can't run the server as a daemon" " on this Operating System") sys.exit(0) else: daemonize(pidfile) if svc_args is not None: # don't do any other stuff return win32serviceutil.HandleCommandLine(RoundupService, argv=svc_args) # redirect stdout/stderr to our logfile if logfile: # appending, unbuffered sys.stdout = sys.stderr = open(logfile, 'a', 0) if success_message: print success_message else: print _('Roundup server started on %(address)s')%locals() try: httpd.serve_forever() except KeyboardInterrupt: print 'Keyboard Interrupt: exiting'
|
raise ValueError, _("Can't change groups - no pwd module") try: gid = pwd.getpwnam(user)[3]
|
raise ValueError, _("Can't change groups - no grp module") try: gid = grp.getgrnam(group)[2]
|
def run(port=PORT, success_message=None): ''' Script entry point - handle args and figure out what to to. ''' # time out after a minute if we can import socket if hasattr(socket, 'setdefaulttimeout'): socket.setdefaulttimeout(60) hostname = HOSTNAME pidfile = PIDFILE logfile = LOGFILE user = ROUNDUP_USER group = ROUNDUP_GROUP svc_args = None try: # handle the command-line args options = 'n:p:g:u:d:l:hNv' if RoundupService: options += 'c' try: optlist, args = getopt.getopt(sys.argv[1:], options) except getopt.GetoptError, e: usage(str(e)) user = ROUNDUP_USER group = None for (opt, arg) in optlist: if opt == '-n': hostname = arg elif opt == '-v': print '%s (python %s)'%(roundup_version, sys.version.split()[0]) return elif opt == '-p': port = int(arg) elif opt == '-u': user = arg elif opt == '-g': group = arg elif opt == '-d': pidfile = os.path.abspath(arg) elif opt == '-l': logfile = os.path.abspath(arg) elif opt == '-h': usage() elif opt == '-N': RoundupRequestHandler.LOG_IPADDRESS = 0 elif opt == '-c': svc_args = [opt] + args; args = None if svc_args is not None and len(optlist) > 1: raise ValueError, _("windows service option must be the only one") if pidfile and not logfile: raise ValueError, _("logfile *must* be specified if pidfile is") # obtain server before changing user id - allows to use port < # 1024 if started as root address = (hostname, port) try: httpd = server_class(address, RoundupRequestHandler) except socket.error, e: if e[0] == errno.EADDRINUSE: raise socket.error, \ _("Unable to bind to port %s, port already in use." % port) raise if group is not None and hasattr(os, 'getgid'): # if root, setgid to the running user if not os.getgid() and user is not None: try: import pwd except ImportError: raise ValueError, _("Can't change groups - no pwd module") try: gid = pwd.getpwnam(user)[3] except KeyError: raise ValueError,_("Group %(group)s doesn't exist")%locals() os.setgid(gid) elif os.getgid() and user is not None: print _('WARNING: ignoring "-g" argument, not root') if hasattr(os, 'getuid'): # if root, setuid to the running user if not os.getuid() and user is not None: try: import pwd except ImportError: raise ValueError, _("Can't change users - no pwd module") try: uid = pwd.getpwnam(user)[2] except KeyError: raise ValueError, _("User %(user)s doesn't exist")%locals() os.setuid(uid) elif os.getuid() and user is not None: print _('WARNING: ignoring "-u" argument, not root') # People can remove this check if they're really determined if not os.getuid() and user is None: raise ValueError, _("Can't run as root!") # handle tracker specs if args: d = {} for arg in args: try: name, home = arg.split('=') except ValueError: raise ValueError, _("Instances must be name=home") d[name] = os.path.abspath(home) RoundupRequestHandler.TRACKER_HOMES = d except SystemExit: raise except ValueError: usage(error()) except: print error() sys.exit(1) # we don't want the cgi module interpreting the command-line args ;) sys.argv = sys.argv[:1] if pidfile: if not hasattr(os, 'fork'): print _("Sorry, you can't run the server as a daemon" " on this Operating System") sys.exit(0) else: daemonize(pidfile) if svc_args is not None: # don't do any other stuff return win32serviceutil.HandleCommandLine(RoundupService, argv=svc_args) # redirect stdout/stderr to our logfile if logfile: # appending, unbuffered sys.stdout = sys.stderr = open(logfile, 'a', 0) if success_message: print success_message else: print _('Roundup server started on %(address)s')%locals() try: httpd.serve_forever() except KeyboardInterrupt: print 'Keyboard Interrupt: exiting'
|
elif os.getgid() and user is not None:
|
elif os.getuid():
|
def run(port=PORT, success_message=None): ''' Script entry point - handle args and figure out what to to. ''' # time out after a minute if we can import socket if hasattr(socket, 'setdefaulttimeout'): socket.setdefaulttimeout(60) hostname = HOSTNAME pidfile = PIDFILE logfile = LOGFILE user = ROUNDUP_USER group = ROUNDUP_GROUP svc_args = None try: # handle the command-line args options = 'n:p:g:u:d:l:hNv' if RoundupService: options += 'c' try: optlist, args = getopt.getopt(sys.argv[1:], options) except getopt.GetoptError, e: usage(str(e)) user = ROUNDUP_USER group = None for (opt, arg) in optlist: if opt == '-n': hostname = arg elif opt == '-v': print '%s (python %s)'%(roundup_version, sys.version.split()[0]) return elif opt == '-p': port = int(arg) elif opt == '-u': user = arg elif opt == '-g': group = arg elif opt == '-d': pidfile = os.path.abspath(arg) elif opt == '-l': logfile = os.path.abspath(arg) elif opt == '-h': usage() elif opt == '-N': RoundupRequestHandler.LOG_IPADDRESS = 0 elif opt == '-c': svc_args = [opt] + args; args = None if svc_args is not None and len(optlist) > 1: raise ValueError, _("windows service option must be the only one") if pidfile and not logfile: raise ValueError, _("logfile *must* be specified if pidfile is") # obtain server before changing user id - allows to use port < # 1024 if started as root address = (hostname, port) try: httpd = server_class(address, RoundupRequestHandler) except socket.error, e: if e[0] == errno.EADDRINUSE: raise socket.error, \ _("Unable to bind to port %s, port already in use." % port) raise if group is not None and hasattr(os, 'getgid'): # if root, setgid to the running user if not os.getgid() and user is not None: try: import pwd except ImportError: raise ValueError, _("Can't change groups - no pwd module") try: gid = pwd.getpwnam(user)[3] except KeyError: raise ValueError,_("Group %(group)s doesn't exist")%locals() os.setgid(gid) elif os.getgid() and user is not None: print _('WARNING: ignoring "-g" argument, not root') if hasattr(os, 'getuid'): # if root, setuid to the running user if not os.getuid() and user is not None: try: import pwd except ImportError: raise ValueError, _("Can't change users - no pwd module") try: uid = pwd.getpwnam(user)[2] except KeyError: raise ValueError, _("User %(user)s doesn't exist")%locals() os.setuid(uid) elif os.getuid() and user is not None: print _('WARNING: ignoring "-u" argument, not root') # People can remove this check if they're really determined if not os.getuid() and user is None: raise ValueError, _("Can't run as root!") # handle tracker specs if args: d = {} for arg in args: try: name, home = arg.split('=') except ValueError: raise ValueError, _("Instances must be name=home") d[name] = os.path.abspath(home) RoundupRequestHandler.TRACKER_HOMES = d except SystemExit: raise except ValueError: usage(error()) except: print error() sys.exit(1) # we don't want the cgi module interpreting the command-line args ;) sys.argv = sys.argv[:1] if pidfile: if not hasattr(os, 'fork'): print _("Sorry, you can't run the server as a daemon" " on this Operating System") sys.exit(0) else: daemonize(pidfile) if svc_args is not None: # don't do any other stuff return win32serviceutil.HandleCommandLine(RoundupService, argv=svc_args) # redirect stdout/stderr to our logfile if logfile: # appending, unbuffered sys.stdout = sys.stderr = open(logfile, 'a', 0) if success_message: print success_message else: print _('Roundup server started on %(address)s')%locals() try: httpd.serve_forever() except KeyboardInterrupt: print 'Keyboard Interrupt: exiting'
|
db = os.path.join(self.dir, 'nodes.%s'%cn) bsddb3.btopen(db, 'n') db = os.path.join(self.dir, 'journals.%s'%cn) bsddb3.btopen(db, 'n')
|
for name in 'nodes.%s'%cn, 'journals.%s'%cn: try: os.remove(os.path.join(self.dir, name)) except os.error, error: if error.errno != errno.ENOENT: raise
|
def clear(self): for cn in self.classes.keys(): db = os.path.join(self.dir, 'nodes.%s'%cn) bsddb3.btopen(db, 'n') db = os.path.join(self.dir, 'journals.%s'%cn) bsddb3.btopen(db, 'n')
|
pretty = interval.pretty() if pretty is None: pretty = value.pretty() return pretty
|
return interval.pretty()
|
def do_reldate(self, property, pretty=0): ''' display a Date property in terms of an interval relative to the current date (e.g. "+ 3w", "- 2d").
|
self.dex = Indexer('test-index')
|
self.dex = Indexer(db)
|
def setUp(self): if os.path.exists('test-index'): shutil.rmtree('test-index') os.mkdir('test-index') os.mkdir('test-index/files') from roundup.backends.indexer_dbm import Indexer self.dex = Indexer('test-index') self.dex.load_index()
|
if os.path.exists('text-index'): shutil.rmtree('text-index')
|
if os.path.exists('test-index'): shutil.rmtree('test-index') os.mkdir('test-index')
|
def setUp(self): if os.path.exists('text-index'): shutil.rmtree('text-index') from roundup.backends.indexer_xapian import Indexer self.dex = Indexer('.')
|
self.dex = Indexer('.')
|
self.dex = Indexer(db)
|
def setUp(self): if os.path.exists('text-index'): shutil.rmtree('text-index') from roundup.backends.indexer_xapian import Indexer self.dex = Indexer('.')
|
shutil.rmtree('text-index')
|
shutil.rmtree('test-index')
|
def tearDown(self): shutil.rmtree('text-index')
|
def stext(self, escape=0):
|
def stext(self, escape=0, hyperlink=1):
|
def stext(self, escape=0): ''' Render the value of the property as StructuredText.
|
s = self.plain(escape=escape)
|
s = self.plain(escape=escape, hyperlink=hyperlink)
|
def stext(self, escape=0): ''' Render the value of the property as StructuredText.
|
def field(self, size = 30):
|
def field(self, **kwargs):
|
def field(self, size = 30): ''' Render the property as a field in HTML.
|
return self.input(name=self._formname,value=value,size=size)
|
kwargs.setdefault("size", 30) kwargs.update({"name": self._formname, "value": value}) return self.input(**kwargs)
|
def field(self, size = 30): ''' Render the property as a field in HTML.
|
for value in self._value: if value not in options: options.insert(0, value)
|
for val in value: if val not in options: options.insert(0, val)
|
def menu(self, size=None, height=None, showid=0, additional=[], **conditions): ''' Render a form select list for this property ''' value = self._value
|
raise TypeError, 'new property "%s" not a string'%key
|
raise TypeError, \ 'new property "%(propname)s" not a string: %(value)r' \ % locals()
|
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 "created" information.
|
self.db.getclass('__sessions').create(sessid=session, user=user,
|
sessions = self.db.getclass('__sessions') self.session = sessions.create(sessid=session, user=user,
|
def set_cookie(self, user, password): # TODO generate a much, much stronger session key ;) session = binascii.b2a_base64(repr(time.time())).strip()
|
print cookie
|
def main(self): '''Wrap the database accesses so we can close the database cleanly ''' # determine the uid to use self.opendb('admin')
|
|
print 'session is', `session`
|
def main(self): '''Wrap the database accesses so we can close the database cleanly ''' # determine the uid to use self.opendb('admin')
|
|
sessid = sessions.lookup(session)
|
self.session = sessions.lookup(session)
|
def main(self): '''Wrap the database accesses so we can close the database cleanly ''' # determine the uid to use self.opendb('admin')
|
sessions.set(sessid, last_use=date.Date())
|
sessions.set(self.session, last_use=date.Date())
|
def main(self): '''Wrap the database accesses so we can close the database cleanly ''' # determine the uid to use self.opendb('admin')
|
ae(filt(None, {}, ('-','deadline'), ('+','priority')), ['2', '4', '1', '3'])
|
def testFilteringDateSortPriorityGroup(self): # '1': '2003-01-01.00:00' 1 => 2 # '2': '2003-02-16.22:50' 3 => 1 # '3': '2003-02-18' 2 => 3 # '4': '2004-03-08' 1 => 2 ae, filt = self.filteringSetup() # ascending ae(filt(None, {}, ('+','deadline'), ('+','priority')), ['2', '1', '4', '3']) ae(filt(None, {}, ('-','deadline'), ('+','priority')), ['2', '4', '1', '3']) # descending ae(filt(None, {}, ('+','deadline'), ('-','priority')), ['3', '1', '4', '2']) ae(filt(None, {}, ('-','deadline'), ('-','priority')), ['3', '4', '1', '2'])
|
|
['3', '1', '4', '2'])
|
['3', '4', '1', '2'])
|
def testFilteringDateSortPriorityGroup(self): # '1': '2003-01-01.00:00' 1 => 2 # '2': '2003-02-16.22:50' 3 => 1 # '3': '2003-02-18' 2 => 3 # '4': '2004-03-08' 1 => 2 ae, filt = self.filteringSetup() # ascending ae(filt(None, {}, ('+','deadline'), ('+','priority')), ['2', '1', '4', '3']) ae(filt(None, {}, ('-','deadline'), ('+','priority')), ['2', '4', '1', '3']) # descending ae(filt(None, {}, ('+','deadline'), ('-','priority')), ['3', '1', '4', '2']) ae(filt(None, {}, ('-','deadline'), ('-','priority')), ['3', '4', '1', '2'])
|
['3', '4', '1', '2'])
|
['4', '3', '2', '1'])
|
def testFilteringDateSortPriorityGroup(self): # '1': '2003-01-01.00:00' 1 => 2 # '2': '2003-02-16.22:50' 3 => 1 # '3': '2003-02-18' 2 => 3 # '4': '2004-03-08' 1 => 2 ae, filt = self.filteringSetup() # ascending ae(filt(None, {}, ('+','deadline'), ('+','priority')), ['2', '1', '4', '3']) ae(filt(None, {}, ('-','deadline'), ('+','priority')), ['2', '4', '1', '3']) # descending ae(filt(None, {}, ('+','deadline'), ('-','priority')), ['3', '1', '4', '2']) ae(filt(None, {}, ('-','deadline'), ('-','priority')), ['3', '4', '1', '2'])
|
if os.path.exists(os.path.join(tracker_home, 'config.py')):
|
config_ini_file = os.path.join(tracker_home, CoreConfig.INI_FILE) if filter(os.path.exists, [config_ini_file, os.path.join(tracker_home, 'config.py'), ]):
|
def do_install(self, tracker_home, args): ""'''Usage: install [template [backend [admin password]]] Install a new Roundup tracker.
|
print _('''
|
print _("""
|
def do_install(self, tracker_home, args): ""'''Usage: install [template [backend [admin password]]] Install a new Roundup tracker.
|
%(config_file)s ... at a minimum, you must set MAILHOST, TRACKER_WEB, MAIL_DOMAIN and ADMIN_EMAIL. If you wish to modify the default schema, you should also edit the database initialisation file:
|
%(config_file)s""") % {"config_file": config_ini_file} need_set = CoreConfig(tracker_home)._get_unset_options() if need_set: print _(" ... at a minimum, you must set following options:") for section, options in need_set.items(): print " [%s]: %s" % (section, ", ".join(options)) print _(""" If you wish to modify the database schema, you should also edit the schema file:
|
def do_install(self, tracker_home, args): ""'''Usage: install [template [backend [admin password]]] Install a new Roundup tracker.
|
''')%{ 'config_file': os.path.join(tracker_home, 'config.py'), 'database_config_file': os.path.join(tracker_home, 'dbinit.py')
|
""") % { 'database_config_file': os.path.join(tracker_home, 'schema.py'), 'database_init_file': os.path.join(tracker_home, 'initial_data.py'),
|
def do_install(self, tracker_home, args): ""'''Usage: install [template [backend [admin password]]] Install a new Roundup tracker.
|
form variable. XXX Used to add a link to new items created during edit. XXX These are collected up and returned in all_links. This will XXX result in an additional linking operation (either Link set or XXX Multilink append) after the edit/create is done using XXX all_props in _editnodes. The <propname> on the current item XXX will be set/appended the id of the newly created item of XXX class <designator> (where <designator> must be XXX <classname>-<N>).
|
form variable. These are collected up and returned in all_links.
|
def parsePropsFromForm(self, num_re=re.compile('^\d+$')): ''' Item properties and their values are edited with html FORM variables and their values. You can:
|
if not all_required.has_key(this): all_required[this] = [] required = all_required[this]
|
propdef = all_propdef[cn]
|
|
if propname in required and value is not None: required.remove(propname)
|
propdef = all_propdef[cn]
|
|
from_address=[], cc=[], bcc=[]):
|
from_address=None, cc=[]):
|
def nosymessage(self, nodeid, msgid, oldvalues, whichnosy='nosy', from_address=[], cc=[], bcc=[]): """Send a message to the members of an issue's nosy list.
|
url_re = re.compile(r'\w{3,6}://\S+') email_re = re.compile(r'[\w\.]+@[\w\.\-]+') designator_re = re.compile(r'([a-z_]+)(\d+)') def _url_repl(self, match): s = match.group(0) return '<a href="%s">%s</a>'%(s, s) def _email_repl(self, match): s = match.group(0) return '<a href="mailto:%s">%s</a>'%(s, s) def _designator_repl(self, match): s = match.group(0) s1 = match.group(1) s2 = match.group(2) try: self._db.getclass(s1) return '<a href="%s">%s %s</a>'%(s, s1, s2) except KeyError: return '%s%s'%(s1, s2)
|
hyper_re = re.compile(r'((?P<url>\w{3,6}://\S+)|' r'(?P<email>[\w\.]+@[\w\.\-]+)|' r'(?P<item>(?P<class>[a-z_]+)(?P<id>\d+)))') def _hyper_repl(self, match): if match.group('url'): s = match.group('url') return '<a href="%s">%s</a>'%(s, s) elif match.group('email'): s = match.group('email') return '<a href="mailto:%s">%s</a>'%(s, s) else: s = match.group('item') s1 = match.group('class') s2 = match.group('id') try: self._db.getclass(s1) return '<a href="%s">%s %s</a>'%(s, s1, s2) except KeyError: return '%s%s'%(s1, s2)
|
def __cmp__(self, other): if isinstance(other, HTMLProperty): return cmp(self._value, other._value) return cmp(self._value, other)
|
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)
|
s = self.hyper_re.sub(self._hyper_repl, s)
|
def plain(self, escape=0, hyperlink=0): ''' 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 = str(self._value) if hyperlink: if not escape: s = cgi.escape(s) 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
|
instance = imp.loa_package('instance', instance_home)
|
instance = imp.load_package('instance', instance_home)
|
def init(instance_home, template, backend, adminpw): ''' initialise an instance using the named template ''' # first, copy the template dir over import roundup.templatebuilder template_dir = os.path.split(__file__)[0] template_name = template template = os.path.join(template_dir, 'templates', template) copytree(template, instance_home) roundup.templatebuilder.installHtmlBase(template_name, instance_home) # now select database db = '''# WARNING: DO NOT EDIT THIS FILE!!!
|
gid = grp.getgrnam(group)[2]
|
try: gid = int(group) except ValueError: gid = grp.getgrnam(group)[2] else: grp.getgrgid(gid)
|
def run(port=PORT, success_message=None): ''' Script entry point - handle args and figure out what to to. ''' # time out after a minute if we can import socket if hasattr(socket, 'setdefaulttimeout'): socket.setdefaulttimeout(60) hostname = HOSTNAME pidfile = PIDFILE logfile = LOGFILE user = ROUNDUP_USER group = ROUNDUP_GROUP svc_args = None try: # handle the command-line args options = 'n:p:g:u:d:l:hNv' if RoundupService: options += 'c' try: optlist, args = getopt.getopt(sys.argv[1:], options) except getopt.GetoptError, e: usage(str(e)) user = ROUNDUP_USER group = None for (opt, arg) in optlist: if opt == '-n': hostname = arg elif opt == '-v': print '%s (python %s)'%(roundup_version, sys.version.split()[0]) return elif opt == '-p': port = int(arg) elif opt == '-u': user = arg elif opt == '-g': group = arg elif opt == '-d': pidfile = os.path.abspath(arg) elif opt == '-l': logfile = os.path.abspath(arg) elif opt == '-h': usage() elif opt == '-N': RoundupRequestHandler.LOG_IPADDRESS = 0 elif opt == '-c': svc_args = [opt] + args; args = None if svc_args is not None and len(optlist) > 1: raise ValueError, _("windows service option must be the only one") if pidfile and not logfile: raise ValueError, _("logfile *must* be specified if pidfile is") # obtain server before changing user id - allows to use port < # 1024 if started as root address = (hostname, port) try: httpd = server_class(address, RoundupRequestHandler) except socket.error, e: if e[0] == errno.EADDRINUSE: raise socket.error, \ _("Unable to bind to port %s, port already in use." % port) raise if group is not None and hasattr(os, 'getuid'): # if root, setgid to the running user if not os.getuid(): try: import grp except ImportError: raise ValueError, _("Can't change groups - no grp module") try: gid = grp.getgrnam(group)[2] except KeyError: raise ValueError,_("Group %(group)s doesn't exist")%locals() os.setgid(gid) elif os.getuid(): print _('WARNING: ignoring "-g" argument, not root') if hasattr(os, 'getuid'): # if root, setuid to the running user if not os.getuid() and user is not None: try: import pwd except ImportError: raise ValueError, _("Can't change users - no pwd module") try: uid = pwd.getpwnam(user)[2] except KeyError: raise ValueError, _("User %(user)s doesn't exist")%locals() os.setuid(uid) elif os.getuid() and user is not None: print _('WARNING: ignoring "-u" argument, not root') # People can remove this check if they're really determined if not os.getuid() and user is None: raise ValueError, _("Can't run as root!") # handle tracker specs if args: d = {} for arg in args: try: name, home = arg.split('=') except ValueError: raise ValueError, _("Instances must be name=home") d[name] = os.path.abspath(home) RoundupRequestHandler.TRACKER_HOMES = d except SystemExit: raise except ValueError: usage(error()) except: print error() sys.exit(1) # we don't want the cgi module interpreting the command-line args ;) sys.argv = sys.argv[:1] if pidfile: if not hasattr(os, 'fork'): print _("Sorry, you can't run the server as a daemon" " on this Operating System") sys.exit(0) else: daemonize(pidfile) if svc_args is not None: # don't do any other stuff return win32serviceutil.HandleCommandLine(RoundupService, argv=svc_args) # redirect stdout/stderr to our logfile if logfile: # appending, unbuffered sys.stdout = sys.stderr = open(logfile, 'a', 0) if success_message: print success_message else: print _('Roundup server started on %(address)s')%locals() try: httpd.serve_forever() except KeyboardInterrupt: print 'Keyboard Interrupt: exiting'
|
uid = pwd.getpwnam(user)[2]
|
try: uid = int(user) except ValueError: uid = pwd.getpwnam(user)[2] else: pwd.getpwuid(uid)
|
def run(port=PORT, success_message=None): ''' Script entry point - handle args and figure out what to to. ''' # time out after a minute if we can import socket if hasattr(socket, 'setdefaulttimeout'): socket.setdefaulttimeout(60) hostname = HOSTNAME pidfile = PIDFILE logfile = LOGFILE user = ROUNDUP_USER group = ROUNDUP_GROUP svc_args = None try: # handle the command-line args options = 'n:p:g:u:d:l:hNv' if RoundupService: options += 'c' try: optlist, args = getopt.getopt(sys.argv[1:], options) except getopt.GetoptError, e: usage(str(e)) user = ROUNDUP_USER group = None for (opt, arg) in optlist: if opt == '-n': hostname = arg elif opt == '-v': print '%s (python %s)'%(roundup_version, sys.version.split()[0]) return elif opt == '-p': port = int(arg) elif opt == '-u': user = arg elif opt == '-g': group = arg elif opt == '-d': pidfile = os.path.abspath(arg) elif opt == '-l': logfile = os.path.abspath(arg) elif opt == '-h': usage() elif opt == '-N': RoundupRequestHandler.LOG_IPADDRESS = 0 elif opt == '-c': svc_args = [opt] + args; args = None if svc_args is not None and len(optlist) > 1: raise ValueError, _("windows service option must be the only one") if pidfile and not logfile: raise ValueError, _("logfile *must* be specified if pidfile is") # obtain server before changing user id - allows to use port < # 1024 if started as root address = (hostname, port) try: httpd = server_class(address, RoundupRequestHandler) except socket.error, e: if e[0] == errno.EADDRINUSE: raise socket.error, \ _("Unable to bind to port %s, port already in use." % port) raise if group is not None and hasattr(os, 'getuid'): # if root, setgid to the running user if not os.getuid(): try: import grp except ImportError: raise ValueError, _("Can't change groups - no grp module") try: gid = grp.getgrnam(group)[2] except KeyError: raise ValueError,_("Group %(group)s doesn't exist")%locals() os.setgid(gid) elif os.getuid(): print _('WARNING: ignoring "-g" argument, not root') if hasattr(os, 'getuid'): # if root, setuid to the running user if not os.getuid() and user is not None: try: import pwd except ImportError: raise ValueError, _("Can't change users - no pwd module") try: uid = pwd.getpwnam(user)[2] except KeyError: raise ValueError, _("User %(user)s doesn't exist")%locals() os.setuid(uid) elif os.getuid() and user is not None: print _('WARNING: ignoring "-u" argument, not root') # People can remove this check if they're really determined if not os.getuid() and user is None: raise ValueError, _("Can't run as root!") # handle tracker specs if args: d = {} for arg in args: try: name, home = arg.split('=') except ValueError: raise ValueError, _("Instances must be name=home") d[name] = os.path.abspath(home) RoundupRequestHandler.TRACKER_HOMES = d except SystemExit: raise except ValueError: usage(error()) except: print error() sys.exit(1) # we don't want the cgi module interpreting the command-line args ;) sys.argv = sys.argv[:1] if pidfile: if not hasattr(os, 'fork'): print _("Sorry, you can't run the server as a daemon" " on this Operating System") sys.exit(0) else: daemonize(pidfile) if svc_args is not None: # don't do any other stuff return win32serviceutil.HandleCommandLine(RoundupService, argv=svc_args) # redirect stdout/stderr to our logfile if logfile: # appending, unbuffered sys.stdout = sys.stderr = open(logfile, 'a', 0) if success_message: print success_message else: print _('Roundup server started on %(address)s')%locals() try: httpd.serve_forever() except KeyboardInterrupt: print 'Keyboard Interrupt: exiting'
|
if hasattr(excClass,'__name__'): excName = excClass.__name__
|
if hasattr(exception, '__name__'): excName = exception.__name__
|
def assertRaisesMessage(self, exception, callable, message, *args, **kwargs): """An extension of assertRaises, which also checks the exception message. We need this because we rely on exception messages when redirecting. """ try: callable(*args, **kwargs) except exception, msg: self.assertEqual(str(msg), message) else: if hasattr(excClass,'__name__'): excName = excClass.__name__ else: excName = str(excClass) raise self.failureException, excName
|
excName = str(excClass)
|
excName = str(exception)
|
def assertRaisesMessage(self, exception, callable, message, *args, **kwargs): """An extension of assertRaises, which also checks the exception message. We need this because we rely on exception messages when redirecting. """ try: callable(*args, **kwargs) except exception, msg: self.assertEqual(str(msg), message) else: if hasattr(excClass,'__name__'): excName = excClass.__name__ else: excName = str(excClass) raise self.failureException, excName
|
url = req.indexargs_href('', {})
|
url = req.indexargs_href('', {})[1:]
|
def searchAction(self, wcre=re.compile(r'[\s,]+')): ''' Mangle some of the form variables.
|
''' Print up an index of the available instances
|
''' Print up an index of the available trackers
|
def index(self): ''' Print up an index of the available instances ''' self.send_response(200) self.send_header('Content-Type', 'text/html') self.end_headers() w = self.wfile.write w(_('<html><head><title>Roundup instances index</title></head>\n')) w(_('<body><h1>Roundup instances index</h1><ol>\n')) for instance in self.TRACKER_HOMES.keys(): w(_('<li><a href="%(instance_url)s/index">%(instance_name)s</a>\n')%{ 'instance_url': urllib.quote(instance), 'instance_name': cgi.escape(instance)}) w(_('</ol></body></html>'))
|
w(_('<html><head><title>Roundup instances index</title></head>\n')) w(_('<body><h1>Roundup instances index</h1><ol>\n')) for instance in self.TRACKER_HOMES.keys(): w(_('<li><a href="%(instance_url)s/index">%(instance_name)s</a>\n')%{ 'instance_url': urllib.quote(instance), 'instance_name': cgi.escape(instance)})
|
w(_('<html><head><title>Roundup trackers index</title></head>\n')) w(_('<body><h1>Roundup trackers index</h1><ol>\n')) keys = self.TRACKER_HOMES.keys() keys.sort() for tracker in keys: w(_('<li><a href="%(tracker_url)s/index">%(tracker_name)s</a>\n')%{ 'tracker_url': urllib.quote(tracker), 'tracker_name': cgi.escape(tracker)})
|
def index(self): ''' Print up an index of the available instances ''' self.send_response(200) self.send_header('Content-Type', 'text/html') self.end_headers() w = self.wfile.write w(_('<html><head><title>Roundup instances index</title></head>\n')) w(_('<body><h1>Roundup instances index</h1><ol>\n')) for instance in self.TRACKER_HOMES.keys(): w(_('<li><a href="%(instance_url)s/index">%(instance_name)s</a>\n')%{ 'instance_url': urllib.quote(instance), 'instance_name': cgi.escape(instance)}) w(_('</ol></body></html>'))
|
instance_name = urllib.unquote(l_path[1]) if self.TRACKER_HOMES.has_key(instance_name): instance_home = self.TRACKER_HOMES[instance_name] instance = roundup.instance.open(instance_home)
|
tracker_name = urllib.unquote(l_path[1]) if self.TRACKER_HOMES.has_key(tracker_name): tracker_home = self.TRACKER_HOMES[tracker_name] tracker = roundup.instance.open(tracker_home)
|
def inner_run_cgi(self): ''' This is the inner part of the CGI handling '''
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.