bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def undoable_transactions(self, AUTHENTICATION_PATH=None, first_transaction=None, last_transaction=None):
|
def undoable_transactions(self, AUTHENTICATION_PATH=None, first_transaction=None, last_transaction=None):
| 4,100
|
def undoable_transactions(self, AUTHENTICATION_PATH=None, first_transaction=None, last_transaction=None):
|
def undoable_transactions(self, AUTHENTICATION_PATH=None, first_transaction=None, last_transaction=None):
| 4,101
|
def emitStartElement(self, name, attrlist, taldict, metaldict, position=(None, None), isend=0): if not taldict and not metaldict: # Handle the simple, common case self.emitStartTag(name, attrlist, isend) self.todoPush({}) if isend: self.emitEndElement(name, isend) return
|
def emitStartElement(self, name, attrlist, taldict, metaldict, position=(None, None), isend=0): if not taldict and not metaldict: # Handle the simple, common case self.emitStartTag(name, attrlist, isend) self.todoPush({}) if isend: self.emitEndElement(name, isend) return
| 4,102
|
def emitStartElement(self, name, attrlist, taldict, metaldict, position=(None, None), isend=0): if not taldict and not metaldict: # Handle the simple, common case self.emitStartTag(name, attrlist, isend) self.todoPush({}) if isend: self.emitEndElement(name, isend) return
|
def emitStartElement(self, name, attrlist, taldict, metaldict, position=(None, None), isend=0): if not taldict and not metaldict: # Handle the simple, common case self.emitStartTag(name, attrlist, isend) self.todoPush({}) if isend: self.emitEndElement(name, isend) return
| 4,103
|
def tutorialShowLesson(self, id, REQUEST): """ Navigate management frame to a given lesson's screen. """ url=self.lessonURL(id, REQUEST) if not url: return """\
|
def tutorialShowLesson(self, id, REQUEST): """ Navigate management frame to a given lesson's screen. """ url=self.lessonURL(id, REQUEST) if not url or not self.checkInstallation(REQUEST): REQUEST.set('hide_next', 0) return """\
| 4,104
|
def index_object(self, i, obj, threshold=None): """ index and object 'obj' with integer id 'i'""" index = self._index unindex = self._unindex
|
def index_object(self, i, obj, threshold=None): """ index and object 'obj' with integer id 'i'""" index = self._index unindex = self._unindex
| 4,105
|
def index_object(self, i, obj, threshold=None): """ index and object 'obj' with integer id 'i'""" index = self._index unindex = self._unindex
|
def index_object(self, i, obj, threshold=None): """ index and object 'obj' with integer id 'i'""" index = self._index unindex = self._unindex
| 4,106
|
def index_object(self, i, obj, threshold=None): """ index and object 'obj' with integer id 'i'""" index = self._index unindex = self._unindex
|
def index_object(self, i, obj, threshold=None): """ index and object 'obj' with integer id 'i'""" index = self._index unindex = self._unindex
| 4,107
|
def _apply_index(self, request, cid=''): """Apply the index to query parameters given in the argument, request
|
def _apply_index(self, request, cid=''): """Apply the index to query parameters given in the argument, request
| 4,108
|
def _apply_index(self, request, cid=''): """Apply the index to query parameters given in the argument, request
|
def _apply_index(self, request, cid=''): """Apply the index to query parameters given in the argument, request
| 4,109
|
def _apply_index(self, request, cid=''): """Apply the index to query parameters given in the argument, request
|
def _apply_index(self, request, cid=''): """Apply the index to query parameters given in the argument, request
| 4,110
|
def _apply_index(self, request, cid=''): """Apply the index to query parameters given in the argument, request
|
def _apply_index(self, request, cid=''): """Apply the index to query parameters given in the argument, request
| 4,111
|
def _apply_index(self, request, cid=''): """Apply the index to query parameters given in the argument, request
|
def _apply_index(self, request, cid=''): """Apply the index to query parameters given in the argument, request
| 4,112
|
def _get_id(ob, id): try: ob=ob.aq_base except: pass n=0 if (len(id) > 8) and (id[8:]=='copy_of_'): n=1 while (hasattr(ob, id)): id='copy%s_of_%s' % (n and n+1 or '', id) n=n+1 return id
|
def _get_id(ob, id): try: ob=ob.aq_base except: pass n=0 if (len(id) > 8) and (id[8:]=='copy_of_'): n=1 while (hasattr(ob, id)): id='copy%s_of_%s' % (n and n+1 or '', orig_id) n=n+1 return id
| 4,113
|
def pt_render(self, source=0, extra_context={}): """Render this Page Template""" if self._v_errors: raise RuntimeError, 'Page Template %s has errors.' % self.id output = StringIO() c = self.pt_getContext() c.update(extra_context) if __debug__: __traceback_info__ = pprint.pformat(c)
|
def pt_render(self, source=0, extra_context={}): """Render this Page Template""" if self._v_errors: raise RuntimeError, 'Page Template %s has errors.' % self.id output = StringIO() c = self.pt_getContext() c.update(extra_context) if Z_DEBUG_MODE: __traceback_info__ = pprint.pformat(c)
| 4,114
|
def manage_move_objects_up(self, REQUEST, ids=None, delta=None): """ Move specified sub-objects up by delta in container. """ if ids: try: attempt = self.moveObjectsUp(ids, delta) message = '%d item%s moved up.' % ( attempt, ( (attempt!=1) and 's' or '' ) ) except ValueError, errmsg: message = 'Error: %s' % (errmsg) else: message = 'Error: No items were specified!' return self.manage_main(self, REQUEST, skey='position', manage_tabs_message=message)
|
def manage_move_objects_up(self, REQUEST, ids=None, delta=1): """ Move specified sub-objects up by delta in container. """ if ids: try: attempt = self.moveObjectsUp(ids, delta) message = '%d item%s moved up.' % ( attempt, ( (attempt!=1) and 's' or '' ) ) except ValueError, errmsg: message = 'Error: %s' % (errmsg) else: message = 'Error: No items were specified!' return self.manage_main(self, REQUEST, skey='position', manage_tabs_message=message)
| 4,115
|
def manage_move_objects_down(self, REQUEST, ids=None, delta=None): """ Move specified sub-objects down by delta in container. """ if ids: try: attempt = self.moveObjectsDown(ids, delta) message = '%d item%s moved down.' % ( attempt, ( (attempt!=1) and 's' or '' ) ) except ValueError, errmsg: message = 'Error: %s' % (errmsg) else: message = 'Error: No items were specified!' return self.manage_main(self, REQUEST, skey='position', manage_tabs_message=message)
|
def manage_move_objects_down(self, REQUEST, ids=None, delta=1): """ Move specified sub-objects down by delta in container. """ if ids: try: attempt = self.moveObjectsDown(ids, delta) message = '%d item%s moved down.' % ( attempt, ( (attempt!=1) and 's' or '' ) ) except ValueError, errmsg: message = 'Error: %s' % (errmsg) else: message = 'Error: No items were specified!' return self.manage_main(self, REQUEST, skey='position', manage_tabs_message=message)
| 4,116
|
def publish(request, module_name, after_list, debug=0, # Optimize: call_object=call_object, missing_name=missing_name, dont_publish_class=dont_publish_class, mapply=mapply, ): (bobo_before, bobo_after, object, realm, debug_mode, err_hook, validated_hook, transactions_manager)= get_module_info(module_name) parents=None try: request.processInputs() request_get=request.get response=request.response # First check for "cancel" redirect: cancel='' if request_get('SUBMIT','').strip().lower()=='cancel': cancel=request_get('CANCEL_ACTION','') if cancel: raise 'Redirect', cancel after_list[0]=bobo_after if debug_mode: response.debug_mode=debug_mode if realm and not request.get('REMOTE_USER',None): response.realm=realm if bobo_before is not None: bobo_before() # Get a nice clean path list: path=request_get('PATH_INFO').strip() request['PARENTS']=parents=[object] if transactions_manager: transactions_manager.begin() object=request.traverse(path, validated_hook=validated_hook) if transactions_manager: transactions_manager.recordMetaData(object, request) result=mapply(object, request.args, request, call_object,1, missing_name, dont_publish_class, request, bind=1) if result is not response: response.setBody(result) if transactions_manager: transactions_manager.commit() return response except: if transactions_manager: transactions_manager.abort() # DM: provide nicer error message for FTP try: sm= response.setMessage except: sm= None if sm is not None: from ZServer.medusa.asyncore import compact_traceback cl,val= sys.exc_info()[:2] sm('%s: %s %s' % (getattr(cl,'__name__',cl), val, debug_mode and compact_traceback()[-1] or '')) if err_hook is not None: if parents: parents=parents[0] try: return err_hook(parents, request, sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2], ) except Retry: # We need to try again.... if not request.supports_retry(): return err_hook(parents, request, sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2], ) newrequest=request.retry() request.close() # Free resources held by the request. try: return publish(newrequest, module_name, after_list, debug) finally: newrequest.close() else: raise
|
def publish(request, module_name, after_list, debug=0, # Optimize: call_object=call_object, missing_name=missing_name, dont_publish_class=dont_publish_class, mapply=mapply, ): (bobo_before, bobo_after, object, realm, debug_mode, err_hook, validated_hook, transactions_manager)= get_module_info(module_name) parents=None try: request.processInputs() request_get=request.get response=request.response # First check for "cancel" redirect: cancel='' if request_get('SUBMIT','').strip().lower()=='cancel': cancel=request_get('CANCEL_ACTION','') if cancel: raise 'Redirect', cancel after_list[0]=bobo_after if debug_mode: response.debug_mode=debug_mode if realm and not request.get('REMOTE_USER',None): response.realm=realm if bobo_before is not None: bobo_before() # Get a nice clean path list: path=request_get('PATH_INFO').strip() request['PARENTS']=parents=[object] if transactions_manager: transactions_manager.begin() object=request.traverse(path, validated_hook=validated_hook) if transactions_manager: transactions_manager.recordMetaData(object, request) result=mapply(object, request.args, request, call_object,1, missing_name, dont_publish_class, request, bind=1) if result is not response: response.setBody(result) if transactions_manager: transactions_manager.commit() return response except: if transactions_manager: transactions_manager.abort() # DM: provide nicer error message for FTP sm = None if response is not None: sm = getattr(response, "setMessage", None) if sm is not None: from ZServer.medusa.asyncore import compact_traceback cl,val= sys.exc_info()[:2] sm('%s: %s %s' % (getattr(cl,'__name__',cl), val, debug_mode and compact_traceback()[-1] or '')) if err_hook is not None: if parents: parents=parents[0] try: return err_hook(parents, request, sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2], ) except Retry: # We need to try again.... if not request.supports_retry(): return err_hook(parents, request, sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2], ) newrequest=request.retry() request.close() # Free resources held by the request. try: return publish(newrequest, module_name, after_list, debug) finally: newrequest.close() else: raise
| 4,117
|
def __iadd__(self, other): return self.__class__(self.value + other)
|
def __iadd__(self, other): return self.__class__(self.value + other)
| 4,118
|
def __iadd__(self, other): return self.__class__(self.value + other)
|
def __iadd__(self, other): return self.__class__(self.value + other)
| 4,119
|
def emitDefines(self, defines, position): for part in splitParts(defines): m = re.match( r"\s*(?:(global|local)\s+)?(%s)\s+(.*)" % NAME_RE, part) if not m: raise TALError("invalid define syntax: " + `part`, position) scope, name, expr = m.group(1, 2, 3) scope = scope or "local" cexpr = self.compileExpression(expr) if scope == "local": self.emit("setLocal", name, cexpr) else: self.emit("setGlobal", name, cexpr)
|
def emitDefines(self, defines, position): for part in splitParts(defines): m = re.match( r"(?s)\s*(?:(global|local)\s+)?(%s)\s+(.*)\Z" % NAME_RE, part) if not m: raise TALError("invalid define syntax: " + `part`, position) scope, name, expr = m.group(1, 2, 3) scope = scope or "local" cexpr = self.compileExpression(expr) if scope == "local": self.emit("setLocal", name, cexpr) else: self.emit("setGlobal", name, cexpr)
| 4,120
|
def emitRepeat(self, arg): m = re.match("\s*(%s)\s+(.*)" % NAME_RE, arg) if not m: raise TALError("invalid repeat syntax: " + `repeat`) name, expr = m.group(1, 2) cexpr = self.compileExpression(expr) program = self.popProgram() self.emit("loop", name, cexpr, program)
|
def emitRepeat(self, arg): m = re.match("(?s)\s*(%s)\s+(.*)\Z" % NAME_RE, arg) if not m: raise TALError("invalid repeat syntax: " + `repeat`) name, expr = m.group(1, 2) cexpr = self.compileExpression(expr) program = self.popProgram() self.emit("loop", name, cexpr, program)
| 4,121
|
def _error_html(self,title,body): # XXX could this try to use standard_error_message somehow? return ("""\
|
def _error_html(self,title,body): # XXX could this try to use standard_error_message somehow? return ("""\
| 4,122
|
def getPhysicalPath(self): '''Returns a path (an immutable sequence of strings) that can be used to access this object again later, for example in a copy/paste operation. getPhysicalRoot() and getPhysicalPath() are designed to operate together. ''' path = (self.getId(),) p = aq_parent(aq_inner(self) if p is not None: path = p.getPhysicalPath() + path
|
def getPhysicalPath(self): '''Returns a path (an immutable sequence of strings) that can be used to access this object again later, for example in a copy/paste operation. getPhysicalRoot() and getPhysicalPath() are designed to operate together. ''' path = (self.getId(),) p = aq_parent(aq_inner(self)) if p is not None: path = p.getPhysicalPath() + path
| 4,123
|
def testSetupServersWithConflict(self): conf = self.load_config_text(""" <http-server> address 18092 </http-server> <ftp-server> address 18092 # conflict </ftp-server>""") starter = ZopeStarter(conf) # do the job the 'handler' would have done (call prepare) for server in conf.servers: server.prepare('', None, 'Zope', {}, None) try: self.assertRaises(ZConfig.ConfigurationError, starter.setupServers) finally: del conf.servers
|
def testSetupServersWithConflict(self): conf = self.load_config_text(""" <http-server> address 18092 </http-server> <ftp-server> address 18092 # conflict </ftp-server>""") starter = ZopeStarter(conf) # do the job the 'handler' would have done (call prepare) for server in conf.servers: server.prepare('', None, 'Zope', {}, None) try: self.assertRaises(ZConfig.ConfigurationError, starter.setupServers) finally: del conf.servers
| 4,124
|
def _cook_check(self): if self._v_last_read and not DevelopmentMode: return __traceback_info__ = self.filename try: mtime=os.stat(self.filename)[8] except: mtime=0 if hasattr(self, '_v_program') and mtime == self._v_last_read: return self.pt_edit(open(self.filename), None) self._cook() if self._v_errors: LOG('PageTemplateFile', ERROR, 'Error in template', '\n'.join(self._v_errors)) return self._v_last_read = mtime
|
def _cook_check(self): if self._v_last_read and not DevelopmentMode: return __traceback_info__ = self.filename try: mtime = os.path.getmtime(self.filename) except OSError: mtime = 0 if self._v_program is not None and mtime == self._v_last_read: return self.pt_edit(open(self.filename), None) self._cook() if self._v_errors: LOG('PageTemplateFile', ERROR, 'Error in template', '\n'.join(self._v_errors)) return self._v_last_read = mtime
| 4,125
|
def __bobo_traverse__(self, REQUEST, name): if name[-9:]=='__draft__': return getattr(self, name)
|
def __bobo_traverse__(self, REQUEST, name): if name[-9:]=='__draft__': return getattr(self, name)
| 4,126
|
def nonempty(self): try: db=self._jar.db() except: # BoboPOS 2 return Globals.VersionBase[self._version].nonempty() else: # ZODB 3 return not db.versionEmpty(self._version)
|
def nonempty(self): try: db=self._p_jar.db() except: # BoboPOS 2 return Globals.VersionBase[self._version].nonempty() else: # ZODB 3 return not db.versionEmpty(self._version)
| 4,127
|
def manage_Save__draft__(self, remark, REQUEST=None): """Make version changes permanent""" try: db=self._jar.db() except: # BoboPOS 2 Globals.VersionBase[self._version].commit(remark) else: # ZODB 3 s=self._version d=self._p_jar.getVersion() if d==s: d='' db.commitVersion(s, d) if REQUEST: REQUEST['RESPONSE'].redirect(REQUEST['URL2']+'/manage_main')
|
def manage_Save__draft__(self, remark, REQUEST=None): """Make version changes permanent""" try: db=self._p_jar.db() except: # BoboPOS 2 Globals.VersionBase[self._version].commit(remark) else: # ZODB 3 s=self._version d=self._p_jar.getVersion() if d==s: d='' db.commitVersion(s, d) if REQUEST: REQUEST['RESPONSE'].redirect(REQUEST['URL2']+'/manage_main')
| 4,128
|
def manage_Discard__draft__(self, REQUEST=None): 'Discard changes made during the version' try: db=self._jar.db() except: # BoboPOS 2 Globals.VersionBase[self._version].abort() else: # ZODB 3 db.abortVersion(self._version)
|
def manage_Discard__draft__(self, REQUEST=None): 'Discard changes made during the version' try: db=self._p_jar.db() except: # BoboPOS 2 Globals.VersionBase[self._version].abort() else: # ZODB 3 db.abortVersion(self._version)
| 4,129
|
def authorize(self, user, accessed, container, name, value, roles): user = getattr(user, 'aq_base', user).__of__(self) newSecurityManager(None, user) security = getSecurityManager() try: try: if security.validate(accessed, container, name, value, roles): return 1 except: noSecurityManager() raise except Unauthorized: pass return 0
|
def authorize(self, user, accessed, container, name, value, roles): user = getattr(user, 'aq_base', user).__of__(self) newSecurityManager(None, user) security = getSecurityManager() try: try: if roles is _noroles: if security.validate(accessed, container, name, value): return 1 else: if security.validate(accessed, container, name, value, roles): return 1 except: noSecurityManager() raise except Unauthorized: pass return 0
| 4,130
|
def __init__(self,*args): """Return a new date-time object
|
def __init__(self,*args): """Return a new date-time object
| 4,131
|
def forkit(attempts = FORK_ATTEMPTS): while attempts: # if at first you don't succeed... attempts = attempts + 1 try: pid = os.fork() except os.error: pstamp('Houston, the fork failed') time.sleep(2) else: pstamp('Houston, we have forked') return pid
|
def forkit(attempts = FORK_ATTEMPTS): while attempts: # if at first you don't succeed... attempts = attempts - 1 try: pid = os.fork() except os.error: pstamp('Houston, the fork failed') time.sleep(2) else: pstamp('Houston, we have forked') return pid
| 4,132
|
def get(self, key, default): """Get a variable value
|
def get(self, key, default=None): """Get a variable value
| 4,133
|
def main(args=None): # This is exactly like zdctl.main(), but uses ZopeCtlOptions and # ZopeCmd instead of ZDCtlOptions and ZDCmd, so the default values # are handled properly for Zope. options = ZopeCtlOptions() options.realize(args) c = ZopeCmd(options) if options.args: c.onecmd(" ".join(options.args)) else: options.interactive = 1 if options.interactive: try: import readline except ImportError: pass print "program:", " ".join(options.program) c.do_status() c.cmdloop()
|
def main(args=None): # This is exactly like zdctl.main(), but uses ZopeCtlOptions and # ZopeCmd instead of ZDCtlOptions and ZDCmd, so the default values # are handled properly for Zope. options = ZopeCtlOptions() options.realize(args) c = ZopeCmd(options) if options.args: c.onecmd(" ".join(options.args)) else: options.interactive = 1 if options.interactive: try: import readline except ImportError: pass print "program:", " ".join(options.program) c.do_status() c.cmdloop()
| 4,134
|
def get_source(func): """Less silly interface to find_source""" # Sheesh return find_source(func.func_globals['__file__'], func.func_code)[1]
|
def get_source(func): """Less silly interface to find_source""" # Sheesh return find_source(func.func_globals['__file__'], func.func_code)[1]
| 4,135
|
def checkBeforeAndAfter(self): from RestrictedPython.RCompile import RModule
|
deffrom RestrictedPython.tests import before_and_after checkBeforeAndAfter(self):from RestrictedPython.tests import before_and_after fromfrom RestrictedPython.tests import before_and_after RestrictedPython.RCompilefrom RestrictedPython.tests import before_and_after importfrom RestrictedPython.tests import before_and_after RModule
| 4,136
|
def getiter(seq): calls.append(seq) return list(seq)
|
def getiter(seq): calls.append(seq) return list(seq)
| 4,137
|
def publish(self, module_name, after_list, published='web_objects', imported_modules={}, module_dicts={},debug=0):
|
def publish(self, module_name, after_list, published='web_objects', imported_modules={}, module_dicts={},debug=0):
| 4,138
|
def getElementsByTagName(self, tagname): """ Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree. Parameter: tagname The name of the tag to match (* = all tags). Return Value: A new NodeList object containing all the matched Elements. """ nodeList = [] for child in self.objectValues(): if (child.getNodeType()==ELEMENT_NODE and \ child.getTagName()==tagname or tagname== '*'): nodeList.append(child) n1 = child.getElementsByTagName(tagname) nodeList = nodeList + n1._data return NodeList(nodeList)
|
def getElementsByTagName(self, tagname): """ Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree. Parameter: tagname The name of the tag to match (* = all tags). Return Value: A new NodeList object containing all the matched Elements. """ nodeList = [] for child in self.objectValues(): if (child.getNodeType()==ELEMENT_NODE and \ child.getTagName()==tagname or tagname== '*'): nodeList.append(child) if hasattr(child, 'getElementsByTagName'): n1 = child.getElementsByTagName(tagname) nodeList = nodeList + n1._data return NodeList(nodeList)
| 4,139
|
def _finish(self, tid, user, desc, ext): """Called from BaseStorage.tpc_finish(), this commits the underlying BSDDB transaction.
|
def _finish(self, tid, user, desc, ext): """Called from BaseStorage.tpc_finish(), this commits the underlying BSDDB transaction.
| 4,140
|
def _abort(self, tid, user, desc, ext): """Called from BaseStorage.tpc_abort(), this aborts the underlying BSDDB transaction. tid is the transaction id user is the transaction user desc is the transaction description ext is the transaction extension
|
def _abort(self, tid, user, desc, ext): """Called from BaseStorage.tpc_abort(), this aborts the underlying BSDDB transaction. tid is the transaction id user is the transaction user desc is the transaction description ext is the transaction extension
| 4,141
|
def _validTime(self,h,m,s): return h>=0 and h<=23 and m>=0 and m<=59 and s>=0 and s<=59
|
def _validTime(self,h,m,s): return h>=0 and h<=23 and m>=0 and m<=59 and s>=0 and s<=59
| 4,142
|
def unrestrictedTraverse(self, path, default=_marker, restricted=0):
|
def unrestrictedTraverse(self, path, default=_marker, restricted=0):
| 4,143
|
def next_object(self): # Get the next object pickle data. Return the oid and the pickle # string. Raise a LogCorruptedError if there's an incomplete marshal # record. rec = self._next() if rec is None: return None try: key, (oid, pickle) = rec except ValueError: raise LogCorruptedError, 'incomplete record' if key <> 'o': raise LogCorruptedError, 'bad record key: %s' % key return oid, pickle
|
def next_object(self): # Get the next object pickle data. Return the oid and the pickle # string. Raise a LogCorruptedError if there's an incomplete marshal # record. rec = self._next() if rec is None: return None try: key, (oid, pickle) = rec except ValueError: raise LogCorruptedError, 'incomplete record' if key <> 'o': raise LogCorruptedError, 'bad record key: %s' % key return oid, pickle
| 4,144
|
def write_object(self, oid, pickle): self._append('o', (oid, pickle))
|
def write_object(self, oid, pickle): self._append('o', (oid, pickle))
| 4,145
|
def next_object(self): # Get the next object record. Return the key for unpacking and the # object record data. rec = self._next() if rec is None: return NOne try: key, data = rec except ValueError: raise LogCorruptedError, 'incomplete record' if key not in 'ovd': raise LogCorruptedError, 'bad record key: %s' % key return key, data
|
def next_object(self): # Get the next object record. Return the key for unpacking and the # object record data. rec = self._next() if rec is None: return None try: key, data = rec except ValueError: raise LogCorruptedError, 'incomplete record' if key not in 'ovd': raise LogCorruptedError, 'bad record key: %s' % key return key, data
| 4,146
|
def next_object(self): # Get the next object record. Return the key for unpacking and the # object record data. rec = self._next() if rec is None: return NOne try: key, data = rec except ValueError: raise LogCorruptedError, 'incomplete record' if key not in 'ovd': raise LogCorruptedError, 'bad record key: %s' % key return key, data
|
def next_object(self): # Get the next object record. Return the key for unpacking and the # object record data. rec = self._next() if rec is None: return NOne try: key, data = rec except ValueError: raise LogCorruptedError, 'incomplete record' if key not in 'ovd': raise LogCorruptedError, 'bad record key: %s' % key return key, data
| 4,147
|
def manage_exportObject(self, id='', download=None, toxml=None, RESPONSE=None,REQUEST=None): """Exports an object to a file and returns that file.""" if not id: # can't use getId() here (breaks on "old" exported objects) id=self.id if hasattr(id, 'im_func'): id=id() ob=self else: ob=self._getOb(id)
|
def manage_exportObject(self, id='', download=None, toxml=None, RESPONSE=None,REQUEST=None): """Exports an object to a file and returns that file.""" if not id: # can't use getId() here (breaks on "old" exported objects) id=self.id if hasattr(id, 'im_func'): id=id() ob=self else: ob=self._getOb(id)
| 4,148
|
def manage_importObject(self, file, REQUEST=None, set_owner=1): """Import an object from a file""" dirname, file=os.path.split(file) if dirname: raise BadRequestException, 'Invalid file name %s' % escape(file)
|
def manage_importObject(self, file, REQUEST=None, set_owner=1): """Import an object from a file""" dirname, file=os.path.split(file) if dirname: raise BadRequestException, 'Invalid file name %s' % escape(file)
| 4,149
|
def _cookie_list(self):
|
def _cookie_list(self):
| 4,150
|
def formatTracebackInfo(self, tbi): return self.formatSupplementLine('__traceback_info__: %s' % tbi)
|
def formatTracebackInfo(self, tbi): return self.formatSupplementLine('__traceback_info__: %s' % tbi)
| 4,151
|
def search(self,path,default_level=0): """ path is either a string representing a relative URL or a part of a relative URL or a tuple (path,level).
|
def search(self,path,default_level=0): """ path is either a string representing a relative URL or a part of a relative URL or a tuple (path,level).
| 4,152
|
def search(self,path,default_level=0): """ path is either a string representing a relative URL or a part of a relative URL or a tuple (path,level).
|
def search(self,path,default_level=0): """ path is either a string representing a relative URL or a part of a relative URL or a tuple (path,level).
| 4,153
|
def doc_inner_link(self, s, expr1 = re.compile(r"\.\.\s*").search, expr2 = re.compile(r"\[[%s%s]+\]" % (letters, digits) ).search): # make sure we dont grab a named link if expr2(s) and expr1(s): start1,end1 = expr1(s).span() start2,end2 = expr2(s).span() if end1 == start2: # uh-oh, looks like a named link return None else: # the .. is somewhere else, ignore it return (StructuredTextInnerLink(s[start2+1,end2-1],start2,end2)) return None elif expr2(s) and not expr1(s): start,end = expr2(s).span() return (StructuredTextInnerLink(s[start+1:end-1]),start,end) return None
|
def doc_inner_link(self, s, expr1 = re.compile(r"\.\.\s*").search, expr2 = re.compile(r"\[[%s%s]+\]" % (letters, digits) ).search): # make sure we dont grab a named link if expr2(s) and expr1(s): start1,end1 = expr1(s).span() start2,end2 = expr2(s).span() if end1 == start2: # uh-oh, looks like a named link return None else: # the .. is somewhere else, ignore it return (StructuredTextInnerLink(s[start2+1:end2-1],start2,end2)) return None elif expr2(s) and not expr1(s): start,end = expr2(s).span() return (StructuredTextInnerLink(s[start+1:end-1]),start,end) return None
| 4,154
|
def __getattr__(self, name):
|
def __getattr__(self, name):
| 4,155
|
def getobject(self, rid, REQUEST=None): """ Return a cataloged object given a 'data_record_id_' """ try: obj = self.aq_parent.restrictedTraverse(self.getpath(rid)) if not obj: if REQUEST is None: REQUEST=self.REQUEST obj = self.sq_parent.resolve_url(self.getpath(rid), REQUEST) return obj except: pass
|
def getobject(self, rid, REQUEST=None): """ Return a cataloged object given a 'data_record_id_' """ try: obj = self.aq_parent.restrictedTraverse(self.getpath(rid)) if not obj: if REQUEST is None: REQUEST=self.REQUEST obj = self.aq_parent.resolve_url(self.getpath(rid), REQUEST) return obj except: pass
| 4,156
|
def _unauthorized(self): realm=self.realm if realm: self['WWW-authenticate']='basic realm="%s"' % realm
|
def _unauthorized(self): realm=self.realm if realm: self['WWW-authenticate']='basic realm="%s"' % realm
| 4,157
|
def __init__(self, id, text=None, content_type=None, encoding='utf-8', strict=True): self.id = id self.expand = 0 self.ZBindings_edit(self._default_bindings) self.output_encoding = 'utf-8'
|
def __init__(self, id, text=None, content_type=None, encoding='utf-8', strict=True): self.id = id self.expand = 0 self.ZBindings_edit(self._default_bindings) self.output_encoding = 'utf-8'
| 4,158
|
def pt_edit(self, text, content_type, keep_output_encoding=False):
|
def pt_edit(self, text, content_type, keep_output_encoding=False):
| 4,159
|
def initialize(app): # Initialize the application # Initialize the cache: app.Control_Panel.initialize_cache() # The following items marked b/c are backward compatibility hacks # which make sure that expected system objects are added to the # bobobase. This is required because the bobobase in use may pre- # date the introduction of certain system objects such as those # which provide Lever support. # b/c: Ensure that Control Panel exists. if not hasattr(app, 'Control_Panel'): cpl=ApplicationManager() cpl._init() app._setObject('Control_Panel', cpl) get_transaction().note('Added Control_Panel') get_transaction().commit() # b/c: Ensure that a ProductFolder exists. if not hasattr(app.Control_Panel.aq_base, 'Products'): app.Control_Panel.Products=App.Product.ProductFolder() get_transaction().note('Added Control_Panel.Products') get_transaction().commit() # Ensure that a temp folder exists if not hasattr(app, 'temp_folder'): from Products.TemporaryFolder.TemporaryFolder import \ MountedTemporaryFolder tf = MountedTemporaryFolder('temp_folder','Temporary Folder') app._setObject('temp_folder', tf) get_transaction().note('Added temp_folder') get_transaction().commit() del tf # Ensure that there is a transient container in the temp folder tf = app.temp_folder if not hasattr(tf, 'session_data'): env_has = os.environ.get from Products.Transience.Transience import TransientObjectContainer addnotify = env_has('ZSESSION_ADD_NOTIFY', None) delnotify = env_has('ZSESSION_DEL_NOTIFY', None) default_limit = 1000 limit = env_has('ZSESSION_OBJECT_LIMIT', default_limit) try: limit=int(limit) if limit != default_limit: LOG('Zope Default Object Creation', INFO, ('using ZSESSION_OBJECT_LIMIT-specified max objects ' 'value of %s' % limit)) except ValueError: LOG('Zope Default Object Creation', WARNING, ('Noninteger value %s specified for ZSESSION_OBJECT_LIMIT, ' 'defaulting to %s' % (limit, default_limit))) limit = default_limit if addnotify and app.unrestrictedTraverse(addnotify, None) is None: LOG('Zope Default Object Creation', WARNING, ('failed to use nonexistent "%s" script as ' 'ZSESSION_ADD_NOTIFY' % addnotify)) addnotify=None elif addnotify: LOG('Zope Default Object Creation', INFO, 'using %s as add notification script' % addnotify) if delnotify and app.unrestrictedTraverse(delnotify, None) is None: LOG('Zope Default Object Creation', WARNING, ('failed to use nonexistent "%s" script as ' 'ZSESSION_DEL_NOTIFY' % delnotify)) delnotify=None elif delnotify: LOG('Zope Default Object Creation', INFO, 'using %s as delete notification script' % delnotify) toc = TransientObjectContainer('session_data', 'Session Data Container', addNotification = addnotify, delNotification = delnotify, limit=limit) timeout_spec = env_has('ZSESSION_TIMEOUT_MINS', '') if timeout_spec: try: timeout_spec = int(timeout_spec) except ValueError: LOG('Zope Default Object Creation', WARNING, ('"%s" is an illegal value for ZSESSION_TIMEOUT_MINS, ' 'using default timeout instead.' % timeout_spec)) else: LOG('Zope Default Object Creation', INFO, ('using ZSESSION_TIMEOUT_MINS-specified session timeout ' 'value of %s' % timeout_spec)) toc = TransientObjectContainer('session_data', 'Session Data Container', timeout_mins = timeout_spec, addNotification=addnotify, delNotification = delnotify, limit=limit) tf._setObject('session_data', toc) tf_reserved = getattr(tf, '_reserved_names', ()) if 'session_data' not in tf_reserved: tf._reserved_names = tf_reserved + ('session_data',) get_transaction().note('Added session_data to temp_folder') get_transaction().commit() del toc del addnotify del delnotify del timeout_spec del env_has del tf # Ensure that a browser ID manager exists if not hasattr(app, 'browser_id_manager'): from Products.Sessions.BrowserIdManager import BrowserIdManager bid = BrowserIdManager('browser_id_manager', 'Browser Id Manager') app._setObject('browser_id_manager', bid) get_transaction().note('Added browser_id_manager') get_transaction().commit() del bid # Ensure that a session data manager exists if not hasattr(app, 'session_data_manager'): from Products.Sessions.SessionDataManager import SessionDataManager sdm = SessionDataManager('session_data_manager', title='Session Data Manager', path='/temp_folder/session_data', requestName='SESSION') app._setObject('session_data_manager', sdm) get_transaction().note('Added session_data_manager') get_transaction().commit() del sdm # Ensure that there's an Examples folder with examples. # However, make sure that if the examples have been added already # and then deleted that we don't add them again. if not hasattr(app, 'Examples') and not \ hasattr(app, '_Zope25_examples_have_been_added'): examples_path = os.path.join(Globals.SOFTWARE_HOME, \ '..','..','import', 'Examples.zexp') if os.path.isfile(examples_path): app._importObjectFromFile(examples_path, verify=0) app._Zope25_examples_have_been_added=1 get_transaction().note('Added Examples folder') get_transaction().commit() else: LOG('Zope Default Object Creation', INFO, '%s examples import file could not be found.' % examples_path) # b/c: Ensure that Owner role exists. if hasattr(app, '__ac_roles__') and not ('Owner' in app.__ac_roles__): app.__ac_roles__=app.__ac_roles__ + ('Owner',) get_transaction().note('Added Owner role') get_transaction().commit() # ensure the Authenticated role exists. if hasattr(app, '__ac_roles__'): if not 'Authenticated' in app.__ac_roles__: app.__ac_roles__=app.__ac_roles__ + ('Authenticated',) get_transaction().note('Added Authenticated role') get_transaction().commit() # Make sure we have Globals root=app._p_jar.root() if not root.has_key('ZGlobals'): import BTree app._p_jar.root()['ZGlobals']=BTree.BTree() get_transaction().note('Added Globals') get_transaction().commit() # Install the initial user. if hasattr(app, 'acl_users'): users = app.acl_users if hasattr(users, '_createInitialUser'): app.acl_users._createInitialUser() get_transaction().note('Created initial user') get_transaction().commit() install_products(app) install_standards(app) # Note that the code from here on only runs if we are not a ZEO # client, or if we are a ZEO client and we've specified by way # of env variable that we want to force products to load. if (os.environ.get('ZEO_CLIENT') and not os.environ.get('FORCE_PRODUCT_LOAD')): return # Check for dangling pointers (broken zclass dependencies) in the # global class registry. If found, rebuild the registry. Note that # if the check finds problems but fails to successfully rebuild the # registry we abort the transaction so that we don't leave it in an # indeterminate state. did_fixups=0 bad_things=0 try: if app.checkGlobalRegistry(): LOG('Zope', INFO, 'Beginning attempt to rebuild the global ZClass registry.') app.fixupZClassDependencies(rebuild=1) did_fixups=1 LOG('Zope', INFO, 'The global ZClass registry has successfully been rebuilt.') get_transaction().note('Rebuilt global product registry') get_transaction().commit() except: bad_things=1 LOG('Zope', ERROR, 'The attempt to rebuild the registry failed.', error=sys.exc_info()) get_transaction().abort() # Now we need to see if any (disk-based) products were installed # during intialization. If so (and the registry has no errors), # there may still be zclasses dependent on a base class in the # newly installed product that were previously broken and need to # be fixed up. If any really Bad Things happened (dangling pointers # were found in the registry but it couldn't be rebuilt), we don't # try to do anything to avoid making the problem worse. if (not did_fixups) and (not bad_things): # App.Product.initializeProduct will set this if a disk-based # product was added or updated and we are not a ZEO client. if getattr(Globals, '__disk_product_installed__', 0): try: LOG('Zope', INFO, 'New disk product detected, determining '\ 'if we need to fix up any ZClasses.') if app.fixupZClassDependencies(): LOG('Zope', INFO, 'Repaired broken ZClass dependencies.') get_transaction().commit() except: LOG('Zope', ERROR, 'Attempt to fixup ZClass dependencies after detecting ' \ 'an updated disk-based product failed.', error=sys.exc_info()) get_transaction().abort()
|
def initialize(app): # Initialize the application # Initialize the cache:# The following items marked b/c are backward compatibility hacks # which make sure that expected system objects are added to the # bobobase. This is required because the bobobase in use may pre- # date the introduction of certain system objects such as those # which provide Lever support. # b/c: Ensure that Control Panel exists. if not hasattr(app, 'Control_Panel'): cpl=ApplicationManager() cpl._init() app._setObject('Control_Panel', cpl) get_transaction().note('Added Control_Panel') get_transaction().commit() # b/c: Ensure that a ProductFolder exists. if not hasattr(app.Control_Panel.aq_base, 'Products'): app.Control_Panel.Products=App.Product.ProductFolder() get_transaction().note('Added Control_Panel.Products') get_transaction().commit() # Ensure that a temp folder exists if not hasattr(app, 'temp_folder'): from Products.TemporaryFolder.TemporaryFolder import \ MountedTemporaryFolder tf = MountedTemporaryFolder('temp_folder','Temporary Folder') app._setObject('temp_folder', tf) get_transaction().note('Added temp_folder') get_transaction().commit() del tf # Ensure that there is a transient container in the temp folder tf = app.temp_folder if not hasattr(tf, 'session_data'): env_has = os.environ.get from Products.Transience.Transience import TransientObjectContainer addnotify = env_has('ZSESSION_ADD_NOTIFY', None) delnotify = env_has('ZSESSION_DEL_NOTIFY', None) default_limit = 1000 limit = env_has('ZSESSION_OBJECT_LIMIT', default_limit) try: limit=int(limit) if limit != default_limit: LOG('Zope Default Object Creation', INFO, ('using ZSESSION_OBJECT_LIMIT-specified max objects ' 'value of %s' % limit)) except ValueError: LOG('Zope Default Object Creation', WARNING, ('Noninteger value %s specified for ZSESSION_OBJECT_LIMIT, ' 'defaulting to %s' % (limit, default_limit))) limit = default_limit if addnotify and app.unrestrictedTraverse(addnotify, None) is None: LOG('Zope Default Object Creation', WARNING, ('failed to use nonexistent "%s" script as ' 'ZSESSION_ADD_NOTIFY' % addnotify)) addnotify=None elif addnotify: LOG('Zope Default Object Creation', INFO, 'using %s as add notification script' % addnotify) if delnotify and app.unrestrictedTraverse(delnotify, None) is None: LOG('Zope Default Object Creation', WARNING, ('failed to use nonexistent "%s" script as ' 'ZSESSION_DEL_NOTIFY' % delnotify)) delnotify=None elif delnotify: LOG('Zope Default Object Creation', INFO, 'using %s as delete notification script' % delnotify) toc = TransientObjectContainer('session_data', 'Session Data Container', addNotification = addnotify, delNotification = delnotify, limit=limit) timeout_spec = env_has('ZSESSION_TIMEOUT_MINS', '') if timeout_spec: try: timeout_spec = int(timeout_spec) except ValueError: LOG('Zope Default Object Creation', WARNING, ('"%s" is an illegal value for ZSESSION_TIMEOUT_MINS, ' 'using default timeout instead.' % timeout_spec)) else: LOG('Zope Default Object Creation', INFO, ('using ZSESSION_TIMEOUT_MINS-specified session timeout ' 'value of %s' % timeout_spec)) toc = TransientObjectContainer('session_data', 'Session Data Container', timeout_mins = timeout_spec, addNotification=addnotify, delNotification = delnotify, limit=limit) tf._setObject('session_data', toc) tf_reserved = getattr(tf, '_reserved_names', ()) if 'session_data' not in tf_reserved: tf._reserved_names = tf_reserved + ('session_data',) get_transaction().note('Added session_data to temp_folder') get_transaction().commit() del toc del addnotify del delnotify del timeout_spec del env_has del tf # Ensure that a browser ID manager exists if not hasattr(app, 'browser_id_manager'): from Products.Sessions.BrowserIdManager import BrowserIdManager bid = BrowserIdManager('browser_id_manager', 'Browser Id Manager') app._setObject('browser_id_manager', bid) get_transaction().note('Added browser_id_manager') get_transaction().commit() del bid # Ensure that a session data manager exists if not hasattr(app, 'session_data_manager'): from Products.Sessions.SessionDataManager import SessionDataManager sdm = SessionDataManager('session_data_manager', title='Session Data Manager', path='/temp_folder/session_data', requestName='SESSION') app._setObject('session_data_manager', sdm) get_transaction().note('Added session_data_manager') get_transaction().commit() del sdm # Ensure that there's an Examples folder with examples. # However, make sure that if the examples have been added already # and then deleted that we don't add them again. if not hasattr(app, 'Examples') and not \ hasattr(app, '_Zope25_examples_have_been_added'): examples_path = os.path.join(Globals.SOFTWARE_HOME, \ '..','..','import', 'Examples.zexp') if os.path.isfile(examples_path): app._importObjectFromFile(examples_path, verify=0) app._Zope25_examples_have_been_added=1 get_transaction().note('Added Examples folder') get_transaction().commit() else: LOG('Zope Default Object Creation', INFO, '%s examples import file could not be found.' % examples_path) # b/c: Ensure that Owner role exists. if hasattr(app, '__ac_roles__') and not ('Owner' in app.__ac_roles__): app.__ac_roles__=app.__ac_roles__ + ('Owner',) get_transaction().note('Added Owner role') get_transaction().commit() # ensure the Authenticated role exists. if hasattr(app, '__ac_roles__'): if not 'Authenticated' in app.__ac_roles__: app.__ac_roles__=app.__ac_roles__ + ('Authenticated',) get_transaction().note('Added Authenticated role') get_transaction().commit() # Make sure we have Globals root=app._p_jar.root() if not root.has_key('ZGlobals'): import BTree app._p_jar.root()['ZGlobals']=BTree.BTree() get_transaction().note('Added Globals') get_transaction().commit() # Install the initial user. if hasattr(app, 'acl_users'): users = app.acl_users if hasattr(users, '_createInitialUser'): app.acl_users._createInitialUser() get_transaction().note('Created initial user') get_transaction().commit() install_products(app) install_standards(app) # Note that the code from here on only runs if we are not a ZEO # client, or if we are a ZEO client and we've specified by way # of env variable that we want to force products to load. if (os.environ.get('ZEO_CLIENT') and not os.environ.get('FORCE_PRODUCT_LOAD')): return # Check for dangling pointers (broken zclass dependencies) in the # global class registry. If found, rebuild the registry. Note that # if the check finds problems but fails to successfully rebuild the # registry we abort the transaction so that we don't leave it in an # indeterminate state. did_fixups=0 bad_things=0 try: if app.checkGlobalRegistry(): LOG('Zope', INFO, 'Beginning attempt to rebuild the global ZClass registry.') app.fixupZClassDependencies(rebuild=1) did_fixups=1 LOG('Zope', INFO, 'The global ZClass registry has successfully been rebuilt.') get_transaction().note('Rebuilt global product registry') get_transaction().commit() except: bad_things=1 LOG('Zope', ERROR, 'The attempt to rebuild the registry failed.', error=sys.exc_info()) get_transaction().abort() # Now we need to see if any (disk-based) products were installed # during intialization. If so (and the registry has no errors), # there may still be zclasses dependent on a base class in the # newly installed product that were previously broken and need to # be fixed up. If any really Bad Things happened (dangling pointers # were found in the registry but it couldn't be rebuilt), we don't # try to do anything to avoid making the problem worse. if (not did_fixups) and (not bad_things): # App.Product.initializeProduct will set this if a disk-based # product was added or updated and we are not a ZEO client. if getattr(Globals, '__disk_product_installed__', 0): try: LOG('Zope', INFO, 'New disk product detected, determining '\ 'if we need to fix up any ZClasses.') if app.fixupZClassDependencies(): LOG('Zope', INFO, 'Repaired broken ZClass dependencies.') get_transaction().commit() except: LOG('Zope', ERROR, 'Attempt to fixup ZClass dependencies after detecting ' \ 'an updated disk-based product failed.', error=sys.exc_info()) get_transaction().abort()
| 4,160
|
def apply(self, classobj): """Apply security information to the given class object.""" dict = classobj.__dict__
|
def apply(self, classobj): """Apply security information to the given class object.""" dict = classobj.__dict__
| 4,161
|
def convert(S, find=string.find): new = '' encoding = 'repr' new = string.join(map(lambda s: d[s], S), '') if len(new) > (1.4*len(S)): encoding = 'base64' new = base64.encodestring(S)[:-1] elif find(new,'>') >= 0 or find(new,'<') >= 0 or find(new,'&') >= 0: if find(new, ']]>') <0 : new='<![CDATA[\n\n'+new+'\n\n]]>' encoding='cdata' else: new=string.join(map(lambda s: d2[s], new), '') return encoding, new
|
def convert(S, find=string.find): new = '' encoding = 'repr' new = string.join(map(reprs.get, S), '') if len(new) > (1.4*len(S)): encoding = 'base64' new = base64.encodestring(S)[:-1] elif find(new,'>') >= 0 or find(new,'<') >= 0 or find(new,'&') >= 0: if find(new, ']]>') <0 : new='<![CDATA[\n\n'+new+'\n\n]]>' encoding='cdata' else: new=string.join(map(lambda s: d2[s], new), '') return encoding, new
| 4,162
|
def convert(S, find=string.find): new = '' encoding = 'repr' new = string.join(map(lambda s: d[s], S), '') if len(new) > (1.4*len(S)): encoding = 'base64' new = base64.encodestring(S)[:-1] elif find(new,'>') >= 0 or find(new,'<') >= 0 or find(new,'&') >= 0: if find(new, ']]>') <0 : new='<![CDATA[\n\n'+new+'\n\n]]>' encoding='cdata' else: new=string.join(map(lambda s: d2[s], new), '') return encoding, new
|
def convert(S, find=string.find): new = '' encoding = 'repr' new = string.join(map(lambda s: d[s], S), '') if len(new) > (1.4*len(S)): encoding = 'base64' new = base64.encodestring(S)[:-1] elif find(new,'>') >= 0 or find(new,'<') >= 0 or find(new,'&') >= 0: if find(new, ']]>') <0 : new='<![CDATA[\n\n'+new+'\n\n]]>' encoding='cdata' else: new=string.join(map(lambda s: reprs2.get(s,s), new), '') return encoding, new
| 4,163
|
def u64(v, unpack=struct.unpack): h, v = unpack(">ii", v) if v < 0: v=t32-v if h: if h < 0: h=t32-h v=h*t32+v return v
|
def u64(v, unpack=struct.unpack): h, v = unpack(">ii", v) if v < 0: v=t32+v if h: if h < 0: h=t32-h v=h*t32+v return v
| 4,164
|
def u64(v, unpack=struct.unpack): h, v = unpack(">ii", v) if v < 0: v=t32-v if h: if h < 0: h=t32-h v=h*t32+v return v
|
def u64(v, unpack=struct.unpack): h, v = unpack(">ii", v) if v < 0: v=t32-v if h: if h < 0: h=t32+h v=h*t32+v return v
| 4,165
|
def u64(v, unpack=struct.unpack): h, v = unpack(">ii", v) if v < 0: v=t32-v if h: if h < 0: h=t32-h v=h*t32+v return v
|
def u64(v, unpack=struct.unpack): h, v = unpack(">ii", v) if v < 0: v=t32-v if h: if h < 0: h=t32-h v=h*t32+v return v
| 4,166
|
def end_none(self,tag,data): return None
|
def end_none(self,tag,data): return None
| 4,167
|
def end_dictionary(self, tag, data): D={} a=data[1] for k, v in data[2:]: D[k]=v if a.has_key('id'): self._pickleids[a['id']]=D return D
|
def end_dictionary(self, tag, data): D={} a=data[1] for k, v in data[2:]: D[k]=v if a.has_key('id'): self._pickleids[a['id']]=D return D
| 4,168
|
def end_item(self, tag, data): v=data[2:] return v
|
def end_item(self, tag, data): v=data[2:] return v
| 4,169
|
def end_item(self, tag, data): v=data[2:] return v
|
def end_item(self, tag, data): v=data[2:] return v
| 4,170
|
def end_item(self, tag, data): v=data[2:] return v
|
def end_item(self, tag, data): v=data[2:] return v
| 4,171
|
def save_string(self, tag, data): binary=self.binary v='' a=data[1] if len(data)>2: for x in data[2:]: v=v+x encoding=a['encoding'] if encoding is not '': v=unconvert(encoding,v) put='p' if binary: l=len(v) s=mdumps(l)[1:] if (l<256): v='U'+s[0]+v else: v='T'+s+v put='q' else: v="S'"+v+"'\012" if a.has_key('id'): id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] if binary: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' v=v+put+id else: v=v+put+id+"\012" return v
|
def save_string(self, tag, data): binary=self.binary v='' a=data[1] if len(data)>2: for x in data[2:]: v=v+x encoding=a['encoding'] if encoding is not '': v=unconvert(encoding,v) put='p' if binary: l=len(v) s=mdumps(l)[1:] if (l<256): v='U'+s[0]+v else: v='T'+s+v put='q' else: v="S'"+v+"'\012" return save_put(self, v, a)
| 4,172
|
def save_tuple(self, tag, data): binary=self.binary T=data[2:] a=data[1] v='' put='p' for x in T: v=v+x if v is '': return ')' v='('+v+'t' if a.has_key('id'): id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] if binary: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' v=v+put+id else: v=v+put+id+'\012' return v
|
def save_tuple(self, tag, data): T=data[2:] a=data[1] v='' put='p' for x in T: v=v+x if v is '': return ')' v='('+v+'t' if a.has_key('id'): id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] if binary: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' v=v+put+id else: v=v+put+id+'\012' return v
| 4,173
|
def save_tuple(self, tag, data): binary=self.binary T=data[2:] a=data[1] v='' put='p' for x in T: v=v+x if v is '': return ')' v='('+v+'t' if a.has_key('id'): id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] if binary: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' v=v+put+id else: v=v+put+id+'\012' return v
|
def save_tuple(self, tag, data): binary=self.binary T=data[2:] if not T: return ')' return save_put(self, '('+string.join(T,'')+'t', data[1])
| 4,174
|
def save_list(self, tag, data): binary=self.binary L=data[2:] a=data[1] v='' x=0 if a.has_key('id'): id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] if binary: while x<len(L): v=v+L[x] x=x+1 if id: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' if v is not '': v=']'+put+id+'('+v+'e' else: v=']'+put+id else: while x<len(L): v=v+L[x]+'a' x=x+1 if id: v='(lp'+id+'\012'+v if v=='': v=']' return v
|
def save_list(self, tag, data): L=data[2:] a=data[1] v='' x=0 if a.has_key('id'): id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] if binary: while x<len(L): v=v+L[x] x=x+1 if id: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' if v is not '': v=']'+put+id+'('+v+'e' else: v=']'+put+id else: while x<len(L): v=v+L[x]+'a' x=x+1 if id: v='(lp'+id+'\012'+v if v=='': v=']' return v
| 4,175
|
def save_list(self, tag, data): binary=self.binary L=data[2:] a=data[1] v='' x=0 if a.has_key('id'): id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] if binary: while x<len(L): v=v+L[x] x=x+1 if id: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' if v is not '': v=']'+put+id+'('+v+'e' else: v=']'+put+id else: while x<len(L): v=v+L[x]+'a' x=x+1 if id: v='(lp'+id+'\012'+v if v=='': v=']' return v
|
def save_list(self, tag, data): binary=self.binary L=data[2:] a=data[1] if self.binary: v=save_put(self, ']', a) if L: v=v+'('+string.join(L,'')+'e' else: while x<len(L): v=v+L[x]+'a' x=x+1 if id: v='(lp'+id+'\012'+v if v=='': v=']' return v
| 4,176
|
def save_list(self, tag, data): binary=self.binary L=data[2:] a=data[1] v='' x=0 if a.has_key('id'): id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] if binary: while x<len(L): v=v+L[x] x=x+1 if id: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' if v is not '': v=']'+put+id+'('+v+'e' else: v=']'+put+id else: while x<len(L): v=v+L[x]+'a' x=x+1 if id: v='(lp'+id+'\012'+v if v=='': v=']' return v
|
def save_list(self, tag, data): binary=self.binary L=data[2:] a=data[1] v='' x=0 if a.has_key('id'): id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] if binary: while x<len(L): v=v+L[x] x=x+1 if id: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' if v is not '': v=']'+put+id+'('+v+'e' else: v=']'+put+id else: v=save_put(self, '(l', a) if L: v=string.join(L,'a')+'a' return v
| 4,177
|
def save_dict(self, tag, data): binary=self.binary D=data[2:] a=data[1] id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] if binary: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' v='}'+put+id if len(D)>0: v=v+'(' x=0 while x < len(D): v=v+D[x] x=x+1 if len(D)>0: v=v+'u' else: v='(dp'+id+'\012' x=0 while x<len(D): v=v+D[x]+'s' x=x+1 return v
|
def save_dict(self, tag, data): D=data[2:] a=data[1] id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] if binary: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' v='}'+put+id if len(D)>0: v=v+'(' x=0 while x < len(D): v=v+D[x] x=x+1 if len(D)>0: v=v+'u' else: v='(dp'+id+'\012' x=0 while x<len(D): v=v+D[x]+'s' x=x+1 return v
| 4,178
|
def save_dict(self, tag, data): binary=self.binary D=data[2:] a=data[1] id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] if binary: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' v='}'+put+id if len(D)>0: v=v+'(' x=0 while x < len(D): v=v+D[x] x=x+1 if len(D)>0: v=v+'u' else: v='(dp'+id+'\012' x=0 while x<len(D): v=v+D[x]+'s' x=x+1 return v
|
def save_dict(self, tag, data): binary=self.binary D=data[2:] if self.binary: v=save_put(self, '}', data[1]) if D: v=v+'('+string.join(D,'')+'u' else: v='(dp'+id+'\012' x=0 while x<len(D): v=v+D[x]+'s' x=x+1 return v
| 4,179
|
def save_dict(self, tag, data): binary=self.binary D=data[2:] a=data[1] id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] if binary: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' v='}'+put+id if len(D)>0: v=v+'(' x=0 while x < len(D): v=v+D[x] x=x+1 if len(D)>0: v=v+'u' else: v='(dp'+id+'\012' x=0 while x<len(D): v=v+D[x]+'s' x=x+1 return v
|
def save_dict(self, tag, data): binary=self.binary D=data[2:] a=data[1] id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] if binary: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' v='}'+put+id if len(D)>0: v=v+'(' x=0 while x < len(D): v=v+D[x] x=x+1 if len(D)>0: v=v+'u' else: v='(dp'+id+'\012' x=0 while x<len(D): v=v+D[x]+'s' x=x+1 return v
| 4,180
|
def save_reference(self, tag, data): binary=self.binary a=data[1] id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] get='g' if binary: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] get='h' else: id=s get='j' v=get+id else: v=get+id+'\012' return v
|
def save_reference(self, tag, data): binary=self.binary a=data[1] id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] get='g' if binary: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] get='h' else: id=s get='j' v=get+id else: v=get+id+'\012' return v
| 4,181
|
def save_object(self, tag, data): binary=self.binary a=data[1] v='(' j=0 id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] put='p' if binary: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' for x in data[2:]: if j==0: v=v + x elif j==1: x=x[1:] stop=string.rfind(x,'t') if stop>=0: x=x[:stop] v=v+x+'o'+put+id elif j==2: v=v+x j=j+1 else: for x in data[2:]: if j==0: v=v+x elif j==1: x=x[1:] stop=string.rfind(x,'t') if stop>=0: x=x[:stop] v=v+x+'o'+put+id+'\012' elif j==2: v=v+x j=j+1 v=v+'b' if a.has_key('id'): self._pickleids[a['id']]=v return v
|
def save_object(self, tag, data): v='('+data[2] x=data[3][1:] stop=string.rfind(x,'t') if stop>=0: x=x[:stop] v=save_put(self, v+x+'o', data[1]) v=v+data[4]+'b' return v def save_global(self, tag, data): a=data[1] v='(' j=0 id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] put='p' if binary: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' for x in data[2:]: if j==0: v=v + x elif j==1: x=x[1:] stop=string.rfind(x,'t') if stop>=0: x=x[:stop] v=v+x+'o'+put+id elif j==2: v=v+x j=j+1 else: for x in data[2:]: if j==0: v=v+x elif j==1: x=x[1:] stop=string.rfind(x,'t') if stop>=0: x=x[:stop] v=v+x+'o'+put+id+'\012' elif j==2: v=v+x j=j+1 v=v+'b' if a.has_key('id'): self._pickleids[a['id']]=v return v
| 4,182
|
def save_object(self, tag, data): binary=self.binary a=data[1] v='(' j=0 id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] put='p' if binary: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' for x in data[2:]: if j==0: v=v + x elif j==1: x=x[1:] stop=string.rfind(x,'t') if stop>=0: x=x[:stop] v=v+x+'o'+put+id elif j==2: v=v+x j=j+1 else: for x in data[2:]: if j==0: v=v+x elif j==1: x=x[1:] stop=string.rfind(x,'t') if stop>=0: x=x[:stop] v=v+x+'o'+put+id+'\012' elif j==2: v=v+x j=j+1 v=v+'b' if a.has_key('id'): self._pickleids[a['id']]=v return v
|
def save_object(self, tag, data): binary=self.binary a=data[1] v='(' j=0 id=a['id'] prefix=string.rfind(id,'.') if prefix>=0: id=id[prefix+1:] put='p' if binary: id=string.atoi(id) s=mdumps(id)[1:] if (id < 256): id=s[0] put='q' else: id=s put='r' for x in data[2:]: if j==0: v=v + x elif j==1: x=x[1:] stop=string.rfind(x,'t') if stop>=0: x=x[:stop] v=v+x+'o'+put+id elif j==2: v=v+x j=j+1 else: for x in data[2:]: if j==0: v=v+x elif j==1: x=x[1:] stop=string.rfind(x,'t') if stop>=0: x=x[:stop] v=v+x+'o'+put+id+'\012' elif j==2: v=v+x j=j+1 v=v+'b' if a.has_key('id'): self._pickleids[a['id']]=v return v
| 4,183
|
def save_persis(self, tag, data): binary=self.binary v=data[2] if binary: v=v+'Q' else: v='P'+v return v
|
def save_persis(self, tag, data): v=data[2] if binary: v=v+'Q' else: v='P'+v return v
| 4,184
|
def save_persis(self, tag, data): binary=self.binary v=data[2] if binary: v=v+'Q' else: v='P'+v return v
|
def save_persis(self, tag, data): binary=self.binary v=data[2] if self.binary: v=v+'Q' else: v='P'+v return v
| 4,185
|
def save_persis(self, tag, data): binary=self.binary v=data[2] if binary: v=v+'Q' else: v='P'+v return v
|
defsave_persis(self,tag,data):binary=self.binaryv=data[2]ifbinary:v=v+'Q'else:v='P'+vreturnv
| 4,186
|
def save_persis(self, tag, data): binary=self.binary v=data[2] if binary: v=v+'Q' else: v='P'+v return v
|
def save_persis(self, tag, data): binary=self.binary v=data[2] if binary: v=v+'Q' else: v='P'+v return v
| 4,187
|
def save_persis(self, tag, data): binary=self.binary v=data[2] if binary: v=v+'Q' else: v='P'+v return v
|
def save_persis(self, tag, data): binary=self.binary v=data[2] if binary: v=v+'Q' else: v='P'+v return v
| 4,188
|
def save_persis(self, tag, data): binary=self.binary v=data[2] if binary: v=v+'Q' else: v='P'+v return v
|
def save_persis(self, tag, data): binary=self.binary v=data[2] if binary: v=v+'Q' else: v='P'+v return v
| 4,189
|
def write_access(home, user='', group=''): import whrandom pw_choices = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ "abcdefghijklmnopqrstuvwxyz" \ "0123456789!" ac_path=os.path.join(home, 'access') if not os.path.exists(ac_path): print 'creating default access file' acfile=open(ac_path, 'w') pw = '' for i in range(8): pw = pw + whrandom.choice(pw_choices) acfile.write('superuser:' + generate_passwd(pw, 'SHA')) acfile.close() os.system('chmod 644 access') print """Note: The super user name and password are 'superuser' and '%s'. You can change the superuser name and password with the zpasswd script. To find out more, type: %s zpasswd """ % (pw, sys.executable) import do; do.ch(ac_path, user, group)
|
def write_access(home, user='', group=''): import whrandom pw_choices = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ "abcdefghijklmnopqrstuvwxyz" \ "0123456789!" ac_path=os.path.join(home, 'access') if not os.path.exists(ac_path): print 'creating default access file' acfile=open(ac_path, 'w') pw = '' for i in range(8): pw = pw + whrandom.choice(pw_choices) acfile.write('superuser:' + generate_passwd(pw, 'SHA')) acfile.close() os.system('chmod 644 access') print """Note: The super user name and password are 'superuser' and '%s'. You can change the superuser name and password with the zpasswd script. To find out more, type: %s zpasswd.py """ % (pw, sys.executable) import do; do.ch(ac_path, user, group)
| 4,190
|
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
|
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
| 4,191
|
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
|
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
| 4,192
|
def publish(self, module_name, after_list, published='web_objects',
|
def publish(self, module_name, after_list, published='web_objects',
| 4,193
|
def publish(self, module_name, after_list, published='web_objects',
|
def publish(self, module_name, after_list, published='web_objects',
| 4,194
|
def publish(self, module_name, after_list, published='web_objects',
|
def publish(self, module_name, after_list, published='web_objects',
| 4,195
|
def __call__(self, *args, **kw): self._a() try: return apply(self._f, args, kw) finally: self._r()
|
def __call__(self, *args, **kw): self._a() try: return apply(self._f, args, kw) finally: self._r()
| 4,196
|
def __init__(self, *dicts): self._mm = apply(MultiMapping, dicts)
|
def __init__(self, *dicts): self._mm = apply(MultiMapping, dicts)
| 4,197
|
def has_get(self, key): v = self._mm.get(key, self) if v is self: return 0, None else: return 1, v
|
def has_get(self, key): v = self.get(key, _marker) if v is _marker: return 0, None else: return 1, v
| 4,198
|
def __init__(self,*args): """Return a new date-time object
|
def __init__(self,*args): """Return a new date-time object
| 4,199
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.