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_FILE...
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") table...
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 AU...
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, t...
<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('r...
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('r...
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 ValueErro...
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: (opt...
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 string...
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">...
<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">...
<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">...
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 ...
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 ...
<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,chatti...
<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,chatt...
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: messa...
<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-progre...
<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-progr...
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: messa...
"""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: usa...
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 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 = ROUND...
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 = ROUND...
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 = ROUND...
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 = ROUND...
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, {}...
['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, {}...
['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, {}...
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...
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 ...
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_r...
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">...
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._val...
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(templa...
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 = ROUND...
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 = ROUND...
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:...
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:...
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 sel...
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(tr...
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 sel...
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 '''