rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
if not pops.has_key('type'): | if not props.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 not pops.has_key('content'): | if not props.has_key('content'): | 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) |
pt = Templates(self.instance.config.TEMPLATES).get(name, extension) | pt = templating.Templates(self.instance.config.TEMPLATES).get(name, extension) | 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) |
except NoTemplate, message: | except templating.NoTemplate, message: | 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) |
req = HTMLRequest(self) | req = templating.HTMLRequest(self) | def searchAction(self, wcre=re.compile(r'[\s,]+')): ''' Mangle some of the form variables. |
class RoundupService(win32serviceutil.ServiceFramework, RoundupHTTPServer): | class RoundupService(win32serviceutil.ServiceFramework, BaseHTTPServer.HTTPServer): | def error(): exc_type, exc_value = sys.exc_info()[:2] return _('Error: %s: %s' % (exc_type, exc_value)) |
RoundupHTTPServer.__init__(self, self.address, | BaseHTTPServer.HTTPServer.__init__(self, self.address, | def __init__(self, args): # redirect stdout/stderr to our logfile if LOGFILE: # appending, unbuffered sys.stdout = sys.stderr = open(LOGFILE, 'a', 0) win32serviceutil.ServiceFramework.__init__(self, args) RoundupHTTPServer.__init__(self, self.address, RoundupRequestHandler) |
-l: sets a filename to log to (instead of stdout) | -l: sets a filename to log to (instead of stderr / stdout) | def usage(message=''): if RoundupService: win = ''' -c: Windows Service options. If you want to run the server as a Windows Service, you must configure the rest of the options by changing the constants of this program. You will at least configure one tracker in the TRACKER_HOMES variable. This option is mutually exc... |
httpd = RoundupHTTPServer(address, RoundupRequestHandler) | httpd = BaseHTTPServer.HTTPServer(address, RoundupRequestHandler) | 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... |
self.klass, self.property, self.check) | self.klass, self.properties, self.check) | def __repr__(self): return '<Permission 0x%x %r,%r,%r,%r>'%(id(self), self.name, self.klass, self.property, self.check) |
def login(self, message=None): | def login(self, message=None, newuser_form=None): | def login(self, message=None): self.pagehead('Login to roundup', message) self.write(''' |
<td><input name="realname"></td></tr> | <td><input name="realname" value="%(realname)s"></td></tr> | def login(self, message=None): self.pagehead('Login to roundup', message) self.write(''' |
<td><input name="organisation"></td></tr> | <td><input name="organisation" value="%(organisation)s"></td></tr> | def login(self, message=None): self.pagehead('Login to roundup', message) self.write(''' |
<td><input name="address"></td></tr> | <td><input name="address" value="%(address)s"></td></tr> | def login(self, message=None): self.pagehead('Login to roundup', message) self.write(''' |
<td><input name="phone"></td></tr> | <td><input name="phone" value="%(phone)s"></td></tr> | def login(self, message=None): self.pagehead('Login to roundup', message) self.write(''' |
<td><input name="username"></td></tr> | <td><input name="username" value="%(username)s"></td></tr> | def login(self, message=None): self.pagehead('Login to roundup', message) self.write(''' |
<td><input type="password" name="password"></td></tr> | <td><input type="password" name="password" value="%(password)s"></td></tr> | def login(self, message=None): self.pagehead('Login to roundup', message) self.write(''' |
<td><input type="password" name="confirm"></td></tr> | <td><input type="password" name="confirm" value="%(confirm)s"></td></tr> | def login(self, message=None): self.pagehead('Login to roundup', message) self.write(''' |
''') | '''%values) | def login(self, message=None): self.pagehead('Login to roundup', message) self.write(''' |
cl = self.db.classes['user'] props, dummy = parsePropsFromForm(self.db, cl, self.form) uid = cl.create(**props) self.user = self.db.user.get(uid, 'username') password = self.db.user.get(uid, 'password') self.set_cookie(self.user, password) | cl = self.db.user try: props, dummy = parsePropsFromForm(self.db, cl, self.form) uid = cl.create(**props) except ValueError, message: return self.login(message, newuser_form=self.form) self.user = cl.get(uid, 'username') password = cl.get(uid, 'password') self.set_cookie(self.user, self.form['password'].value) | def newuser_action(self, message=None): ''' create a new user based on the contents of the form and then set the cookie ''' # re-open the database as "admin" self.db.close() self.db = self.instance.open('admin') |
env['SCRIPT_NAME'] = '/'.join(self.getPhysicalPath()[:-1]) env['INSTANCE_NAME'] = self.id | import urlparse path = urlparse.urlparse( self.absolute_url() )[2] path_components = path.split( '/' ) if path == "/" : env['SCRIPT_NAME'] = "/" env['INSTANCE_NAME'] = '' else : env['SCRIPT_NAME'] = '/'.join( path_components[:-1] ) env['INSTANCE_NAME'] = path_components[-1] del path_components , path | def _opendb(self): '''Open the roundup instance database for a transaction. ''' instance = roundup.instance.open(self.instance_home) request = RequestWrapper(self.REQUEST['RESPONSE']) env = self.REQUEST.environ env['SCRIPT_NAME'] = '/'.join(self.getPhysicalPath()[:-1]) env['INSTANCE_NAME'] = self.id if env['REQUEST_MET... |
self.assertEqual(keys, ['title', 'status', 'user'], 'wrong prop list') | self.assertEqual(keys, ['fixer', 'status', 'title'], 'wrong prop list') | def testChanges(self): self.db.issue.create(title="spam", status='1') self.db.issue.create(title="eggs", status='2') self.db.issue.create(title="ham", status='4') self.db.issue.create(title="arguments", status='2') self.db.issue.create(title="abuse", status='1') self.db.issue.addprop(fixer=Link("user")) props = self.db... |
raise ValueError, 'Unknown spec %r'%spec | raise ValueError, 'Unknown spec %r' % (spec,) | def __init__(self, spec='.', offset=0, add_granularity=0, translator=i18n): """Construct a date given a specification and a time zone offset. |
if not os.path.isabs(_val): | if _val and not os.path.isabs(_val): | def get(self): _val = Option.get(self) if not os.path.isabs(_val): _val = os.path.join(self.config["TRACKER_HOME"], _val) return _val |
if type(v) is type([]): | if typeof(v) is typeof([]): | def pagefoot(self): if self.debug: self.write('<hr><small><dl>') self.write('<dt><b>Path</b></dt>') self.write('<dd>%s</dd>'%(', '.join(map(repr, self.split_path)))) keys = self.form.keys() keys.sort() if keys: self.write('<dt><b>Form entries</b></dt>') for k in self.form.keys(): v = self.form.getvalue(k, "<empty>") if... |
if type(arg) == type([]): | if typeof(arg) == typeof([]): | def index_arg(self, arg): ''' handle the args to index - they might be a list from the form (ie. submitted from a form) or they might be a command-separated single string (ie. manually constructed GET args) ''' if self.form.has_key(arg): arg = self.form[arg] if type(arg) == type([]): return [arg.value for arg in arg] ... |
if type(value) == type([]): | if typeof(value) == typeof([]): | def index_filterspec(self, filter): ''' pull the index filter spec from the form |
type = cl.get(nodeid, 'type') if type == 'message/rfc822': type = 'text/plain' self.header(headers={'Content-Type': type}) | mimetype = cl.get(nodeid, 'type') if mimetype == 'message/rfc822': mimetype = 'text/plain' self.header(headers={'Content-Type': mimetype}) | def showfile(self): ''' display a file ''' nodeid = self.nodeid cl = self.db.file type = cl.get(nodeid, 'type') if type == 'message/rfc822': type = 'text/plain' self.header(headers={'Content-Type': type}) self.write(cl.get(nodeid, 'content')) |
if type(value) != type([]): value = [value] | if typeof(value) != typeof([]): value = [value] | def _post_editnode(self, nid, changes=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... |
if type(value) != type([]): | if typeof(value) != typeof([]): | def parsePropsFromForm(db, cl, form, nodeid=0): '''Pull properties for the given class out of the form. ''' props = {} changed = [] keys = form.keys() num_re = re.compile('^\d+$') for key in keys: if not cl.properties.has_key(key): continue proptype = cl.properties[key] if isinstance(proptype, hyperdb.String): value = ... |
if self.user is None and not self.ANONYMOUS_REGISTER == 'deny': | if self.user is None and self.ANONYMOUS_REGISTER == 'deny': | def login(self, message=None): self.pagehead('Login to roundup', message) self.write(''' |
return self.index() | return self.login() | def logout(self, message=None): self.make_user_anonymous() # construct the logout cookie path = '/'.join((self.env['SCRIPT_NAME'], self.env['INSTANCE_NAME'], '')) now = Cookie._getdate() self.header({'Set-Cookie': 'roundup_user=deleted; Max-Age=0; expires=%s; Path=%s;'%(now, path)}) return self.index() |
return self.index() elif not path: raise 'ValueError', 'Path not understood' | action = 'index' else: action = path[0] | def main(self, dre=re.compile(r'([^\d]+)(\d+)'), nre=re.compile(r'new(\w+)')): |
action = path[0] | def main(self, dre=re.compile(r'([^\d]+)(\d+)'), nre=re.compile(r'new(\w+)')): | |
user = base64.encodestring('%s:%s'%(self.user, password))[:-1] | user = binascii.b2a_base64('%s:%s'%(self.user, password)).strip() | 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 = '' print self.user, password # make sure th... |
user = base64.encodestring('%s:%s'%(self.user, password))[:-1] | user = binascii.b2a_base64('%s:%s'%(self.user, password)).strip() | def newuser_action(self, message=None): ''' create a new user based on the contents of the form and then set the cookie ''' # re-open the database as "admin" self.db.close() self.db = self.instance.open('admin') |
user, password = base64.decodestring(cookie).split(':') | user, password = binascii.a2b_base64(cookie).split(':') | def main(self, dre=re.compile(r'([^\d]+)(\d+)'), nre=re.compile(r'new(\w+)')): |
print "back_metakit.Class.set - dirty" | def set(self, nodeid, **propvalues): isnew = 0 if propvalues.has_key('#ISNEW'): isnew = 1 del propvalues['#ISNEW'] if not propvalues: return if propvalues.has_key('id'): raise KeyError, '"id" is reserved' if self.db.journaltag is None: raise DatabaseError, 'Database open read-only' view = self.getview(1) # node must e... | |
print "back_metakit.Class.__getview - dirty!" | def __getview(self): db = self.db._db view = db.view(self.classname) if self.db.fastopen: return view.ordered(1) # is the definition the same? mkprops = view.structure() for nm, rutyp in self.ruprops.items(): for mkprop in mkprops: if mkprop.name == nm: break else: mkprop = None if mkprop is None: #print "%s missing pr... | |
hyperdb.String : 'VARCHAR(255)', | hyperdb.String : 'TEXT', | def db_exists(config): """Check if database already exists.""" kwargs = 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 |
def install_demo(home, backend): from roundup import init, instance, password, backends, configuration | from roundup import configuration from roundup.scripts import roundup_server def install_demo(home, backend, template): """Install a demo tracker Parameters: home: tracker home directory path backend: database backend name template: full path to the tracker template directory """ from roundup import init, instance, ... | def install_demo(home, backend): from roundup import init, instance, password, backends, configuration # set up the config for this tracker config = configuration.CoreConfig() config['TRACKER_HOME'] = home config['MAIL_DOMAIN'] = 'localhost' config['DATABASE'] = 'db' if backend in ('mysql', 'postgresql'): config['RDBM... |
init.install(home, os.path.join('templates', 'classic')) | init.install(home, template) | def install_demo(home, backend): from roundup import init, instance, password, backends, configuration # set up the config for this tracker config = configuration.CoreConfig() config['TRACKER_HOME'] = home config['MAIL_DOMAIN'] = 'localhost' config['DATABASE'] = 'db' if backend in ('mysql', 'postgresql'): config['RDBM... |
config.save() | config.save(os.path.join(home, config.INI_FILE)) | def install_demo(home, backend): from roundup import init, instance, password, backends, configuration # set up the config for this tracker config = configuration.CoreConfig() config['TRACKER_HOME'] = home config['MAIL_DOMAIN'] = 'localhost' config['DATABASE'] = 'db' if backend in ('mysql', 'postgresql'): config['RDBM... |
def run_demo(): ''' Run a demo server for users to play with for instant gratification. Sets up the web service on localhost. Disables nosy lists. ''' home = os.path.abspath('demo') backend = 'anydbm' if not os.path.exists(home) or sys.argv[-1] == 'nuke': if len(sys.argv) > 2: backend = sys.argv[-2] install_demo(home,... | def run_demo(home): """Run the demo tracker installed in ``home``""" | def run_demo(): ''' Run a demo server for users to play with for instant gratification. Sets up the web service on localhost. Disables nosy lists. ''' home = os.path.abspath('demo') backend = 'anydbm' if not os.path.exists(home) or sys.argv[-1] == 'nuke': if len(sys.argv) > 2: backend = sys.argv[-2] install_demo(home,... |
cfg = configuration.CoreConfig(home) | def run_demo(): ''' Run a demo server for users to play with for instant gratification. Sets up the web service on localhost. Disables nosy lists. ''' home = os.path.abspath('demo') backend = 'anydbm' if not os.path.exists(home) or sys.argv[-1] == 'nuke': if len(sys.argv) > 2: backend = sys.argv[-2] install_demo(home,... | |
4. Re-initialise the server by running "python demo.py nuke".''' % url | 4. Re-initialise the server by running "python demo.py nuke". ''' % cfg["TRACKER_WEB"] | def run_demo(): ''' Run a demo server for users to play with for instant gratification. Sets up the web service on localhost. Disables nosy lists. ''' home = os.path.abspath('demo') backend = 'anydbm' if not os.path.exists(home) or sys.argv[-1] == 'nuke': if len(sys.argv) > 2: backend = sys.argv[-2] install_demo(home,... |
roundup_server.run(port, success_message) | roundup_server.run(success_message=success_message) def demo_main(): """Run a demo server for users to play with for instant gratification. Sets up the web service on localhost. Disables nosy lists. """ home = os.path.abspath('demo') if not os.path.exists(home) or (sys.argv[-1] == 'nuke'): if len(sys.argv) > 2: backe... | def run_demo(): ''' Run a demo server for users to play with for instant gratification. Sets up the web service on localhost. Disables nosy lists. ''' home = os.path.abspath('demo') backend = 'anydbm' if not os.path.exists(home) or sys.argv[-1] == 'nuke': if len(sys.argv) > 2: backend = sys.argv[-2] install_demo(home,... |
run_demo() | demo_main() | def run_demo(): ''' Run a demo server for users to play with for instant gratification. Sets up the web service on localhost. Disables nosy lists. ''' home = os.path.abspath('demo') backend = 'anydbm' if not os.path.exists(home) or sys.argv[-1] == 'nuke': if len(sys.argv) > 2: backend = sys.argv[-2] install_demo(home,... |
self.debug = 0 | try: self.debug = int(env.get("ROUNDUP_DEBUG", 0)) except ValueError: self.debug = 0 | def __init__(self, instance, request, env): self.instance = instance self.request = request self.env = env self.path = env['PATH_INFO'] self.split_path = self.path.split('/') |
l = [HTMLItem(self._client, self.classname, x) | l = [HTMLItem(self._client, self.classname, id) | def filter(self, request=None, filterspec={}, sort=(None,None), group=(None,None)): ''' Return a list of items from this class, filtered and sorted by the current requested filterspec/filter/sort/group args |
def multilinkGenerator(classname, client, values): id = -1 check = client.db.security.hasPermission userid = client.userid while 1: id += 1 if id >= len(values): raise StopIteration value = values[id] if check('View', userid, classname, itemid=value): yield HTMLItem(client, classname, value) | def multilinkGenerator(classname, client, values): id = -1 check = client.db.security.hasPermission userid = client.userid while 1: id += 1 if id >= len(values): raise StopIteration value = values[id] if check('View', userid, classname, itemid=value): yield HTMLItem(client, classname, value) | |
return multilinkGenerator(self._prop.classname, self._client, self._value) | return self.multilinkGenerator(self._value) | def __iter__(self): ''' iterate and return a new HTMLItem ''' return multilinkGenerator(self._prop.classname, self._client, self._value) |
return multilinkGenerator(self._prop.classname, self._client, l) | return self.multilinkGenerator(l) | def reverse(self): ''' return the list in reverse order ''' l = self._value[:] l.reverse() return multilinkGenerator(self._prop.classname, self._client, l) |
if response.find('is being accessed by other users') == -1: raise RuntimeError, response time.sleep(1) return 0 | msgs = [ 'is being accessed by other users', 'could not serialize access due to concurrent update', ] can_retry = 0 for msg in msgs: if response.find(msg) == -1: can_retry = 1 if can_retry: time.sleep(1) return 0 raise RuntimeError, response | def pg_command(cursor, command): '''Execute the postgresql command, which may be blocked by some other user connecting to the database, and return a true value if it succeeds. ''' try: cursor.execute(command) except psycopg.ProgrammingError, err: response = str(err).split('\n')[0] if response.find('FATAL') != -1: raise... |
prefix = cmdopt['install']['prefix'][1] | prefix = os.path.expanduser(cmdopt['install']['prefix'][1]) | def finalize_options(self): build_scripts.finalize_options(self) cmdopt=self.distribution.command_options |
http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1 | <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | def testNewIssueAuthMsg(self): message = cStringIO.StringIO('''Content-Type: text/plain; |
http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1 | <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | def testSimpleFollowup(self): self.doNewIssue() message = cStringIO.StringIO('''Content-Type: text/plain; |
http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1 | <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | def testFollowup(self): self.doNewIssue() |
http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1 | <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | def testFollowupTitleMatch(self): self.doNewIssue() message = cStringIO.StringIO('''Content-Type: text/plain; |
http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1 | <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | def testFollowupNosyAuthor(self): self.doNewIssue() self.db.config.ADD_AUTHOR_TO_NOSY = 'yes' message = cStringIO.StringIO('''Content-Type: text/plain; |
http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1 | <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | def testFollowupNosyRecipients(self): self.doNewIssue() self.db.config.ADD_RECIPIENTS_TO_NOSY = 'yes' message = cStringIO.StringIO('''Content-Type: text/plain; |
http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1 | <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | def testFollowupNosyAuthorAndCopy(self): self.doNewIssue() self.db.config.ADD_AUTHOR_TO_NOSY = 'yes' self.db.config.MESSAGES_TO_AUTHOR = 'yes' message = cStringIO.StringIO('''Content-Type: text/plain; |
http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1 | <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | def testFollowupNoNosyAuthor(self): self.doNewIssue() self.instance.config.ADD_AUTHOR_TO_NOSY = 'no' message = cStringIO.StringIO('''Content-Type: text/plain; |
http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1 | <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | def testFollowupNoNosyRecipients(self): self.doNewIssue() self.instance.config.ADD_RECIPIENTS_TO_NOSY = 'no' message = cStringIO.StringIO('''Content-Type: text/plain; |
http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1 | <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | def testEnc01(self): self.doNewIssue() message = cStringIO.StringIO('''Content-Type: text/plain; |
http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1 | <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | def testMultipartEnc01(self): self.doNewIssue() message = cStringIO.StringIO('''Content-Type: text/plain; |
http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1 | <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | def testFollowupStupidQuoting(self): self.doNewIssue() |
label = linkcl.get(self._value, k) | value = linkcl.get(self._value, k) | def field(self, showid=0, size=None): ''' Render a form edit field for the property |
label = self._value value = cgi.escape(str(self._value)) | value = self._value value = cgi.escape(str(value)) | def field(self, showid=0, size=None): ''' Render a form edit field for the property |
label, size) | value, size) | def field(self, showid=0, size=None): ''' Render a form edit field for the property |
if not str(e).startswith('No module named %s' % _modules[name]): | if not str(e).startswith('No module named %s' % _modules.get(name, name)): | def have_backend(name): '''Is backend "name" available?''' try: get_backend(name) return 1 except ImportError, e: global _modules if not str(e).startswith('No module named %s' % _modules[name]): raise return 0 |
if num_re.match(entry): l.append(entry) else: try: l.append(cl.lookup(entry)) except (TypeError, KeyError): if fail_ok: l.append(entry) | try: l.append(cl.lookup(entry)) except (TypeError, KeyError): if fail_ok or num_re.match(entry): l.append(entry) | def lookupIds(db, prop, ids, fail_ok=0, num_re=re.compile('^-?\d+$')): ''' "fail_ok" should be specified if we wish to pass through bad values (most likely form values that we wish to represent back to the user) ''' cl = db.getclass(prop.classname) l = [] for entry in ids: if num_re.match(entry): l.append(entry) else: ... |
self.__RW = 0 | def __init__(self, config, journaltag=None): self.config = config self.journaltag = journaltag self.classes = {} self._classes = [] self.dirty = 0 self.__RW = 0 self._db = self.__open() self.indexer = Indexer(self.config.DATABASE) os.umask(0002) | |
self.indexer = Indexer(self.config.DATABASE) | self.indexer = Indexer(self.config.DATABASE, self._db) | def __init__(self, config, journaltag=None): self.config = config self.journaltag = journaltag self.classes = {} self._classes = [] self.dirty = 0 self.__RW = 0 self._db = self.__open() self.indexer = Indexer(self.config.DATABASE) os.umask(0002) |
if self.__RW: self._db.commit() for cl in self.classes.values(): cl._commit() self.indexer.save_index() else: raise RuntimeError, "metakit is open RO" | self._db.commit() for cl in self.classes.values(): cl._commit() self.indexer.save_index() | def commit(self): if self.dirty: if self.__RW: self._db.commit() for cl in self.classes.values(): cl._commit() self.indexer.save_index() else: raise RuntimeError, "metakit is open RO" self.dirty = 0 |
import time now = time.time start = now() | def close(self): import time now = time.time start = now() for cl in self.classes.values(): cl.db = None #self._db.rollback() #print "pre-close cleanup of DB(%d) took %2.2f secs" % (self.__RW, now()-start) self._db = None #print "close of DB(%d) took %2.2f secs" % (self.__RW, now()-start) self.classes = {} try: del _in... | |
try: del _instances[id(self.config)] except KeyError: pass self.__RW = 0 | self.indexer = None | def close(self): import time now = time.time start = now() for cl in self.classes.values(): cl.db = None #self._db.rollback() #print "pre-close cleanup of DB(%d) took %2.2f secs" % (self.__RW, now()-start) self._db = None #print "close of DB(%d) took %2.2f secs" % (self.__RW, now()-start) self.classes = {} try: del _in... |
else: self.__RW = 1 if not self.fastopen: self.__RW = 1 db = metakit.storage(db, self.__RW) | db = metakit.storage(db, 1) | def __open(self): self.dbnm = db = os.path.join(self.config.DATABASE, 'tracker.mk4') self.fastopen = 0 if os.path.exists(db): dbtm = os.path.getmtime(db) pkgnm = self.config.__name__.split('.')[0] schemamod = sys.modules.get(pkgnm+'.dbinit', None) if schemamod: if os.path.exists(schemamod.__file__): schematm = os.path.... |
def isReadOnly(self): return self.__RW == 0 def getWriteAccess(self): if self.journaltag is not None and self.__RW == 0: self._db = None self._db = metakit.storage(self.dbnm, 1) self.__RW = 1 self.hist = self._db.view('history') self.tables = self._db.view('tables') | def isReadOnly(self): return self.__RW == 0 | |
self.db.getWriteAccess() | def setkey(self, propname): if self.keyname: if propname == self.keyname: return raise ValueError, "%s already indexed on %s" % (self.classname, self.keyname) # first setkey for this run self.keyname = propname iv = self.db._db.view('_%s' % self.classname) if self.db.fastopen and iv.structure(): return # very first set... | |
self.db.getWriteAccess() | def addprop(self, **properties): for key in properties.keys(): if self.ruprops.has_key(key): raise ValueError, "%s is already a property of %s" % (key, self.classname) self.ruprops.update(properties) self.db.getWriteAccess() self.db.fastopen = 0 view = self.__getview() self.db.commit() | |
self.db.getWriteAccess() | def __getview(self): db = self.db._db view = db.view(self.classname) mkprops = view.structure() if mkprops and self.db.fastopen: return view.ordered(1) # is the definition the same? for nm, rutyp in self.ruprops.items(): for mkprop in mkprops: if mkprop.name == nm: break else: mkprop = None if mkprop is None: print "%s... | |
if RW and self.db.isReadOnly(): self.db.getWriteAccess() | def getview(self, RW=0): if RW and self.db.isReadOnly(): self.db.getWriteAccess() return self.db._db.view(self.classname).ordered(1) | |
if RW and self.db.isReadOnly(): self.db.getWriteAccess() | def getindexview(self, RW=0): if RW and self.db.isReadOnly(): self.db.getWriteAccess() return self.db._db.view("_%s" % self.classname).ordered(1) | |
remove(fnm) | action1(fnm) | def undo(fnm=nm, action1=os.remove, indexer=self.db.indexer): remove(fnm) |
''' Render a form select list for this property | ''' Render a form <select> list for this property. "size" is used to limit the length of the list labels "height" is used to set the <select> tag's "size" attribute "showid" includes the item ids in the list labels "additional" lists properties which should be included in the label "sort_on" indicates the property to ... | def menu(self, size=None, height=None, showid=0, additional=[], sort_on=None, **conditions): ''' Render a form select list for this property |
env['HTTP_ACCEPT_LANGUAGE'] = self.headers['accept-language'] | env['HTTP_ACCEPT_LANGUAGE'] = self.headers.get('accept-language') | def inner_run_cgi(self): ''' This is the inner part of the CGI handling ''' rest = self.path |
return self.getclass(classname) | try: return self.getclass(classname) except KeyError, msg: raise AttributeError, str(msg) | def __getattr__(self, classname): if classname == 'transactions': return self.dirty # fall back on the classes return self.getclass(classname) |
self_value = display_value | self._value = display_value | def __init__(self, *args, **kwargs): HTMLProperty.__init__(self, *args, **kwargs) if self._value: display_value = lookupIds(self._db, self._prop, self._value, fail_ok=1) sortfun = make_sort_function(self._db, self._prop.classname) # sorting fails if the value contains # items not yet stored in the database # ignore the... |
return cl.parsePropsFromForm() | return cl.parsePropsFromForm(create=1) | def parseForm(self, form, classname='test', nodeid=None): cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, makeForm(form)) cl.classname = classname cl.nodeid = nodeid cl.db = self.db return cl.parsePropsFromForm() |
self.assertEqual(cl.parsePropsFromForm(), | self.assertEqual(cl.parsePropsFromForm(create=1), | def testMixedMultilink(self): form = cgi.FieldStorage() form.list.append(cgi.MiniFieldStorage('nosy', '1,2')) form.list.append(cgi.MiniFieldStorage('nosy', '3')) cl = client.Client(self.instance, None, {'PATH_INFO':'/'}, form) cl.classname = 'issue' cl.nodeid = None cl.db = self.db self.assertEqual(cl.parsePropsFromFor... |
return '<a class="classhelp" href="javascript:help_window(\'%s?'\ '@startwith=0&@template=help&properties=%s%s%s\', \'%s\', \ \'%s\')">%s</a>'%(self.classname, properties, property, form, width, height, self._(label)) | help_url = "%s?@startwith=0&@template=help&"\ "properties=%s%s%s" % \ (self.classname, properties, property, form) onclick = "javascript:help_window('%s', '%s', '%s');return false;" % \ (help_url, width, height) return '<a class="classhelp" href="%s" onclick="%s">%s</a>' % \ (help_url, onclick, self._(label)) | def classhelp(self, properties=None, label=''"(list)", width='500', height='400', property='', form='itemSynopsis'): '''Pop up a javascript window with class help |
return __import__('back_%s'%name, globals()) | vars = globals() if vars.has_key(name): return vars[name] module_name = 'back_%s' % name try: module = __import__(module_name, vars) except: del sys.modules['.'.join((__name__, module_name))] del vars[module_name] raise else: vars[name] = module return module | def get_backend(name): '''Get a specific backend by name.''' return __import__('back_%s'%name, globals()) |
module = _modules.get(name, name) | def have_backend(name): '''Is backend "name" available?''' module = _modules.get(name, name) try: get_backend(name) return 1 except ImportError, e: if not str(e).startswith('No module named %s'%module): raise return 0 | |
if not str(e).startswith('No module named %s'%module): | global _modules if not str(e).startswith('No module named %s' % _modules[name]): | def have_backend(name): '''Is backend "name" available?''' module = _modules.get(name, name) try: get_backend(name) return 1 except ImportError, e: if not str(e).startswith('No module named %s'%module): raise return 0 |
pt.pt_edit(open(src).read(), mimetypes.guess_type(filename)) | content_type = mimetypes.guess_type(filename)[0] or 'text/html' pt.pt_edit(open(src).read(), content_type) | def get(self, name, extension=None): ''' Interface to get a template, possibly loading a compiled template. |
find_template(self._db.config.TEMPLATES, | template = find_template(self._db.config.TEMPLATES, | def history(self, direction='descending', dre=re.compile('\d+')): l = ['<table class="history">' '<tr><th colspan="4" class="header">', _('History'), '</th></tr><tr>', _('<th>Date</th>'), _('<th>User</th>'), _('<th>Action</th>'), _('<th>Args</th>'), '</tr>'] current = {} comments = {} history = self._klass.history(self... |
if prop is not None: if args[k] and (isinstance(prop, hyperdb.Multilink) or isinstance(prop, hyperdb.Link)): classname = prop.classname try: linkcl = self._db.getclass(classname) except KeyError: labelprop = None comments[classname] = _('''The linked class %(classname)s no longer exists''')%locals() labelprop = linkcl... | if prop is None: comments['no_exist'] = _('''<em>The indicated property no longer exists</em>''') cell.append('<em>%s: %s</em>\n'%(k, str(args[k]))) continue if args[k] and (isinstance(prop, hyperdb.Multilink) or isinstance(prop, hyperdb.Link)): classname = prop.classname try: linkcl = self._db.getclass(classname) e... | def history(self, direction='descending', dre=re.compile('\d+')): l = ['<table class="history">' '<tr><th colspan="4" class="header">', _('History'), '</th></tr><tr>', _('<th>Date</th>'), _('<th>User</th>'), _('<th>Action</th>'), _('<th>Args</th>'), '</tr>'] current = {} comments = {} history = self._klass.history(self... |
label = linkcl.get(args[k], labelprop) | if labelprop is not None and \ labelprop != 'id': label = linkcl.get(linkid, labelprop) | def history(self, direction='descending', dre=re.compile('\d+')): l = ['<table class="history">' '<tr><th colspan="4" class="header">', _('History'), '</th></tr><tr>', _('<th>Date</th>'), _('<th>User</th>'), _('<th>Action</th>'), _('<th>Args</th>'), '</tr>'] current = {} comments = {} history = self._klass.history(self... |
cell.append(' <strike>%s</strike>,\n'%label) label = None if label is not None: if hrefable: old = '<a href="%s%s">%s</a>'%(classname, args[k], label) | subml.append('<strike>%s</strike>'%label) | def history(self, direction='descending', dre=re.compile('\d+')): l = ['<table class="history">' '<tr><th colspan="4" class="header">', _('History'), '</th></tr><tr>', _('<th>Date</th>'), _('<th>User</th>'), _('<th>Action</th>'), _('<th>Args</th>'), '</tr>'] current = {} comments = {} history = self._klass.history(self... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.