bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def _makeFunction(self, allowSideEffect=0): from Guarded import GuardedBlock, theGuard, safebin from Guarded import WriteGuard, ReadGuard # Was the cached bytecode compiled with a compatible Python? if getattr(self, Python_magic, None) != Python_magic: allowSideEffect = 1 if allowSideEffect: self._checkCBlock(GuardedBlock) self.ZCacheable_invalidate() if getattr(self, '_v_errors', None): raise "Python Script Error", ('<pre>%s</pre>' % join(self._v_errors, '\n') ) return self._newfun(allowSideEffect, {'$guard': theGuard, '$write_guard': WriteGuard, '$read_guard': ReadGuard, '__debug__': __debug__}, __builtins__=safebin)
|
def _makeFunction(self, allowSideEffect=0): from Guarded import GuardedBlock, theGuard, safebin from Guarded import WriteGuard, ReadGuard # Was the cached bytecode compiled with a compatible Python? if getattr(self, 'Python_magic', None) != Python_magic: allowSideEffect = 1 if allowSideEffect: self._checkCBlock(GuardedBlock) self.ZCacheable_invalidate() if getattr(self, '_v_errors', None): raise "Python Script Error", ('<pre>%s</pre>' % join(self._v_errors, '\n') ) return self._newfun(allowSideEffect, {'$guard': theGuard, '$write_guard': WriteGuard, '$read_guard': ReadGuard, '__debug__': __debug__}, __builtins__=safebin)
| 2,300
|
def __init__(self,*args): """Return a new date-time object
|
def__init__(self,*args):"""Returnanewdate-timeobject
| 2,301
|
def renderwb(self, md): expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
|
def renderwb(self, md): expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
| 2,302
|
def renderwob(self, md): expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
|
def renderwob(self, md): expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
| 2,303
|
def numObjects(self): """ return number of indexed objects """ print 'numobjects', self.getId(), len(self._unindex) return len(self._unindex)
|
def numObjects(self): """ return number of indexed objects """ return len(self._unindex)
| 2,304
|
def indexSize(self): """ return of distinct values indexed""" print 'indexSize', self.getId(), len(self) return len(self)
|
def indexSize(self): """ return of distinct values indexed""" return len(self)
| 2,305
|
def load_binput(self): i = mloads('i' + self.read(1) + '\000\000\000') last = self.stack[-1] if getattr(last, 'id', last) is not last: last.id = self.idprefix + `i`
|
def load_binput(self): i = mloads('i' + self.read(1) + '\000\000\000') last = self.stack[-1] if getattr(last, 'id', last) is last: last.id = self.idprefix + `i`
| 2,306
|
def load_long_binput(self): i = mloads('i' + self.read(4)) last = self.stack[-1] if getattr(last, 'id', last) is not last: last.id = self.idprefix + `i`
|
def load_long_binput(self): i = mloads('i' + self.read(4)) last = self.stack[-1] if getattr(last, 'id', last) is last: last.id = self.idprefix + `i`
| 2,307
|
def save_persis(self, tag, data): v=data[2] if self.binary: v=v+'Q' else: v='P'+v return v
|
def save_persis(self, tag, data): v=data[2] if self.binary: v=v+'Q' else: v='P'+v return v
| 2,308
|
def save_persis(self, tag, data): v=data[2] if self.binary: v=v+'Q' else: v='P'+v return v
|
def save_persis(self, tag, data): v=data[2] if self.binary: v=v+'Q' else: v='P'+v return v
| 2,309
|
def search(self, text, start=0, name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match, end_match=regex.compile('[\0- ]*\(/\|end\)', regex.casefold).match, start_search=regex.compile('[<&]').search, ent_name=regex.compile('[-a-zA-Z0-9_.]+').match, find=find, strip=strip ):
|
def search(self, text, start=0, name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match, end_match=regex.compile('[\0- ]*\(/\|end\)', regex.casefold).match, start_search=regex.compile('[<&]').search, ent_name=regex.compile('[-a-zA-Z0-9_.]+').match, find=find, strip=strip ):
| 2,310
|
def search(self, text, start=0, name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match, end_match=regex.compile('[\0- ]*\(/\|end\)', regex.casefold).match, start_search=regex.compile('[<&]').search, ent_name=regex.compile('[-a-zA-Z0-9_.]+').match, find=find, strip=strip ):
|
def search(self, text, start=0, name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match, end_match=regex.compile('[\0- ]*\(/\|end\)', regex.casefold).match, start_search=regex.compile('[<&]').search, ent_name=regex.compile('[-a-zA-Z0-9_.]+').match, find=find, strip=strip ):
| 2,311
|
def search(self, text, start=0, name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match, end_match=regex.compile('[\0- ]*\(/\|end\)', regex.casefold).match, start_search=regex.compile('[<&]').search, ent_name=regex.compile('[-a-zA-Z0-9_.]+').match, find=find, strip=strip ):
|
def search(self, text, start=0, name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match, end_match=regex.compile('[\0- ]*\(/\|end\)', regex.casefold).match, start_search=regex.compile('[<&]').search, ent_name=regex.compile('[-a-zA-Z0-9_.]+').match, find=find, strip=strip ):
| 2,312
|
def __of__(self, parent): r=imPermissionRole() n=r._p=self._p if hasattr(parent, n): r._d=getattr(parent,n) else: r._d=self._d return r
|
def __of__(self, parent): r=imPermissionRole() r._p=self._p r._pa=parent r._d=self._d return r
| 2,313
|
def __getitem__(self, i): return self._d[i]
|
def __getitem__(self, i): return self._d[i]
| 2,314
|
def LOG(subsystem, severity, summary, detail='', error=None, reraise=None): """Log some information The required arguments are: subsystem -- The subsystem generating the message (e.g. ZODB) severity -- The "severity" of the event. This may be an integer or a floating point number. Logging back ends may consider the int() of this valua to be significant. For example, a backend may consider any severity whos integer value is WARNING to be a warning. summary -- A short summary of the event detail -- A detailed description error -- A three-element tuple consisting of an error type, value, and traceback. If provided, then a summary of the error is added to the detail. reraise -- If provided with a true value, then the error given by error is reraised. """ if _call_initialize: initialize() log_write(subsystem, severity, summary, detail, error) if reraise and error: raise error[0], error[1], error[2]
|
def LOG(subsystem, severity, summary, detail='', error=None, reraise=None): """Log some information The required arguments are: subsystem -- The subsystem generating the message (e.g. ZODB) severity -- The "severity" of the event. This may be an integer or a floating point number. Logging back ends may consider the int() of this value to be significant. For example, a backend may consider any severity whos integer value is WARNING to be a warning. summary -- A short summary of the event detail -- A detailed description error -- A three-element tuple consisting of an error type, value, and traceback. If provided, then a summary of the error is added to the detail. reraise -- If provided with a true value, then the error given by error is reraised. """ if _call_initialize: initialize() log_write(subsystem, severity, summary, detail, error) if reraise and error: raise error[0], error[1], error[2]
| 2,315
|
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):
| 2,316
|
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):
| 2,317
|
def _defaultInput(self,n,t,v): return '<INPUT NAME="%s:%s" SIZE="50" VALUE="%s"></TD>' % (n,t,v)
|
def _defaultInput(self,n,t,v): return '<INPUT NAME="%s:%s" SIZE="50" VALUE="%s"></TD>' % (n,t,v)
| 2,318
|
def _stringInput(self,n,t,v): return ('<INPUT NAME="%s:%s" SIZE="50" VALUE="%s"></TD>'
|
def _stringInput(self,n,t,v): return ('<INPUT NAME="%s:%s" SIZE="50" VALUE="%s"></TD>'
| 2,319
|
def _linesInput(self,n,t,v):
|
def _linesInput(self,n,t,v):
| 2,320
|
def _textInput(self,n,t,v): return ('<TEXTAREA NAME="%s" ROWS="10" COLS="50">%s</TEXTAREA>'
|
def _textInput(self,n,t,v): return ('<TEXTAREA NAME="%s" ROWS="10" COLS="50">%s</TEXTAREA>'
| 2,321
|
def setLocal(self, name, value): if self.locals is self.stack[-1]: # Unmerge this scope's locals from previous scope of first set self.locals = self.locals.copy() self.locals[name] = value
|
def setLocal(self, name, value): if self.locals is self.stack[-1]: # Unmerge this scope's locals from previous scope of first set self.locals = self.locals.copy() self.locals[name] = value
| 2,322
|
def manage_FTPlist(self, REQUEST): "Directory listing for FTP" out=()
|
def manage_FTPlist(self, REQUEST): "Directory listing for FTP" out=()
| 2,323
|
def getPath(prefix, name, checkProduct=1, suffixes=('',)): """Find a file in one of several relative locations Arguments: prefix -- The location, relative to some home, to look for the file name -- The name of the file. This must not be a path. checkProduct -- a flag indicating whether product directories should be used as additional hope ares to be searched. This defaults to a true value. If this is true and the name contains a dot, then the text before the dot is treated as a product name and the product package directory is used as anothe rhome. suffixes -- a sequences of file suffixes to check. By default, the name is used without a suffix. The search takes on multiple homes which are the instance home, the directory containing the directory containing the software home, and possibly product areas. """ d,n = path_split(name) if d: raise ValueError, ( 'The file name, %s, should be a simple file name' % name) if checkProduct: l = name.find('.') if l > 0: p = name[:l] n = name[l + 1:] for product_dir in Products.__path__: r = _getPath(product_dir, os.path.join(p, prefix), n, suffixes) if r is not None: return r import App.config cfg = App.config.getConfiguration() sw=os.path.dirname(os.path.dirname(cfg.softwarehome)) for home in (cfg.instancehome, sw): r=_getPath(home, prefix, name, suffixes) if r is not None: return r
|
def getPath(prefix, name, checkProduct=1, suffixes=('',)): """Find a file in one of several relative locations Arguments: prefix -- The location, relative to some home, to look for the file name -- The name of the file. This must not be a path. checkProduct -- a flag indicating whether product directories should be used as additional hope ares to be searched. This defaults to a true value. If this is true and the name contains a dot, then the text before the dot is treated as a product name and the product package directory is used as anothe rhome. suffixes -- a sequences of file suffixes to check. By default, the name is used without a suffix. The search takes on multiple homes which are the instance home, the directory containing the directory containing the software home, and possibly product areas. """ d,n = path_split(name) if d: raise ValueError, ( 'The file name, %s, should be a simple file name' % name) if checkProduct: l = name.find('.') if l > 0: p = name[:l] n = name[l + 1:] for product_dir in Products.__path__: r = _getPath(product_dir, os.path.join(p, prefix), n, suffixes) if r is not None: result = r import App.config cfg = App.config.getConfiguration() sw=os.path.dirname(os.path.dirname(cfg.softwarehome)) for home in (cfg.instancehome, sw): r=_getPath(home, prefix, name, suffixes) if r is not None: result = r
| 2,324
|
def getPath(prefix, name, checkProduct=1, suffixes=('',)): """Find a file in one of several relative locations Arguments: prefix -- The location, relative to some home, to look for the file name -- The name of the file. This must not be a path. checkProduct -- a flag indicating whether product directories should be used as additional hope ares to be searched. This defaults to a true value. If this is true and the name contains a dot, then the text before the dot is treated as a product name and the product package directory is used as anothe rhome. suffixes -- a sequences of file suffixes to check. By default, the name is used without a suffix. The search takes on multiple homes which are the instance home, the directory containing the directory containing the software home, and possibly product areas. """ d,n = path_split(name) if d: raise ValueError, ( 'The file name, %s, should be a simple file name' % name) if checkProduct: l = name.find('.') if l > 0: p = name[:l] n = name[l + 1:] for product_dir in Products.__path__: r = _getPath(product_dir, os.path.join(p, prefix), n, suffixes) if r is not None: return r import App.config cfg = App.config.getConfiguration() sw=os.path.dirname(os.path.dirname(cfg.softwarehome)) for home in (cfg.instancehome, sw): r=_getPath(home, prefix, name, suffixes) if r is not None: return r
|
def getPath(prefix, name, checkProduct=1, suffixes=('',)): """Find a file in one of several relative locations Arguments: prefix -- The location, relative to some home, to look for the file name -- The name of the file. This must not be a path. checkProduct -- a flag indicating whether product directories should be used as additional hope ares to be searched. This defaults to a true value. If this is true and the name contains a dot, then the text before the dot is treated as a product name and the product package directory is used as anothe rhome. suffixes -- a sequences of file suffixes to check. By default, the name is used without a suffix. The search takes on multiple homes which are the instance home, the directory containing the directory containing the software home, and possibly product areas. """ d,n = path_split(name) if d: raise ValueError, ( 'The file name, %s, should be a simple file name' % name) if checkProduct: l = name.find('.') if l > 0: p = name[:l] n = name[l + 1:] for product_dir in Products.__path__: r = _getPath(product_dir, os.path.join(p, prefix), n, suffixes) if r is not None: return r if result is None: import App.config cfg = App.config.getConfiguration() sw=os.path.dirname(os.path.dirname(cfg.softwarehome)) for home in (cfg.instancehome, sw): r=_getPath(home, prefix, name, suffixes) if r is not None: result = r if result is None: try: l = name.find('.') if l > 0: realName = name[l + 1:] toplevel = name[:l] m = __import__(toplevel) d = os.path.join(m.__path__[0], prefix, realName) for s in suffixes: if s: s="%s.%s" % (d, s) else: s=d if os.path.exists(s): result = s break except: pass return result
| 2,325
|
def _warn_nobody(): zLOG.LOG("z2", zLOG.INFO, ("Running Zope as 'nobody' can compromise " "your Zope files; consider using a " "dedicated user account for Zope") )
|
def _warn_nobody(): zLOG.LOG("z2", zLOG.INFO, ("Running Zope as 'nobody' can compromise " "your Zope files; consider using a " "dedicated user account for Zope") )
| 2,326
|
def rfc1123_date(t=None, time=time, asctime=asctime, gmtime=gmtime, split=split): # Return an RFC 1123 format date string. t=split(asctime(gmtime(t or time()))) return '%s, %s %s %s %s GMT' % (t[0],t[2],t[1],t[3],t[4])
|
def rfc1123_date(t=None, time=time, asctime=asctime, gmtime=gmtime, split=split): # Return an RFC 1123 format date string. t=split(asctime(gmtime(t or time()))) return '%s, %s %s %s %s GMT' % (t[0],t[2],t[1],t[4],t[3])
| 2,327
|
def default_input_form(id,arguments,action='query', tabs=''): if arguments: items=arguments.items() return ( "%s\n%s%s" % ( '<html><head><title>%s Input Data</title></head><body>\n%s\n' '<form action="<dtml-var URL2>/<dtml-var id>/%s" ' 'method="get">\n' '<h2>%s Input Data</h2>\n' 'Enter query parameters:<br>' '<table>\n' % (id, tabs, action,id), string.joinfields( map( lambda a: ('<tr> <th>%s</th>\n' ' <td><input name="%s"\n' ' width=30 value="%s">' ' </td></tr>' % (nicify(a[0]), ( a[1].has_key('type') and ("%s:%s" % (a[0],a[1]['type'])) or a[0] ), a[1].has_key('default') and a[1]['default'] or '' )) , items ), '\n'), '\n<tr><td colspan=2 align=center>\n' '<input type="SUBMIT" name="SUBMIT" value="Submit Query">\n' '<dtml-if HTTP_REFERER>\n' ' <input type="SUBMIT" name="SUBMIT" value="Cancel">\n' ' <INPUT NAME="CANCEL_ACTION" TYPE="HIDDEN"\n' ' VALUE="<dtml-var HTTP_REFERER>">\n' '</dtml-if>\n' '</td></tr>\n</table>\n</form>\n</body>\n</html>\n' ) ) else: return ( '<html><head><title>%s Input Data</title></head><body>\n%s\n' '<form action="<dtml-var URL2>/<dtml-var id>/%s" ' 'method="get">\n' '<h2>%s Input Data</h2>\n' 'This query requires no input.<p>\n' '<input type="SUBMIT" name="SUBMIT" value="Submit Query">\n' '<dtml-if HTTP_REFERER>\n' ' <input type="SUBMIT" name="SUBMIT" value="Cancel">\n' ' <INPUT NAME="CANCEL_ACTION" TYPE="HIDDEN"\n' ' VALUE="<dtml-var HTTP_REFERER>">\n' '</dtml-if>\n' '</td></tr>\n</table>\n</form>\n</body>\n</html>\n' % (id, tabs, action, id) )
|
def default_input_form(id,arguments,action='query', tabs=''): if arguments: items=arguments.items() return ( "%s\n%s%s" % ( '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">\n' '<html lang="en"><head><title>%s Input Data</title></head>\n' '<body bgcolor=" '<form action="<dtml-var URL2>/<dtml-var id>/%s" ' 'method="get">\n' '<h2>%s Input Data</h2>\n' 'Enter query parameters:<br>' '<table>\n' % (id, tabs, action,id), string.joinfields( map( lambda a: ('<tr> <th>%s</th>\n' ' <td><input name="%s"\n' ' width=30 value="%s">' ' </td></tr>' % (nicify(a[0]), ( a[1].has_key('type') and ("%s:%s" % (a[0],a[1]['type'])) or a[0] ), a[1].has_key('default') and a[1]['default'] or '' )) , items ), '\n'), '\n<tr><td colspan=2 align=center>\n' '<input type="SUBMIT" name="SUBMIT" value="Submit Query">\n' '<dtml-if HTTP_REFERER>\n' ' <input type="SUBMIT" name="SUBMIT" value="Cancel">\n' ' <INPUT NAME="CANCEL_ACTION" TYPE="HIDDEN"\n' ' VALUE="<dtml-var HTTP_REFERER>">\n' '</dtml-if>\n' '</td></tr>\n</table>\n</form>\n</body>\n</html>\n' ) ) else: return ( '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">\n' '<html lang="en"><head><title>%s Input Data</title></head>\n' '<body bgcolor=" '<form action="<dtml-var URL2>/<dtml-var id>/%s" ' 'method="get">\n' '<h2>%s Input Data</h2>\n' 'This query requires no input.<p>\n' '<input type="SUBMIT" name="SUBMIT" value="Submit Query">\n' '<dtml-if HTTP_REFERER>\n' ' <input type="SUBMIT" name="SUBMIT" value="Cancel">\n' ' <INPUT NAME="CANCEL_ACTION" TYPE="HIDDEN"\n' ' VALUE="<dtml-var HTTP_REFERER>">\n' '</dtml-if>\n' '</td></tr>\n</table>\n</form>\n</body>\n</html>\n' % (id, tabs, action, id) )
| 2,328
|
def default_input_form(id,arguments,action='query', tabs=''): if arguments: items=arguments.items() return ( "%s\n%s%s" % ( '<html><head><title>%s Input Data</title></head><body>\n%s\n' '<form action="<dtml-var URL2>/<dtml-var id>/%s" ' 'method="get">\n' '<h2>%s Input Data</h2>\n' 'Enter query parameters:<br>' '<table>\n' % (id, tabs, action,id), string.joinfields( map( lambda a: ('<tr> <th>%s</th>\n' ' <td><input name="%s"\n' ' width=30 value="%s">' ' </td></tr>' % (nicify(a[0]), ( a[1].has_key('type') and ("%s:%s" % (a[0],a[1]['type'])) or a[0] ), a[1].has_key('default') and a[1]['default'] or '' )) , items ), '\n'), '\n<tr><td colspan=2 align=center>\n' '<input type="SUBMIT" name="SUBMIT" value="Submit Query">\n' '<dtml-if HTTP_REFERER>\n' ' <input type="SUBMIT" name="SUBMIT" value="Cancel">\n' ' <INPUT NAME="CANCEL_ACTION" TYPE="HIDDEN"\n' ' VALUE="<dtml-var HTTP_REFERER>">\n' '</dtml-if>\n' '</td></tr>\n</table>\n</form>\n</body>\n</html>\n' ) ) else: return ( '<html><head><title>%s Input Data</title></head><body>\n%s\n' '<form action="<dtml-var URL2>/<dtml-var id>/%s" ' 'method="get">\n' '<h2>%s Input Data</h2>\n' 'This query requires no input.<p>\n' '<input type="SUBMIT" name="SUBMIT" value="Submit Query">\n' '<dtml-if HTTP_REFERER>\n' ' <input type="SUBMIT" name="SUBMIT" value="Cancel">\n' ' <INPUT NAME="CANCEL_ACTION" TYPE="HIDDEN"\n' ' VALUE="<dtml-var HTTP_REFERER>">\n' '</dtml-if>\n' '</td></tr>\n</table>\n</form>\n</body>\n</html>\n' % (id, tabs, action, id) )
|
def default_input_form(id,arguments,action='query', tabs=''): if arguments: items=arguments.items() return ( "%s\n%s%s" % ( '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">\n' '<html lang="en"><head><title>%s Input Data</title></head>\n' '<body bgcolor=" '<form action="<dtml-var URL2>/<dtml-var id>/%s" ' 'method="get">\n' '<h2>%s Input Data</h2>\n' 'Enter query parameters:<br>' '<table>\n' % (id, tabs, action,id), string.joinfields( map( lambda a: ('<tr> <th>%s</th>\n' ' <td><input name="%s"\n' ' width=30 value="%s">' ' </td></tr>' % (nicify(a[0]), ( a[1].has_key('type') and ("%s:%s" % (a[0],a[1]['type'])) or a[0] ), a[1].has_key('default') and a[1]['default'] or '' )) , items ), '\n'), '\n<tr><td colspan=2 align=center>\n' '<input type="SUBMIT" name="SUBMIT" value="Submit Query">\n' '<dtml-if HTTP_REFERER>\n' ' <input type="SUBMIT" name="SUBMIT" value="Cancel">\n' ' <INPUT NAME="CANCEL_ACTION" TYPE="HIDDEN"\n' ' VALUE="<dtml-var HTTP_REFERER>">\n' '</dtml-if>\n' '</td></tr>\n</table>\n</form>\n</body>\n</html>\n' ) ) else: return ( '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">\n' '<html lang="en"><head><title>%s Input Data</title></head>\n' '<body bgcolor=" '<form action="<dtml-var URL2>/<dtml-var id>/%s" ' 'method="get">\n' '<h2>%s Input Data</h2>\n' 'This query requires no input.<p>\n' '<input type="SUBMIT" name="SUBMIT" value="Submit Query">\n' '<dtml-if HTTP_REFERER>\n' ' <input type="SUBMIT" name="SUBMIT" value="Cancel">\n' ' <INPUT NAME="CANCEL_ACTION" TYPE="HIDDEN"\n' ' VALUE="<dtml-var HTTP_REFERER>">\n' '</dtml-if>\n' '</td></tr>\n</table>\n</form>\n</body>\n</html>\n' % (id, tabs, action, id) )
| 2,329
|
def _getTargetClass( self ):
|
def _getTargetClass( self ):
| 2,330
|
def initialize(context): # abuse registerClass to get a tutorial constructor # in the product add list context.registerClass( None, meta_type='Zope Tutorial', constructors=(TutorialTopic.addTutorialForm, TutorialTopic.addTutorial), ) # create tutorial help topics lesson_path=os.path.join(App.Common.package_home(globals()), 'tutorial.stx') glossary_path=os.path.join(App.Common.package_home(globals()), 'glossary.stx') help=context.getProductHelp() # test to see if nothing has changed since last registration if help.lastRegistered is not None and \ help.lastRegistered >= DateTime(os.stat(lesson_path)[stat.ST_MTIME]): return help.lastRegistered=DateTime() # delete old help topics for id in help.objectIds('Help Topic'): help._delObject(id) # create glossary text=open(glossary_path).read() text=term_pat.sub(defineTerm, text) glossary=TutorialTopic.TutorialTopic('glossary', 'Zope Tutorial Glossary', text) # create lessons f=open(lesson_path) lines=[] id=0 while 1: line = f.readline() if (string.strip(line) and string.find(line, ' ') != 0) or line=='': # new topic if lines: id = id + 1 topic_id = 'topic_%d' % id text=string.join(lines[1:], '') text=term_pat.sub(glossaryTerm, text) topic=TutorialTopic.TutorialTopic(topic_id, string.strip(lines[0]), text) context.registerHelpTopic(topic_id, topic) lines=[line] else: lines.append(line) if line == '': break f.close() # register glossary last context.registerHelpTopic('glossary', glossary)
|
def initialize(context): # abuse registerClass to get a tutorial constructor # in the product add list context.registerClass( None, meta_type='Zope Tutorial', constructors=(TutorialTopic.addTutorialForm, TutorialTopic.addTutorial), ) # create tutorial help topics lesson_path=os.path.join(App.Common.package_home(globals()), 'tutorial.stx') glossary_path=os.path.join(App.Common.package_home(globals()), 'glossary.stx') help=context.getProductHelp() # test to see if nothing has changed since last registration if help.lastRegistered is not None and \ help.lastRegistered >= DateTime(os.stat(lesson_path)[stat.ST_MTIME]): return help.lastRegistered=DateTime() # delete old help topics for id in help.objectIds('Help Topic'): help._delObject(id) # create glossary text=open(glossary_path).read() text=term_pat.sub(defineTerm, text) glossary=TutorialTopic.TutorialTopic('glossary', 'Zope Tutorial Glossary', text) # create lessons f=open(lesson_path) lines=[] id=0 while 1: line = f.readline() if (string.strip(line) and string.find(line, ' ') != 0) or line=='': # new topic if lines: id = id + 1 topic_id = 'topic_%02d' % id text=string.join(lines[1:], '') text=term_pat.sub(glossaryTerm, text) topic=TutorialTopic.TutorialTopic(topic_id, string.strip(lines[0]), text) context.registerHelpTopic(topic_id, topic) lines=[line] else: lines.append(line) if line == '': break f.close() # register glossary last context.registerHelpTopic('glossary', glossary)
| 2,331
|
def decapitate(html, RESPONSE=None): headers = [] spos = 0 eolen = 1 while 1: m = hdr_start(html, spos) if not m: if html[spos:spos+2] == '\r\n': eolen = 2 break if html[spos:spos+1] == '\n': eolen = 1 break return html header = list(m.groups()) headers.append(header) spos = m.end() + 1 while spos < len(html) and html[spos] in ' \t': eol = find(html, '\r\n', spos) if eol <> -1: eolen = 2 else: eol = find(html, '\n', spos) if eol < 0: return html eolen = 1 header.append(strip(html[spos:eol])) spos = eol + eolen if RESPONSE is not None: for header in headers: hkey = header.pop(0) RESPONSE.setHeader(hkey, ' '.join(header).strip()) return html[spos + eolen:]
|
def decapitate(html, RESPONSE=None): headers = [] spos = 0 eolen = 1 while 1: m = hdr_start(html, spos) if not m: if html[spos:spos+2] == '\r\n': eolen = 2 break if html[spos:spos+1] == '\n': eolen = 1 break return html header = list(m.groups()) headers.append(header) spos = m.end() + 1 while spos < len(html) and html[spos] in ' \t': eol = html.find('\r\n', spos) if eol <> -1: eolen = 2 else: eol = find(html, '\n', spos) if eol < 0: return html eolen = 1 header.append(strip(html[spos:eol])) spos = eol + eolen if RESPONSE is not None: for header in headers: hkey = header.pop(0) RESPONSE.setHeader(hkey, ' '.join(header).strip()) return html[spos + eolen:]
| 2,332
|
def decapitate(html, RESPONSE=None): headers = [] spos = 0 eolen = 1 while 1: m = hdr_start(html, spos) if not m: if html[spos:spos+2] == '\r\n': eolen = 2 break if html[spos:spos+1] == '\n': eolen = 1 break return html header = list(m.groups()) headers.append(header) spos = m.end() + 1 while spos < len(html) and html[spos] in ' \t': eol = find(html, '\r\n', spos) if eol <> -1: eolen = 2 else: eol = find(html, '\n', spos) if eol < 0: return html eolen = 1 header.append(strip(html[spos:eol])) spos = eol + eolen if RESPONSE is not None: for header in headers: hkey = header.pop(0) RESPONSE.setHeader(hkey, ' '.join(header).strip()) return html[spos + eolen:]
|
def decapitate(html, RESPONSE=None): headers = [] spos = 0 eolen = 1 while 1: m = hdr_start(html, spos) if not m: if html[spos:spos+2] == '\r\n': eolen = 2 break if html[spos:spos+1] == '\n': eolen = 1 break return html header = list(m.groups()) headers.append(header) spos = m.end() + 1 while spos < len(html) and html[spos] in ' \t': eol = find(html, '\r\n', spos) if eol <> -1: eolen = 2 else: eol = html.find( '\n', spos) if eol < 0: return html eolen = 1 header.append(strip(html[spos:eol])) spos = eol + eolen if RESPONSE is not None: for header in headers: hkey = header.pop(0) RESPONSE.setHeader(hkey, ' '.join(header).strip()) return html[spos + eolen:]
| 2,333
|
def decapitate(html, RESPONSE=None): headers = [] spos = 0 eolen = 1 while 1: m = hdr_start(html, spos) if not m: if html[spos:spos+2] == '\r\n': eolen = 2 break if html[spos:spos+1] == '\n': eolen = 1 break return html header = list(m.groups()) headers.append(header) spos = m.end() + 1 while spos < len(html) and html[spos] in ' \t': eol = find(html, '\r\n', spos) if eol <> -1: eolen = 2 else: eol = find(html, '\n', spos) if eol < 0: return html eolen = 1 header.append(strip(html[spos:eol])) spos = eol + eolen if RESPONSE is not None: for header in headers: hkey = header.pop(0) RESPONSE.setHeader(hkey, ' '.join(header).strip()) return html[spos + eolen:]
|
def decapitate(html, RESPONSE=None): headers = [] spos = 0 eolen = 1 while 1: m = hdr_start(html, spos) if not m: if html[spos:spos+2] == '\r\n': eolen = 2 break if html[spos:spos+1] == '\n': eolen = 1 break return html header = list(m.groups()) headers.append(header) spos = m.end() + 1 while spos < len(html) and html[spos] in ' \t': eol = find(html, '\r\n', spos) if eol <> -1: eolen = 2 else: eol = find(html, '\n', spos) if eol < 0: return html eolen = 1 header.append(html[spos:eol].strip()) spos = eol + eolen if RESPONSE is not None: for header in headers: hkey = header.pop(0) RESPONSE.setHeader(hkey, ' '.join(header).strip()) return html[spos + eolen:]
| 2,334
|
def resolve_url(self, url): # Attempt to resolve a url into an object in the Zope # namespace. The url must be a fully-qualified url. The # method will return the requested object if it is found # or raise the same HTTP error that would be raised in # the case of a real web request. If the passed in url # does not appear to describe an object in the system # namespace (e.g. the host, port or script name dont # match that of the current request), a ValueError will # be raised. if find(url, self.script) != 0: raise ValueError, 'Different namespace.' path=url[len(self.script):] while path and path[0]=='/': path=path[1:] while path and path[-1]=='/': path=path[:-1] req=self.clone() rsp=req.response req['PATH_INFO']=path object=None try: object=req.traverse(path) except: rsp.exception(0) if object is not None: # waaa - traversal may return a "default object" # like an index_html document, though you really # wanted to get a Folder back :( if callable(object.id): name=object.id() else: name=object.id if name != os.path.split(path)[-1] and \ hasattr(object, 'aq_parent'): return object.aq_parent return object raise rsp.errmsg, sys.exc_value
|
def resolve_url(self, url): # Attempt to resolve a url into an object in the Zope # namespace. The url must be a fully-qualified url. The # method will return the requested object if it is found # or raise the same HTTP error that would be raised in # the case of a real web request. If the passed in url # does not appear to describe an object in the system # namespace (e.g. the host, port or script name dont # match that of the current request), a ValueError will # be raised. if find(url, self.script) != 0: raise ValueError, 'Different namespace.' path=url[len(self.script):] while path and path[0]=='/': path=path[1:] while path and path[-1]=='/': path=path[:-1] req=self.clone() rsp=req.response req['PATH_INFO']=path object=None try: object=req.traverse(path) except: rsp.exception(0) if object is not None: # waaa - traversal may return a "default object" # like an index_html document, though you really # wanted to get a Folder back :( if hasattr(object, 'id'): if callable(object.id): name=object.id() else: name=object.id elif hasattr(object, '__name__'): name=object.__name__ else: name='' if name != os.path.split(path)[-1]: return req.PARENTS[0] return object raise rsp.errmsg, sys.exc_value
| 2,335
|
def manage_addFile(self,id,file,title='',precondition='',REQUEST=None): """Add a new File object. Creates a new File object 'id' with the contents of 'file'""" id, title = cookId(id, title, file) self._setObject(id, File(id,title,file,precondition)) if REQUEST is not None: return self.manage_main(self,REQUEST)
|
def manage_addFile(self,id,file,title='',precondition='',REQUEST=None): """Add a new File object. Creates a new File object 'id' with the contents of 'file'""" id, title = cookId(id, title, file) self._setObject(id, File(id,title,file,precondition)) if REQUEST is not None: return self.manage_main(self,REQUEST)
| 2,336
|
def tearDown(self): try: os.remove(self.path) except os.error: pass if os.environ.has_key('STUPID_LOG_FILE'): del os.environ['STUPID_LOG_FILE'] if os.environ.has_key('EVENT_LOG_FILE'): del os.environ['EVENT_LOG_FILE'] if os.environ.has_key('STUPID_LOG_SEVERITY'): del os.environ['STUPID_LOG_SEVERITY'] if os.environ.has_key('EVENT_LOG_SEVERITY'): del os.environ['EVENT_LOG_SEVERITY']
|
def tearDown(self): try: os.remove(self.path) except os.error: pass if os.environ.has_key('STUPID_LOG_FILE'): del os.environ['STUPID_LOG_FILE'] if os.environ.has_key('EVENT_LOG_FILE'): del os.environ['EVENT_LOG_FILE'] if os.environ.has_key('STUPID_LOG_SEVERITY'): del os.environ['STUPID_LOG_SEVERITY'] if os.environ.has_key('EVENT_LOG_SEVERITY'): del os.environ['EVENT_LOG_SEVERITY']
| 2,337
|
def database_size(self): try: db=self._p_jar.db() except: # BoboPOS2 return len(Globals.Bobobase._jar.db.index)*4 else: return db.getSize()
|
def database_size(self): try: db=self._p_jar.db() except: # BoboPOS2 return len(Globals.Bobobase._jar.db.index)*4 else: return db.getSize()
| 2,338
|
def recordMetaData(self, object, request, # Optimize global var lookups: hasattr=hasattr, getattr=getattr, logger=ac_logger, ): request_get = request.get if hasattr(object, 'getPhysicalPath'): path = '/'.join(object.getPhysicalPath()) else: # Try hard to get the physical path of the object, # but there are many circumstances where that's not possible. to_append = ()
|
def recordMetaData(self, object, request, # Optimize global var lookups: hasattr=hasattr, getattr=getattr, logger=ac_logger, ): request_get = request.get if hasattr(object, 'getPhysicalPath'): path = '/'.join(object.getPhysicalPath()) else: # Try hard to get the physical path of the object, # but there are many circumstances where that's not possible. to_append = ()
| 2,339
|
def traverse(self, path, response=None): """Traverse the object space
|
def traverse(self, path, response=None): """Traverse the object space
| 2,340
|
def manage_exportObject(self,id=None,download=None,RESPONSE=None): """Exports an object to a file and returns that file.""" if id is None: o=self else: o=getattr(self,id) if download: f=StringIO() o._p_jar.export_file(o,f) RESPONSE.setHeader('Content-type','application/data') RESPONSE.setHeader('Content-Disposition', 'inline;filename=%s.bbe' % id) return f.getvalue() f=Globals.data_dir+'/%s.bbe' % id o._p_jar.export_file(o,f) if RESPONSE is not None: return MessageDialog( title="Object exported", message="<EM>%s</EM> sucessfully\ exported to <pre>%s</pre>." % (id,f), action="manage_main")
|
def manage_exportObject(self, id='', download=None, RESPONSE=None): """Exports an object to a file and returns that file.""" if id is None: o=self else: o=getattr(self,id) if download: f=StringIO() o._p_jar.export_file(o,f) RESPONSE.setHeader('Content-type','application/data') RESPONSE.setHeader('Content-Disposition', 'inline;filename=%s.bbe' % id) return f.getvalue() f=Globals.data_dir+'/%s.bbe' % id o._p_jar.export_file(o,f) if RESPONSE is not None: return MessageDialog( title="Object exported", message="<EM>%s</EM> sucessfully\ exported to <pre>%s</pre>." % (id,f), action="manage_main")
| 2,341
|
def manage_exportObject(self,id=None,download=None,RESPONSE=None): """Exports an object to a file and returns that file.""" if id is None: o=self else: o=getattr(self,id) if download: f=StringIO() o._p_jar.export_file(o,f) RESPONSE.setHeader('Content-type','application/data') RESPONSE.setHeader('Content-Disposition', 'inline;filename=%s.bbe' % id) return f.getvalue() f=Globals.data_dir+'/%s.bbe' % id o._p_jar.export_file(o,f) if RESPONSE is not None: return MessageDialog( title="Object exported", message="<EM>%s</EM> sucessfully\ exported to <pre>%s</pre>." % (id,f), action="manage_main")
|
def manage_exportObject(self,id=None,download=None,RESPONSE=None): """Exports an object to a file and returns that file.""" if not id: id=self.id if callable(id): id=id() ob=self else: ob=getattr(self,id) if download: f=StringIO() o._p_jar.export_file(o,f) RESPONSE.setHeader('Content-type','application/data') RESPONSE.setHeader('Content-Disposition', 'inline;filename=%s.bbe' % id) return f.getvalue() f=Globals.data_dir+'/%s.bbe' % id o._p_jar.export_file(o,f) if RESPONSE is not None: return MessageDialog( title="Object exported", message="<EM>%s</EM> sucessfully\ exported to <pre>%s</pre>." % (id,f), action="manage_main")
| 2,342
|
def manage_exportObject(self,id=None,download=None,RESPONSE=None): """Exports an object to a file and returns that file.""" if id is None: o=self else: o=getattr(self,id) if download: f=StringIO() o._p_jar.export_file(o,f) RESPONSE.setHeader('Content-type','application/data') RESPONSE.setHeader('Content-Disposition', 'inline;filename=%s.bbe' % id) return f.getvalue() f=Globals.data_dir+'/%s.bbe' % id o._p_jar.export_file(o,f) if RESPONSE is not None: return MessageDialog( title="Object exported", message="<EM>%s</EM> sucessfully\ exported to <pre>%s</pre>." % (id,f), action="manage_main")
|
def manage_exportObject(self,id=None,download=None,RESPONSE=None): """Exports an object to a file and returns that file.""" if id is None: o=self else: o=getattr(self,id) if download: f=StringIO() ob._p_jar.export_file(ob, f) RESPONSE.setHeader('Content-type','application/data') RESPONSE.setHeader('Content-Disposition', 'inline;filename=%s.bbe' % id) return f.getvalue() f=Globals.data_dir+'/%s.bbe' % id ob._p_jar.export_file(ob, f) if RESPONSE is not None: return MessageDialog( title="Object exported", message="<EM>%s</EM> sucessfully\ exported to <pre>%s</pre>." % (id,f), action="manage_main")
| 2,343
|
def manage_exportObject(self,id=None,download=None,RESPONSE=None): """Exports an object to a file and returns that file.""" if id is None: o=self else: o=getattr(self,id) if download: f=StringIO() o._p_jar.export_file(o,f) RESPONSE.setHeader('Content-type','application/data') RESPONSE.setHeader('Content-Disposition', 'inline;filename=%s.bbe' % id) return f.getvalue() f=Globals.data_dir+'/%s.bbe' % id o._p_jar.export_file(o,f) if RESPONSE is not None: return MessageDialog( title="Object exported", message="<EM>%s</EM> sucessfully\ exported to <pre>%s</pre>." % (id,f), action="manage_main")
|
def manage_exportObject(self,id=None,download=None,RESPONSE=None): """Exports an object to a file and returns that file.""" if id is None: o=self else: o=getattr(self,id) if download: f=StringIO() ob._p_jar.export_file(ob, f) RESPONSE.setHeader('Content-type','application/data') RESPONSE.setHeader('Content-Disposition', 'inline;filename=%s.bbe' % id) return f.getvalue() f=Globals.data_dir+'/%s.bbe' % id ob._p_jar.export_file(ob, f) if RESPONSE is not None: return MessageDialog( title="Object exported", message="<EM>%s</EM> sucessfully\ exported to <pre>%s</pre>." % (id,f), action="manage_main")
| 2,344
|
def manage_exportObject(self,id=None,download=None,RESPONSE=None): """Exports an object to a file and returns that file.""" if id is None: o=self else: o=getattr(self,id) if download: f=StringIO() o._p_jar.export_file(o,f) RESPONSE.setHeader('Content-type','application/data') RESPONSE.setHeader('Content-Disposition', 'inline;filename=%s.bbe' % id) return f.getvalue() f=Globals.data_dir+'/%s.bbe' % id o._p_jar.export_file(o,f) if RESPONSE is not None: return MessageDialog( title="Object exported", message="<EM>%s</EM> sucessfully\ exported to <pre>%s</pre>." % (id,f), action="manage_main")
|
def manage_exportObject(self,id=None,download=None,RESPONSE=None): """Exports an object to a file and returns that file.""" if id is None: o=self else: o=getattr(self,id) if download: f=StringIO() o._p_jar.export_file(o,f) RESPONSE.setHeader('Content-type','application/data') RESPONSE.setHeader('Content-Disposition', 'inline;filename=%s.bbe' % id) return f.getvalue() f=Globals.data_dir+'/%s.bbe' % id o._p_jar.export_file(o,f) if RESPONSE is not None: return MessageDialog( title="Object exported", message="<EM>%s</EM> sucessfully\ exported to <pre>%s</pre>." % (id, f), action="manage_main")
| 2,345
|
def __init__(self, parent, id): self.id=id self.__parent__=parent self.__roles__ =parent.PUT__roles__
|
def __init__(self, parent, id): self.id=id self.__parent__=parent self.__roles__ =parent.PUT__roles__
| 2,346
|
def PUT(self, REQUEST, RESPONSE): """Adds a document, image or file to the folder when a PUT request is received.""" name=self.id type=REQUEST.get_header('content-type', None) body=REQUEST.get('BODY', '') if type is None: type, enc=mimetypes.guess_type(name) if type is None: if content_types.find_binary(body) >= 0: raise 'Bad Request', 'Unknown content type' else: type=content_types.text_type(body) type=lower(type) if type in ('text/html', 'text/xml', 'text/plain'): self.__parent__.manage_addDTMLDocument(name, '', body) elif type[:6]=='image/': ob=Image(name, '', body, content_type=type) self.__parent__._setObject(name, ob) else: ob=File(name, '', body, content_type=type) self.__parent__._setObject(name, ob) RESPONSE.setStatus(201) RESPONSE.setBody('') return RESPONSE
|
def PUT(self, REQUEST, RESPONSE): """Adds a document, image or file to the folder when a PUT request is received.""" name=self.id type=REQUEST.get_header('content-type', None) body=REQUEST.get('BODY', '') if type is None: type, enc=mimetypes.guess_type(name) if type is None: if content_types.find_binary(body) >= 0: content_type='application/octet-stream' else: type=content_types.text_type(body) type=lower(type) if type in ('text/html', 'text/xml', 'text/plain'): self.__parent__.manage_addDTMLDocument(name, '', body) elif type[:6]=='image/': ob=Image(name, '', body, content_type=type) self.__parent__._setObject(name, ob) else: ob=File(name, '', body, content_type=type) self.__parent__._setObject(name, ob) RESPONSE.setStatus(201) RESPONSE.setBody('') return RESPONSE
| 2,347
|
def scrub(list, dirname, filelist): for name in filelist: if name in EXCLUDED_NAMES: continue prefix, ext = os.path.splitext(name) if ext == '.pyo' or ext == '.pyc': full = os.path.join(dirname, name) os.unlink(full) filelist.remove(name) if DEBUG: print full
|
def scrub(list, dirname, filelist): for name in filelist: if name in EXCLUDED_NAMES: continue prefix, ext = os.path.splitext(name) if ext == '.pyo' or ext == '.pyc': full = os.path.join(dirname, name) os.unlink(full) if DEBUG: print full
| 2,348
|
def usage(): usage = ("""
|
def usage(): usage = ("""
| 2,349
|
def usage(): usage = ("""
|
def usage(): usage = ("""
| 2,350
|
def usage(): usage = ("""
|
def usage(): usage = ("""
| 2,351
|
def __init__(self, vocabulary=None, brains=None): # Catalogs no longer care about vocabularies and lexicons # so the vocabulary argument is ignored. (Casey)
|
def __init__(self, vocabulary=None, brains=None): # Catalogs no longer care about vocabularies and lexicons # so the vocabulary argument is ignored. (Casey)
| 2,352
|
def clear(self): """ clear catalog """
|
def clear(self): """ clear catalog """
| 2,353
|
def logBadRefresh(productid): exc = sys.exc_info() try: logger.error('Exception while refreshing %s' % productid, exc_info=exc) if hasattr(exc[0], '__name__'): error_type = exc[0].__name__ else: error_type = str(exc[0]) error_value = str(exc[1]) info = ''.join(format_exception(exc[0], exc[1], exc[2], limit=200)) refresh_exc_info[productid] = (error_type, error_value, info) finally: exc = None
|
def logBadRefresh(productid): exc = sys.exc_info() try: logger.error('Exception while refreshing %s' % productid, exc_info=True) if hasattr(exc[0], '__name__'): error_type = exc[0].__name__ else: error_type = str(exc[0]) error_value = str(exc[1]) info = ''.join(format_exception(exc[0], exc[1], exc[2], limit=200)) refresh_exc_info[productid] = (error_type, error_value, info) finally: exc = None
| 2,354
|
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' 'To use localization options, you must ensure\n' 'that the locale module is compiled into your\n' 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The specified locale is not supported by your system.\n' 'See your operating system documentation for more\n' 'information on locale support.' )
|
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' 'To use localization options, you must ensure\n' 'that the locale module is compiled into your\n' 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The specified locale is not supported by your system.\n' 'See your operating system documentation for more\n' 'information on locale support.' )
| 2,355
|
def _indexedSearch(self, args, sort_index, append, used):
|
def _indexedSearch(self, args, sort_index, append, used):
| 2,356
|
def package_home(globals_dict): __name__=globals_dict['__name__'] m=sys.modules[__name__] if hasattr(m,'__path__'): return m.__path__[0] return sys.modules[__name__[:rfind(__name__,'.')]].__path__[0]
|
def package_home(globals_dict): __name__=globals_dict['__name__'] m=sys.modules[__name__] if hasattr(m,'__path__'): return m.__path__[0] return sys.modules[__name__[:rfind(__name__,'.')]].__path__[0]
| 2,357
|
def allowed(self, parent, roles=None): """Check whether the user has access to parent, assuming that parent.__roles__ is the given roles.""" if roles is None or 'Anonymous' in roles: return 1 usr_roles=self.getRolesInContext(parent) for role in roles: if role in usr_roles: if (hasattr(self,'aq_parent') and hasattr(self.aq_parent,'aq_parent')): if parent is None: return 1 if (not hasattr(parent, 'aq_inContextOf') and hasattr(parent, 'im_self')): # This is a method, grab it's self. parent=parent.im_self if not parent.aq_inContextOf(self.aq_parent.aq_parent,1): if 'Shared' in roles: # Damn, old role setting. Waaa roles=self._shared_roles(parent) if 'Anonymous' in roles: return 1 return None return 1
|
def allowed(self, parent, roles=None): """Check whether the user has access to parent, assuming that parent.__roles__ is the given roles.""" if roles is None or 'Anonymous' in roles: return 1 usr_roles=self.getRolesInContext(parent) for role in roles: if role in usr_roles: if (hasattr(self,'aq_parent') and hasattr(self.aq_parent,'aq_parent')): if parent is None: return 1 if (not hasattr(parent, 'aq_inContextOf') and hasattr(parent, 'im_self')): # This is a method, grab it's self. parent=parent.im_self if (hasattr(parent, 'aq_inContextOf') and not parent.aq_inContextOf(self.aq_parent.aq_parent,1)): if 'Shared' in roles: # Damn, old role setting. Waaa roles=self._shared_roles(parent) if 'Anonymous' in roles: return 1 return None return 1
| 2,358
|
def careful_hasattr(md, inst, name): get = md.guarded_getattr if get is None: get = getattr try: get(inst, name) except (AttributeError, ValidationError): return 0 else: return 1
|
def careful_hasattr(md, inst, name): get = md.guarded_getattr if get is None: get = getattr try: get(inst, name) except (AttributeError, ValidationError, KeyError): return 0 else: return 1
| 2,359
|
def connected(self):
|
def connected(self):
| 2,360
|
def __bobo_traverse__(self, REQUEST, key):
|
def __bobo_traverse__(self, REQUEST, key):
| 2,361
|
def __getattr__(self, name):
|
def __getattr__(self, name):
| 2,362
|
def __getattr__(self, name):
|
def __getattr__(self, name):
| 2,363
|
def __init__(self,(items,data),brains=NoBrains, parent=None, zbrains=None):
|
def __init__(self,(items,data),brains=NoBrains, parent=None, zbrains=None):
| 2,364
|
def _apply_index(self, request):
|
def _apply_index(self, request):
| 2,365
|
def hs_search_mod(self, mod, dict): # Root through a module for things that look like # createable object classes. hidden=('Control Panel', 'Principia Draft', 'simple item') for k, v in mod.__dict__.items(): if is_class(v) and hasattr(v, 'meta_type') and \ hasattr(v, '__ac_permissions__') and \ (v.meta_type not in hidden): dict[v.meta_type]=ObjectItem(k, v) if is_module(v) and hasattr(v, '__path__'): dict=self.hs_search_mod(v, dict) return dict
|
def hs_search_mod(self, mod, dict): # Root through a module for things that look like # createable object classes. hidden=('Control Panel', 'Principia Draft', 'simple item', 'Broken Because Product is Gone') for k, v in mod.__dict__.items(): if is_class(v) and hasattr(v, 'meta_type') and \ hasattr(v, '__ac_permissions__') and \ (v.meta_type not in hidden): dict[v.meta_type]=ObjectItem(k, v) if is_module(v) and hasattr(v, '__path__'): dict=self.hs_search_mod(v, dict) return dict
| 2,366
|
def hs_search_mod(self, mod, dict): # Root through a module for things that look like # createable object classes. hidden=('Control Panel', 'Principia Draft', 'simple item') for k, v in mod.__dict__.items(): if is_class(v) and hasattr(v, 'meta_type') and \ hasattr(v, '__ac_permissions__') and \ (v.meta_type not in hidden): dict[v.meta_type]=ObjectItem(k, v) if is_module(v) and hasattr(v, '__path__'): dict=self.hs_search_mod(v, dict) return dict
|
def hs_search_mod(self, mod, dict): # Root through a module for things that look like # createable object classes. hidden=('Control Panel', 'Principia Draft', 'simple item') for k, v in mod.__dict__.items(): if is_class(v) and hasattr(v, 'meta_type') and \ hasattr(v, '__ac_permissions__'): if callable(v.meta_type): try: meta_type=v.meta_type() except: meta_type=None else: meta_type=v.meta_type if (meta_type is not None) and (meta_type not in hidden): dict[meta_type]=ObjectItem(k, v) if is_module(v) and hasattr(v, '__path__'): dict=self.hs_search_mod(v, dict) return dict
| 2,367
|
def __call__(self, sub, sev, sum, det, err):
|
def __call__(self, sub, sev, sum, det, err):
| 2,368
|
def has_permission(self, permission, object): """Check to see if a user has a given permission on an object.""" return getSecurityManager().checkPermission(permission, object)
|
def has_permission(self, permission, object): """Check to see if a user has a given permission on an object.""" return getSecurityManager().checkPermission(permission, object)
| 2,369
|
def _setaccess(self, names, access): # Empty names list sets access to the class itself, named '' if not len(names): names = ('',) for name in names: if self.names.get(name, access) != access: LOG('SecurityInfo', WARNING, 'Conflicting security ' 'declarations for "%s"' % name) self._warnings = 1 self.names[name] = access
|
def _setaccess(self, names, access): # Empty names list sets access to the class itself, named '' if not len(names): names = ('',) for name in names: if self.names.get(name, access) != access: LOG('SecurityInfo', WARNING, 'Conflicting security ' 'declarations for "%s"' % name) self._warnings = 1 self.names[name] = access
| 2,370
|
def public(self, *names): """Declare names to be publicly accessible.""" self._setaccess(names, ACCESS_PUBLIC)
|
def public(self, *names): """Declare names to be publicly accessible.""" self._setaccess(names, ACCESS_PUBLIC)
| 2,371
|
def private(self, *names): """Declare names to be inaccessible to restricted code.""" self._setaccess(names, ACCESS_PRIVATE)
|
def private(self, *names): """Declare names to be inaccessible to restricted code.""" self._setaccess(names, ACCESS_PRIVATE)
| 2,372
|
def protected(self, permission_name, *names): """Cannot declare module names protected.""" pass
|
declareProtected__roles__=ACCESS_PRIVATE def declareProtected(self, permission_name, *names): """Cannot declare module names protected.""" pass
| 2,373
|
def import_products(): # Try to import each product, checking for and catching errors. done={} products = get_products() for priority, product_name, index, product_dir in products: if done.has_key(product_name): LOG('OFS.Application', WARNING, 'Duplicate Product name', 'After loading Product %s from %s,\n' 'I skipped the one in %s.\n' % ( `product_name`, `done[product_name]`, `product_dir`) ) continue done[product_name]=product_dir import_product(product_dir, product_name)
|
def import_products(): # Try to import each product, checking for and catching errors. done={} products = get_products() for priority, product_name, index, product_dir in products: if done.has_key(product_name): LOG('OFS.Application', WARNING, 'Duplicate Product name', 'After loading Product %s from %s,\n' 'I skipped the one in %s.\n' % ( `product_name`, `done[product_name]`, `product_dir`) ) continue done[product_name]=product_dir import_product(product_dir, product_name, raise_exc=debug_mode)
| 2,374
|
def install_products(app): # Install a list of products into the basic folder class, so # that all folders know about top-level objects, aka products folder_permissions = get_folder_permissions() meta_types=[] done={} get_transaction().note('Prior to product installs') get_transaction().commit() products = get_products() for priority, product_name, index, product_dir in products: # For each product, we will import it and try to call the # intialize() method in the product __init__ module. If # the method doesnt exist, we put the old-style information # together and do a default initialization. if done.has_key(product_name): continue done[product_name]=1 install_product(app, product_dir, product_name, meta_types, folder_permissions) Products.meta_types=Products.meta_types+tuple(meta_types) Globals.default__class_init__(Folder.Folder)
|
def install_products(app): # Install a list of products into the basic folder class, so # that all folders know about top-level objects, aka products folder_permissions = get_folder_permissions() meta_types=[] done={} get_transaction().note('Prior to product installs') get_transaction().commit() products = get_products() for priority, product_name, index, product_dir in products: # For each product, we will import it and try to call the # intialize() method in the product __init__ module. If # the method doesnt exist, we put the old-style information # together and do a default initialization. if done.has_key(product_name): continue done[product_name]=1 install_product(app, product_dir, product_name, meta_types, folder_permissions, raise_exc=debug_mode) Products.meta_types=Products.meta_types+tuple(meta_types) Globals.default__class_init__(Folder.Folder)
| 2,375
|
def __getitem__(self, key): self=self.aq_parent
|
def __getitem__(self, key): self=self.aq_parent
| 2,376
|
def filtered_manage_options( self, REQUEST=None, help_option_=({'label': 'Help', 'action': 'manage_help', 'target':"z_help_wnd"},), ): if REQUEST is None and hasattr(self, 'aq_acquire'): try: REQUEST=self.aq_acquire('REQUEST') except: pass try: user=REQUEST['AUTHENTICATED_USER'] except: user=None result=[] seen_roles={}
|
def filtered_manage_options( self, REQUEST=None, help_option_=({'label': 'Help', 'action': 'manage_help', 'target':"z_help_wnd"},), ): if REQUEST is None and hasattr(self, 'aq_acquire'): try: REQUEST=self.aq_acquire('REQUEST') except: pass try: user=REQUEST['AUTHENTICATED_USER'] except: user=None result=[] seen_roles={}
| 2,377
|
def check_zglobals(self): if not doInstall(): return
|
def check_zglobals(self): if not doInstall(): return
| 2,378
|
def parse_endtag(self, i): rawdata = self.rawdata assert rawdata[i:i+2] == "</", "unexpected call to parse_endtag" match = endendtag.search(rawdata, i+1) # > if not match: return -1 j = match.end() tag = string.lower(string.strip(rawdata[i+2:j-1])) if not tag: raise HTMLParseError("empty start tag", self.getpos()) self.handle_endtag(tag) return j
|
def parse_endtag(self, i): rawdata = self.rawdata assert rawdata[i:i+2] == "</", "unexpected call to parse_endtag" match = endendtag.search(rawdata, i+1) # > if not match: return -1 j = match.end() match = endtagfind.match(rawdata, i) if not match: raise HTMLParseError("bad end tag: %s" % `rawdata[i:j]`, self.getpos()) tag = match.group(1) self.handle_endtag(tag) return j
| 2,379
|
def load(self, oid, version): self._lock_acquire() try: s=self._index[oid] p=self._opickle[oid] return p, s # pickle, serial finally: self._lock_release()
|
def load(self, oid, version): self._lock_acquire() try: s=self._index[oid] p=self._opickle[oid] return p, s # pickle, serial finally: self._lock_release()
| 2,380
|
def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) if version: # we allow a version to be in use although we don't # support versions in the storage. LOG('TemporaryStorage', BLATHER, ('versions in use with TemporaryStorage although Temporary' 'Storage doesnt support versions'), ) self._lock_acquire() try: if self._index.has_key(oid): oserial=self._index[oid] if serial != oserial: rdata = self.tryToResolveConflict(oid, oserial, serial, data) if rdata is None: raise POSException.ConflictError( oid=oid, serials=(oserial, serial), data=data) else: data = rdata else: oserial = serial newserial=self._tid self._tmp.append((oid, data)) now = time.time() self._conflict_cache[(oid, newserial)] = data, now return serial == oserial and newserial or ResolvedSerial finally: self._lock_release()
|
def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) if version: # we allow a version to be in use although we don't # support versions in the storage. LOG('TemporaryStorage', BLATHER, ('versions in use with TemporaryStorage although Temporary' 'Storage doesnt support versions'), ) self._lock_acquire() try: if self._index.has_key(oid): oserial=self._index[oid] if serial != oserial: data=self.tryToResolveConflict(oid, oserial, serial, data) if not data: raise POSException.ConflictError(oid=oid, serials=(oserial, serial)) else: oserial = serial newserial=self._tid self._tmp.append((oid, data)) now = time.time() self._conflict_cache[(oid, newserial)] = data, now return serial == oserial and newserial or ResolvedSerial finally: self._lock_release()
| 2,381
|
def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) if version: # we allow a version to be in use although we don't # support versions in the storage. LOG('TemporaryStorage', BLATHER, ('versions in use with TemporaryStorage although Temporary' 'Storage doesnt support versions'), ) self._lock_acquire() try: if self._index.has_key(oid): oserial=self._index[oid] if serial != oserial: rdata = self.tryToResolveConflict(oid, oserial, serial, data) if rdata is None: raise POSException.ConflictError( oid=oid, serials=(oserial, serial), data=data) else: data = rdata else: oserial = serial newserial=self._tid self._tmp.append((oid, data)) now = time.time() self._conflict_cache[(oid, newserial)] = data, now return serial == oserial and newserial or ResolvedSerial finally: self._lock_release()
|
def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) if version: # we allow a version to be in use although we don't # support versions in the storage. LOG('TemporaryStorage', BLATHER, ('versions in use with TemporaryStorage although Temporary' 'Storage doesnt support versions'), ) self._lock_acquire() try: if self._index.has_key(oid): oserial=self._index[oid] if serial != oserial: rdata = self.tryToResolveConflict(oid, oserial, serial, data) if rdata is None: raise POSException.ConflictError( oid=oid, serials=(oserial, serial), data=data) else: data = rdata else: oserial = serial newserial=self._serial self._tmp.append((oid, data)) now = time.time() self._conflict_cache[(oid, newserial)] = data, now return serial == oserial and newserial or ResolvedSerial finally: self._lock_release()
| 2,382
|
def _finish(self, tid, u, d, e): zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get oreferences=self._oreferences serial=self._tid index=self._index opickle=self._opickle
|
def _finish(self, tid, u, d, e): zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get oreferences=self._oreferences serial=self._serial index=self._index opickle=self._opickle
| 2,383
|
def render(self, md): name=self.__name__ t=self.type try: v = md[name] except KeyError, key: if key==name and self.optional: return '' raise KeyError, key, sys.exc_traceback if type(v) in (ListType, TupleType): if len(v) > 1 and not self.multiple: raise 'Multiple Values', ( 'multiple values are not allowed for <em>%s</em>' % name) else: v=[v] vs=[] for v in v: if not v and type(v) is StringType and t != 'string': continue if t=='int': try: if type(v) is StringType: atoi(v) else: v=str(int(v)) except: raise ValueError, ( 'Invalid integer value for <em>%s</em>' % name) elif t=='float': if not v and type(v) is StringType: continue try: if type(v) is StringType: atof(v) else: v=str(float(v)) except: raise ValueError, ( 'Invalid floating-point value for <em>%s</em>' % name) else: v=str(v) v=md.getitem('sql_quote__',0)(v) #if find(v,"\'") >= 0: v=join(split(v,"\'"),"''") #v="'%s'" % v vs.append(v)
|
def render(self, md): name=self.__name__ t=self.type try: v = md[name] except KeyError, key: if str(key)==name and self.optional: return '' raise KeyError, key, sys.exc_traceback if type(v) in (ListType, TupleType): if len(v) > 1 and not self.multiple: raise 'Multiple Values', ( 'multiple values are not allowed for <em>%s</em>' % name) else: v=[v] vs=[] for v in v: if not v and type(v) is StringType and t != 'string': continue if t=='int': try: if type(v) is StringType: atoi(v) else: v=str(int(v)) except: raise ValueError, ( 'Invalid integer value for <em>%s</em>' % name) elif t=='float': if not v and type(v) is StringType: continue try: if type(v) is StringType: atof(v) else: v=str(float(v)) except: raise ValueError, ( 'Invalid floating-point value for <em>%s</em>' % name) else: v=str(v) v=md.getitem('sql_quote__',0)(v) #if find(v,"\'") >= 0: v=join(split(v,"\'"),"''") #v="'%s'" % v vs.append(v)
| 2,384
|
def validClipData(self):
|
def validClipData(self):
| 2,385
|
def unauthorized(self, realm): if not (self.request.has_key('REMOTE_USER') and self.request['REMOTE_USER']): self.response['WWW-authenticate']='basic realm="%s"' % realm m="<strong>You are not authorized to access this resource.</strong>" if not self.HTTP_AUTHORIZATION: m=m+'\n<!-- No Authorization header-->' raise 'Unauthorized', m
|
def unauthorized(self, realm,debug_mode=None): if not (self.request.has_key('REMOTE_USER') and self.request['REMOTE_USER']): self.response['WWW-authenticate']='basic realm="%s"' % realm m="<strong>You are not authorized to access this resource.</strong>" if not self.HTTP_AUTHORIZATION: m=m+'\n<!-- No Authorization header-->' raise 'Unauthorized', m
| 2,386
|
def unauthorized(self, realm): if not (self.request.has_key('REMOTE_USER') and self.request['REMOTE_USER']): self.response['WWW-authenticate']='basic realm="%s"' % realm m="<strong>You are not authorized to access this resource.</strong>" if not self.HTTP_AUTHORIZATION: m=m+'\n<!-- No Authorization header-->' raise 'Unauthorized', m
|
def unauthorized(self, realm): if not (self.request.has_key('REMOTE_USER') and self.request['REMOTE_USER']): self.response['WWW-authenticate']='basic realm="%s"' % realm m="<strong>You are not authorized to access this resource.</strong>" if debug_mode: if self.HTTP_AUTHORIZATION: m=m+'\nUsername and password are not correct.' else: m=m+'\nNo Authorization header found.' raise 'Unauthorized', m
| 2,387
|
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):
| 2,388
|
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):
| 2,389
|
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):
| 2,390
|
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):
| 2,391
|
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):
| 2,392
|
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):
| 2,393
|
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):
| 2,394
|
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):
| 2,395
|
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):
| 2,396
|
def get_module_info(module_name, modules={}, acquire=_l.acquire, release=_l.release, ): if modules.has_key(module_name): return modules[module_name] if module_name[-4:]=='.cgi': module_name=module_name[:-4] acquire() tb=None try: try: module=__import__(module_name, globals(), globals(), ('__doc__',)) realm=module_name # Let the app specify a realm if hasattr(module,'__bobo_realm__'): realm=module.__bobo_realm__ else: realm=module_name # Check whether tracebacks should be hidden: if (hasattr(module,'__bobo_hide_tracebacks__') and not module.__bobo_hide_tracebacks__): CGIResponse._tbopen, CGIResponse._tbclose = '<PRE>', '</PRE>' if hasattr(module,'__bobo_before__'): bobo_before=module.__bobo_before__ else: bobo_before=None if hasattr(module,'__bobo_after__'): bobo_after=module.__bobo_after__ else: bobo_after=None # Get request data from outermost environment: if hasattr(module,'__request_data__'): request_params=module.__request_data__ else: request_params=None # Get initial group data: inherited_groups=[] if hasattr(module,'__allow_groups__'): groups=module.__allow_groups__ inherited_groups.append(groups) else: groups=None web_objects=None roles=UNSPECIFIED_ROLES if hasattr(module,'bobo_application'): object=module.bobo_application if hasattr(object,'__allow_groups__'): groups=object.__allow_groups__ inherited_groups.append(groups) else: groups=None if hasattr(object,'__roles__'): roles=object.__roles__ else: if hasattr(module,'web_objects'): web_objects=module.web_objects object=web_objects else: object=module published=web_objects try: doc=module.__doc__ except: if web_objects is not None: doc=' ' else: doc=None info= (bobo_before, bobo_after, request_params, inherited_groups, groups, roles, object, doc, published, realm, module_name) modules[module_name]=modules[module_name+'.cgi']=info return info except: if hasattr(sys, 'exc_info'): t,v,tb=sys.exc_info() else: t, v, tb = sys.exc_type, sys.exc_value, sys.exc_traceback v=str(v) raise ImportError, (t, v), tb finally: tb=None release()
|
def get_module_info(module_name, modules={}, acquire=_l.acquire, release=_l.release, ): if modules.has_key(module_name): return modules[module_name] if module_name[-4:]=='.cgi': module_name=module_name[:-4] acquire() tb=None try: try: module=__import__(module_name, globals(), globals(), ('__doc__',)) realm=module_name # Let the app specify a realm if hasattr(module,'__bobo_realm__'): realm=module.__bobo_realm__ else: realm=module_name # Check whether tracebacks should be hidden: if (hasattr(module,'__bobo_hide_tracebacks__') and not module.__bobo_hide_tracebacks__): hide_tracebacks=None else: hide_tracebacks=1 if hasattr(module,'__bobo_before__'): bobo_before=module.__bobo_before__ else: bobo_before=None if hasattr(module,'__bobo_after__'): bobo_after=module.__bobo_after__ else: bobo_after=None # Get request data from outermost environment: if hasattr(module,'__request_data__'): request_params=module.__request_data__ else: request_params=None # Get initial group data: inherited_groups=[] if hasattr(module,'__allow_groups__'): groups=module.__allow_groups__ inherited_groups.append(groups) else: groups=None web_objects=None roles=UNSPECIFIED_ROLES if hasattr(module,'bobo_application'): object=module.bobo_application if hasattr(object,'__allow_groups__'): groups=object.__allow_groups__ inherited_groups.append(groups) else: groups=None if hasattr(object,'__roles__'): roles=object.__roles__ else: if hasattr(module,'web_objects'): web_objects=module.web_objects object=web_objects else: object=module published=web_objects try: doc=module.__doc__ except: if web_objects is not None: doc=' ' else: doc=None info= (bobo_before, bobo_after, request_params, inherited_groups, groups, roles, object, doc, published, realm, module_name) modules[module_name]=modules[module_name+'.cgi']=info return info except: if hasattr(sys, 'exc_info'): t,v,tb=sys.exc_info() else: t, v, tb = sys.exc_type, sys.exc_value, sys.exc_traceback v=str(v) raise ImportError, (t, v), tb finally: tb=None release()
| 2,397
|
def get_module_info(module_name, modules={}, acquire=_l.acquire, release=_l.release, ): if modules.has_key(module_name): return modules[module_name] if module_name[-4:]=='.cgi': module_name=module_name[:-4] acquire() tb=None try: try: module=__import__(module_name, globals(), globals(), ('__doc__',)) realm=module_name # Let the app specify a realm if hasattr(module,'__bobo_realm__'): realm=module.__bobo_realm__ else: realm=module_name # Check whether tracebacks should be hidden: if (hasattr(module,'__bobo_hide_tracebacks__') and not module.__bobo_hide_tracebacks__): CGIResponse._tbopen, CGIResponse._tbclose = '<PRE>', '</PRE>' if hasattr(module,'__bobo_before__'): bobo_before=module.__bobo_before__ else: bobo_before=None if hasattr(module,'__bobo_after__'): bobo_after=module.__bobo_after__ else: bobo_after=None # Get request data from outermost environment: if hasattr(module,'__request_data__'): request_params=module.__request_data__ else: request_params=None # Get initial group data: inherited_groups=[] if hasattr(module,'__allow_groups__'): groups=module.__allow_groups__ inherited_groups.append(groups) else: groups=None web_objects=None roles=UNSPECIFIED_ROLES if hasattr(module,'bobo_application'): object=module.bobo_application if hasattr(object,'__allow_groups__'): groups=object.__allow_groups__ inherited_groups.append(groups) else: groups=None if hasattr(object,'__roles__'): roles=object.__roles__ else: if hasattr(module,'web_objects'): web_objects=module.web_objects object=web_objects else: object=module published=web_objects try: doc=module.__doc__ except: if web_objects is not None: doc=' ' else: doc=None info= (bobo_before, bobo_after, request_params, inherited_groups, groups, roles, object, doc, published, realm, module_name) modules[module_name]=modules[module_name+'.cgi']=info return info except: if hasattr(sys, 'exc_info'): t,v,tb=sys.exc_info() else: t, v, tb = sys.exc_type, sys.exc_value, sys.exc_traceback v=str(v) raise ImportError, (t, v), tb finally: tb=None release()
|
def get_module_info(module_name, modules={}, acquire=_l.acquire, release=_l.release, ): if modules.has_key(module_name): return modules[module_name] if module_name[-4:]=='.cgi': module_name=module_name[:-4] acquire() tb=None try: try: module=__import__(module_name, globals(), globals(), ('__doc__',)) realm=module_name # Let the app specify a realm if hasattr(module,'__bobo_realm__'): realm=module.__bobo_realm__ else: realm=module_name # Check whether tracebacks should be hidden: if (hasattr(module,'__bobo_hide_tracebacks__') and not module.__bobo_hide_tracebacks__): CGIResponse._tbopen, CGIResponse._tbclose = '<PRE>', '</PRE>' if hasattr(module,'__bobo_before__'): bobo_before=module.__bobo_before__ else: bobo_before=None if hasattr(module,'__bobo_after__'): bobo_after=module.__bobo_after__ else: bobo_after=None # Get request data from outermost environment: if hasattr(module,'__request_data__'): request_params=module.__request_data__ else: request_params=None # Get initial group data: inherited_groups=[] if hasattr(module,'__allow_groups__'): groups=module.__allow_groups__ inherited_groups.append(groups) else: groups=None web_objects=None roles=UNSPECIFIED_ROLES if hasattr(module,'bobo_application'): object=module.bobo_application if hasattr(object,'__allow_groups__'): groups=object.__allow_groups__ inherited_groups.append(groups) else: groups=None if hasattr(object,'__roles__'): roles=object.__roles__ else: if hasattr(module,'web_objects'): web_objects=module.web_objects object=web_objects else: object=module published=web_objects try: doc=module.__doc__ except: if web_objects is not None: doc=' ' else: doc=None info= (bobo_before, bobo_after, request_params, inherited_groups, groups, roles, object, doc, published, realm, module_name, hide_tracebacks, debug_mode) modules[module_name]=modules[module_name+'.cgi']=info return info except: if hasattr(sys, 'exc_info'): t,v,tb=sys.exc_info() else: t, v, tb = sys.exc_type, sys.exc_value, sys.exc_traceback v=str(v) raise ImportError, (t, v), tb finally: tb=None release()
| 2,398
|
def __init__(self,environ,form,stdin): self.environ=environ self.other=form self.stdin=stdin have_env=environ.has_key
|
def __init__(self,environ,form,stdin): self.environ=environ self.other=form self.stdin=stdin have_env=environ.has_key
| 2,399
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.