bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def writeln(self, *args): if args: apply(self.write, args) self.write(os.linesep)
def writeln(self, *args): if args: apply(self.write, args) self.write(os.linesep)
3,500
def printErrors(self): self.printNumberedErrors('error',self.errors)
def printErrors(self): self.printNumberedErrors('error',self.errors)
3,501
def printFailures(self): self.printNumberedErrors('failure',self.failures)
def printFailures(self): self.printNumberedErrors('failure',self.failures)
3,502
def printHeader(self): self.stream.writeln() if self.wasSuccessful(): self.stream.writeln("OK (%i tests)" % self.testsRun) else: self.stream.writeln("!!!FAILURES!!!") self.stream.writeln("Test Results") self.stream.writeln() self.stream.writeln("Run: %i ; Failures: %i; Errors: %i" % (self.testsRun, len(self.failures), len(self.errors)))
def printHeader(self): self.stream.writeln() if self.wasSuccessful(): self.stream.writeln("OK (%i tests)" % self.testsRun) else: self.stream.writeln("!!!FAILURES!!!") self.stream.writeln("Test Results") self.stream.writeln() self.stream.writeln("Run: %i ; Failures: %i ; Errors: %i" % (self.testsRun, len(self.failures), len(self.errors)))
3,503
def printResult(self): self.printHeader() self.printErrors() self.printFailures()
def printResult(self): self.printHeader() self.printErrors() self.printFailures()
3,504
def printResult(self): self.printHeader() self.printErrors() self.printFailures()
def printResult(self): self.printHeader() self.printErrors() self.printFailures()
3,505
def run(self, test): """Run the given test case or test suite. """ result = _TextTestResult(self.stream) startTime = time.time() test(result) stopTime = time.time() self.stream.writeln() self.stream.writeln("Time: %.3fs" % float(stopTime - startTime)) result.printResult() return result
def run(self, test): "Run the given test case or test suite." result = _JUnitTextTestResult(self.stream) startTime = time.time() test(result) stopTime = time.time() self.stream.writeln() self.stream.writeln("Time: %.3fs" % float(stopTime - startTime)) result.printResult() return result
3,506
def createTestInstance(name): """Looks up and calls a callable object by its string name, which should include its module name, e.g. 'widgettests.WidgetTestSuite'. """ if '.' not in name: raise ValueError,"Incomplete name; expected 'package.suiteobj'" dotPos = string.rfind(name,'.') last = name[dotPos+1:] if not len(last): raise ValueError,"Malformed classname" pkg = name[:dotPos] try: testCreator = getattr(__import__(pkg,globals(),locals(),[last]),last) except AttributeError, e: raise ImportError, \ "No object '%s' found in package '%s'" % (last,pkg) if not callable(testCreator): raise ValueError, "'%s' is not callable" % name try: test = testCreator() except: raise TypeError, \ "Error making a test instance by calling '%s'" % testCreator if not hasattr(test,"countTestCases"): raise TypeError, \ "Calling '%s' returned '%s', which is not a test case or suite" \ % (name,test) return test
def createTestInstance(name): """Looks up and calls a callable object by its string name, which should include its module name, e.g. 'widgettests.WidgetTestSuite'. """ if '.' not in name: raise ValueError,"Incomplete name; expected 'package.suiteobj'" dotPos = string.rfind(name,'.') last = name[dotPos+1:] if not len(last): raise ValueError,"Malformed classname" pkg = name[:dotPos] try: testCreator = getattr(__import__(pkg,globals(),locals(),[last]),last) except AttributeError, e: raise ImportError, \ "No object '%s' found in package '%s'" % (last,pkg) if not callable(testCreator): raise ValueError, "'%s' is not callable" % name try: test = testCreator() except: raise TypeError, \ "Error making a test instance by calling '%s'" % testCreator if not hasattr(test,"countTestCases"): raise TypeError, \ "Calling '%s' returned '%s', which is not a test case or suite" \ % (name,test) return test
3,507
def makeSuite(testCaseClass, prefix='test', sortUsing=cmp): """Returns a TestSuite instance built from all of the test functions in the given test case class whose names begin with the given prefix. The cases are sorted by their function names using the supplied comparison function, which defaults to 'cmp'. """ cases = map(testCaseClass, getTestCaseNames(testCaseClass, prefix, sortUsing)) return TestSuite(cases)
def makeSuite(testCaseClass, prefix='test', sortUsing=cmp): """Returns a TestSuite instance built from all of the test functions in the given test case class whose names begin with the given prefix. The cases are sorted by their function names using the supplied comparison function, which defaults to 'cmp'. """ cases = map(testCaseClass, getTestCaseNames(testCaseClass, prefix, sortUsing)) return TestSuite(cases)
3,508
def cache_detail(self): try: db=self._p_jar.db() except: # BoboPOS2 detail={} for oid, ob in Globals.Bobobase._jar.cache.items(): if hasattr(ob, '__class__'): ob=ob.__class__ decor='' else: decor=' class' c="%s.%s%s" % (ob.__module__ or '', ob.__name__, decor) if detail.has_key(c): detail[c]=detail[c]+1 else: detail[c]=1 detail=detail.items() else: # ZODB 3 detail=db.cacheDetail() detail=map(lambda d: (("%s.%s" % (d[0].__module__, d[0].__name__)), d[1]), detail.items())
def cache_detail(self): try: db=self._p_jar.db() except: # BoboPOS2 detail={} for oid, ob in Globals.Bobobase._jar.cache.items(): if hasattr(ob, '__class__'): ob=ob.__class__ decor='' else: decor=' class' c="%s.%s%s" % (ob.__module__ or '', ob.__name__, decor) if detail.has_key(c): detail[c]=detail[c]+1 else: detail[c]=1 detail=detail.items() else: # ZODB 3 detail=db.cacheDetail() detail=map(lambda d: (("%s.%s" % (d[0].__module__, d[0].__name__)), d[1]), detail.items())
3,509
def cache_extreme_detail(self): try: db=self._p_jar.db() except: # BoboPOS2 detail=[] rc=sys.getrefcount db=Globals.Bobobase._jar.db for oid, ob in Globals.Bobobase._jar.cache.items(): id=oid
def cache_extreme_detail(self): try: db=self._p_jar.db() except: # BoboPOS2 detail=[] rc=sys.getrefcount db=Globals.Bobobase._jar.db for oid, ob in Globals.Bobobase._jar.cache.items(): id=oid
3,510
def manage_addPythonScript(self, id, REQUEST=None): """Add a Python script to a folder. """ id = str(id) id = self._setObject(id, PythonScript(id)) if REQUEST is not None: file = REQUEST.form.get('file', None) if file: if type(file) is not type(''): file = file.read() getattr(self, id).write(file) try: u = self.DestinationURL() except: u = REQUEST['URL1'] REQUEST.RESPONSE.redirect('%s/%s/manage_main' % (u, quote(id))) return ''
def manage_addPythonScript(self, id, REQUEST=None): """Add a Python script to a folder. """ id = str(id) id = self._setObject(id, PythonScript(id)) if REQUEST is not None: file = REQUEST.form.get('file', None) if file: if type(file) is not type(''): file = file.read() self._getOb(id).write(file) try: u = self.DestinationURL() except: u = REQUEST['URL1'] REQUEST.RESPONSE.redirect('%s/%s/manage_main' % (u, quote(id))) return ''
3,511
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
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: 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
3,512
def __init__(self, klass): # Creates an APIDoc instance given a python class. # the class describes the API; it contains # methods, arguments and doc strings. # # The name of the API is deduced from the name # of the class. # # The base APIs are deduced from the __extends__ # attribute. self.name=klass.__name__ self.doc=trim_doc_string(klass.__doc__) if hasattr(klass,'__extends__'): self.extends=[] for base in klass.__extends__: names=string.split(base, '.') url="%s/Help/%s.py#%s" % (names[0], names[1], names[2]) self.extends.append(names[2], url) # Get info on methods and attributes, ignore special items self.attributes=[] self.methods=[] for k,v in klass.__dict__.items(): if k not in ('__extends__', '__doc__'): if type(v)==types.FunctionType: self.methods.append(MethodDoc(v)) else: self.attributes.append(AttributeDoc(k, v))
def __init__(self, klass): # Creates an APIDoc instance given a python class. # the class describes the API; it contains # methods, arguments and doc strings. # # The name of the API is deduced from the name # of the class. # # The base APIs are deduced from the __extends__ # attribute. self.name=klass.__name__ self.doc=trim_doc_string(klass.__doc__) if hasattr(klass,'__extends__'): self.extends=[] for base in klass.__extends__: names=string.split(base, '.') url="%s/Help/%s.py#%s" % (names[0], names[1], names[2]) self.extends.append((names[2], url)) # Get info on methods and attributes, ignore special items self.attributes=[] self.methods=[] for k,v in klass.__dict__.items(): if k not in ('__extends__', '__doc__'): if type(v)==types.FunctionType: self.methods.append(MethodDoc(v)) else: self.attributes.append(AttributeDoc(k, v))
3,513
def undoable_transactions(self, AUTHENTICATION_PATH=None, first_transaction=None, last_transaction=None, PrincipiaUndoBatchSize=None):
def undoable_transactions(self, AUTHENTICATION_PATH=None, first_transaction=None, last_transaction=None, PrincipiaUndoBatchSize=None):
3,514
def undoable_transactions(self, AUTHENTICATION_PATH=None, first_transaction=None, last_transaction=None, PrincipiaUndoBatchSize=None):
def undoable_transactions(self, AUTHENTICATION_PATH=None, first_transaction=None, last_transaction=None, PrincipiaUndoBatchSize=None):
3,515
def __init__(self, name, bases=(), attrs=None, __doc__=None): """Create a new interface """ for b in bases: if not isinstance(b, Interface): raise TypeError, 'Expected base interfaces' self.__bases__=bases self.__name__=name
def __init__(self, name, bases=(), attrs=None, __doc__=None): """Create a new interface """ for b in bases: if not isinstance(b, Interface): raise TypeError, 'Expected base interfaces' self.__bases__=bases self.__name__=name
3,516
def __init__(self, name, bases=(), attrs=None, __doc__=None): """Create a new interface """ for b in bases: if not isinstance(b, Interface): raise TypeError, 'Expected base interfaces' self.__bases__=bases self.__name__=name
def __init__(self, name, bases=(), attrs=None, __doc__=None): """Create a new interface """ for b in bases: if not isinstance(b, Interface): raise TypeError, 'Expected base interfaces' self.__bases__=bases self.__name__=name
3,517
def __d(self, dict):
def __d(self, dict):
3,518
def pt_changePrefs(self, REQUEST, height=None, width=None, dtpref_cols='50', dtpref_rows='20'): """Change editing preferences.""" # The <textarea> can have dimensions expressed in percentages; # strip the percent sign so int() below won't fail if dtpref_cols[-1:] == "%": dtpref_cols = dtpref_cols[:-1] or '50' if dtpref_rows[-1:] == "%": dtpref_rows = dtpref_rows[:-1] or '20' szchh = {'Taller': 1, 'Shorter': -1, None: 0} szchw = {'Wider': 5, 'Narrower': -5, None: 0} try: rows = int(height) except: rows = max(1, int(dtpref_rows) + szchh.get(height, 0)) try: cols = int(width) except: cols = max(40, int(dtpref_cols) + szchw.get(width, 0)) e = (DateTime('GMT') + 365).rfc822() setc = REQUEST['RESPONSE'].setCookie setc('dtpref_rows', str(rows), path='/', expires=e) setc('dtpref_cols', str(cols), path='/', expires=e) REQUEST.form.update({'dtpref_cols': cols, 'dtpref_rows': rows}) return self.manage_main()
def pt_changePrefs(self, REQUEST, height=None, width=None, dtpref_cols='100%', dtpref_rows='20'): """Change editing preferences.""" # The <textarea> can have dimensions expressed in percentages; # strip the percent sign so int() below won't fail if dtpref_cols[-1:] == "%": dtpref_cols = dtpref_cols[:-1] or '50' if dtpref_rows[-1:] == "%": dtpref_rows = dtpref_rows[:-1] or '20' szchh = {'Taller': 1, 'Shorter': -1, None: 0} szchw = {'Wider': 5, 'Narrower': -5, None: 0} try: rows = int(height) except: rows = max(1, int(dtpref_rows) + szchh.get(height, 0)) try: cols = int(width) except: cols = max(40, int(dtpref_cols) + szchw.get(width, 0)) e = (DateTime('GMT') + 365).rfc822() setc = REQUEST['RESPONSE'].setCookie setc('dtpref_rows', str(rows), path='/', expires=e) setc('dtpref_cols', str(cols), path='/', expires=e) REQUEST.form.update({'dtpref_cols': cols, 'dtpref_rows': rows}) return self.manage_main()
3,519
def pt_changePrefs(self, REQUEST, height=None, width=None, dtpref_cols='50', dtpref_rows='20'): """Change editing preferences.""" # The <textarea> can have dimensions expressed in percentages; # strip the percent sign so int() below won't fail if dtpref_cols[-1:] == "%": dtpref_cols = dtpref_cols[:-1] or '50' if dtpref_rows[-1:] == "%": dtpref_rows = dtpref_rows[:-1] or '20' szchh = {'Taller': 1, 'Shorter': -1, None: 0} szchw = {'Wider': 5, 'Narrower': -5, None: 0} try: rows = int(height) except: rows = max(1, int(dtpref_rows) + szchh.get(height, 0)) try: cols = int(width) except: cols = max(40, int(dtpref_cols) + szchw.get(width, 0)) e = (DateTime('GMT') + 365).rfc822() setc = REQUEST['RESPONSE'].setCookie setc('dtpref_rows', str(rows), path='/', expires=e) setc('dtpref_cols', str(cols), path='/', expires=e) REQUEST.form.update({'dtpref_cols': cols, 'dtpref_rows': rows}) return self.manage_main()
def pt_changePrefs(self, REQUEST, height=None, width=None, dtpref_cols='50', dtpref_rows='20'): """Change editing preferences.""" # The <textarea> can have dimensions expressed in percentages; # strip the percent sign so int() below won't fail if dtpref_cols[-1:] == "%": dtpref_cols = dtpref_cols[:-1] or '50' if dtpref_rows[-1:] == "%": dtpref_rows = dtpref_rows[:-1] or '20' szchh = {'Taller': 1, 'Shorter': -1, None: 0} szchw = {'Wider': 5, 'Narrower': -5, None: 0} try: rows = int(height) except: rows = max(1, int(dtpref_rows) + szchh.get(height, 0)) try: cols = int(width) except: cols = max(40, int(dtpref_cols) + szchw.get(width, 0)) e = (DateTime('GMT') + 365).rfc822() setc = REQUEST['RESPONSE'].setCookie setc('dtpref_rows', str(rows), path='/', expires=e) setc('dtpref_cols', str(cols), path='/', expires=e) REQUEST.form.update({'dtpref_cols': cols, 'dtpref_rows': rows}) return self.manage_main()
3,520
def pt_changePrefs(self, REQUEST, height=None, width=None, dtpref_cols='50', dtpref_rows='20'): """Change editing preferences.""" # The <textarea> can have dimensions expressed in percentages; # strip the percent sign so int() below won't fail if dtpref_cols[-1:] == "%": dtpref_cols = dtpref_cols[:-1] or '50' if dtpref_rows[-1:] == "%": dtpref_rows = dtpref_rows[:-1] or '20' szchh = {'Taller': 1, 'Shorter': -1, None: 0} szchw = {'Wider': 5, 'Narrower': -5, None: 0} try: rows = int(height) except: rows = max(1, int(dtpref_rows) + szchh.get(height, 0)) try: cols = int(width) except: cols = max(40, int(dtpref_cols) + szchw.get(width, 0)) e = (DateTime('GMT') + 365).rfc822() setc = REQUEST['RESPONSE'].setCookie setc('dtpref_rows', str(rows), path='/', expires=e) setc('dtpref_cols', str(cols), path='/', expires=e) REQUEST.form.update({'dtpref_cols': cols, 'dtpref_rows': rows}) return self.manage_main()
def pt_changePrefs(self, REQUEST, height=None, width=None, dtpref_cols='50', dtpref_rows='20'): """Change editing preferences.""" # The <textarea> can have dimensions expressed in percentages; # strip the percent sign so int() below won't fail if dtpref_cols[-1:] == "%": dtpref_cols = dtpref_cols[:-1] or '50' if dtpref_rows[-1:] == "%": dtpref_rows = dtpref_rows[:-1] or '20' szchh = {'Taller': 1, 'Shorter': -1, None: 0} szchw = {'Wider': 5, 'Narrower': -5, None: 0} try: rows = int(height) except: rows = max(1, int(dtpref_rows) + szchh.get(height, 0)) e = (DateTime('GMT') + 365).rfc822() setc = REQUEST['RESPONSE'].setCookie setc('dtpref_rows', str(rows), path='/', expires=e) setc('dtpref_cols', str(cols), path='/', expires=e) REQUEST.form.update({'dtpref_cols': cols, 'dtpref_rows': rows}) return self.manage_main()
3,521
def testResolveUrl(self): # Check that ResolveUrl really raises the same error
def testResolveUrl(self): # Check that ResolveUrl really raises the same error
3,522
def testResolveUrl(self): # Check that ResolveUrl really raises the same error
def testResolveUrl(self): # Check that ResolveUrl really raises the same error
3,523
def manage_edit(self, meta_type='', icon='', file='', REQUEST=None): """Set basic item properties. """ if meta_type: self.setClassAttr('meta_type', meta_type)
def manage_edit(self, meta_type='', icon='', file='', REQUEST=None): """Set basic item properties. """ if meta_type: self.setClassAttr('meta_type', meta_type)
3,524
def objectIds(self, spec=None): """ this is a patch for pre-2.4 Zope installations. Such installations don't have an entry for the WebDAV LockManager introduced in 2.4. """
def objectIds(self, spec=None): """ this is a patch for pre-2.4 Zope installations. Such installations don't have an entry for the WebDAV LockManager introduced in 2.4. """
3,525
def createInObjectManager(self, id, REQUEST, RESPONSE=None): """ Create Z instance. If called with a RESPONSE, the RESPONSE will be redirected to the management screen of the new instance's parent Folder. Otherwise, the instance will be returned. """ i=mapply(self._zclass_, (), REQUEST) try: i._setId(id) except AttributeError: i.id=id folder=durl=None if hasattr(self, 'Destination'): d=self.Destination if d.im_self.__class__ is FactoryDispatcher: folder=d() if folder is None: folder=self.aq_parent if not hasattr(folder,'_setObject'): folder=folder.aq_parent
def createInObjectManager(self, id, REQUEST, RESPONSE=None): """ Create Z instance. If called with a RESPONSE, the RESPONSE will be redirected to the management screen of the new instance's parent Folder. Otherwise, the instance will be returned. """ i=mapply(self._zclass_, (), REQUEST) try: i._setId(id) except AttributeError: i.id=id folder=durl=None if hasattr(self, 'Destination'): d=self.Destination if d.im_self.__class__ is FactoryDispatcher: folder=d() if folder is None: folder=self.aq_parent if not hasattr(folder,'_setObject'): folder=folder.aq_parent
3,526
def parse_cookie(text, result=None, qparmre=regex.compile( '\([\0- ]*' '\([^\0- ;,=\"]+\)="\([^"]*\)\"' '\([\0- ]*[;,]\)?[\0- ]*\)' ), parmre=regex.compile( '\([\0- ]*' '\([^\0- ;,=\"]+\)=\([^\0;-=\"]*\)' '\([\0- ]*[;,]\)?[\0- ]*\)' ), ): if result is None: result={} if qparmre.match(text) >= 0: # Match quoted correct cookies name=qparmre.group(2) value=qparmre.group(3) l=len(qparmre.group(1)) elif parmre.match(text) >= 0: # Match evil MSIE cookies ;) name=parmre.group(2) value=parmre.group(3) l=len(parmre.group(1)) else: if not text or not strip(text): return result raise "InvalidParameter", text result[name]=value return apply(parse_cookie,(text[l:],result))
def parse_cookie(text, result=None, qparmre=regex.compile( '\([\0- ]*' '\([^\0- ;,=\"]+\)="\([^"]*\)\"' '\([\0- ]*[;,]\)?[\0- ]*\)' ), parmre=regex.compile( '\([\0- ]*' '\([^\0- ;,=\"]+\)=\([^\0;-=\"]*\)' '\([\0- ]*[;,]\)?[\0- ]*\)' ), ): if result is None: result={} if qparmre.match(text) >= 0: # Match quoted correct cookies name=qparmre.group(2) value=qparmre.group(3) l=len(qparmre.group(1)) elif parmre.match(text) >= 0: # Match evil MSIE cookies ;) name=parmre.group(2) value=parmre.group(3) l=len(parmre.group(1)) else: if not text or not strip(text): return result raise "InvalidParameter", text if not already_have(name): result[name]=value return apply(parse_cookie,(text[l:],result))
3,527
def _range_request_handler(self, REQUEST, RESPONSE): # HTTP Range header handling: return True if we've served a range # chunk out of our data. range = REQUEST.get_header('Range', None) request_range = REQUEST.get_header('Request-Range', None) if request_range is not None: # Netscape 2 through 4 and MSIE 3 implement a draft version # Later on, we need to serve a different mime-type as well. range = request_range if_range = REQUEST.get_header('If-Range', None) if range is not None: ranges = HTTPRangeSupport.parseRange(range)
def _range_request_handler(self, REQUEST, RESPONSE): # HTTP Range header handling: return True if we've served a range # chunk out of our data. range = REQUEST.get_header('Range', None) request_range = REQUEST.get_header('Request-Range', None) if request_range is not None: # Netscape 2 through 4 and MSIE 3 implement a draft version # Later on, we need to serve a different mime-type as well. range = request_range if_range = REQUEST.get_header('If-Range', None) if range is not None: ranges = HTTPRangeSupport.parseRange(range)
3,528
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
3,529
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
3,530
def _read_data(self, file):
def _read_data(self, file):
3,531
def _read_data(self, file):
def _read_data(self, file):
3,532
def _read_data(self, file):
def _read_data(self, file):
3,533
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.' )
3,534
def _distribution(self): # Return a distribution if self.__dict__.has_key('manage_options'): raise TypeError, 'This product is <b>not</b> redistributable.'
def _distribution(self): # Return a distribution if self.__dict__.has_key('manage_options'): raise TypeError, 'This product is <b>not</b> redistributable.'
3,535
def index_object(self, documentId, obj, threshold=None): """ index an object 'obj' with integer id 'i'
def index_object(self, documentId, obj, threshold=None): """ index an object 'obj' with integer id 'i'
3,536
def fixupZClassDependencies(self, rebuild=0): # Note that callers should not catch exceptions from this method # to ensure that the transaction gets aborted if the registry # cannot be rebuilt for some reason. Returns true if any ZClasses # were registered as a result of the call or the registry was # rebuilt. jar=self._p_jar result=0
def fixupZClassDependencies(self, rebuild=0): # Note that callers should not catch exceptions from this method # to ensure that the transaction gets aborted if the registry # cannot be rebuilt for some reason. Returns true if any ZClasses # were registered as a result of the call or the registry was # rebuilt. jar=self._p_jar result=0
3,537
def fixupZClassDependencies(self, rebuild=0): # Note that callers should not catch exceptions from this method # to ensure that the transaction gets aborted if the registry # cannot be rebuilt for some reason. Returns true if any ZClasses # were registered as a result of the call or the registry was # rebuilt. jar=self._p_jar result=0
def fixupZClassDependencies(self, rebuild=0): # Note that callers should not catch exceptions from this method # to ensure that the transaction gets aborted if the registry # cannot be rebuilt for some reason. Returns true if any ZClasses # were registered as a result of the call or the registry was # rebuilt. jar=self._p_jar result=0
3,538
def fixupZClassDependencies(self, rebuild=0): # Note that callers should not catch exceptions from this method # to ensure that the transaction gets aborted if the registry # cannot be rebuilt for some reason. Returns true if any ZClasses # were registered as a result of the call or the registry was # rebuilt. jar=self._p_jar result=0
def fixupZClassDependencies(self, rebuild=0): # Note that callers should not catch exceptions from this method # to ensure that the transaction gets aborted if the registry # cannot be rebuilt for some reason. Returns true if any ZClasses # were registered as a result of the call or the registry was # rebuilt. jar=self._p_jar result=0
3,539
def fixupZClassDependencies(self, rebuild=0): # Note that callers should not catch exceptions from this method # to ensure that the transaction gets aborted if the registry # cannot be rebuilt for some reason. Returns true if any ZClasses # were registered as a result of the call or the registry was # rebuilt. jar=self._p_jar result=0
def fixupZClassDependencies(self, rebuild=0): # Note that callers should not catch exceptions from this method # to ensure that the transaction gets aborted if the registry # cannot be rebuilt for some reason. Returns true if any ZClasses # were registered as a result of the call or the registry was # rebuilt. jar=self._p_jar result=0
3,540
def fixupZClassDependencies(self, rebuild=0): # Note that callers should not catch exceptions from this method # to ensure that the transaction gets aborted if the registry # cannot be rebuilt for some reason. Returns true if any ZClasses # were registered as a result of the call or the registry was # rebuilt. jar=self._p_jar result=0
def fixupZClassDependencies(self, rebuild=0): # Note that callers should not catch exceptions from this method # to ensure that the transaction gets aborted if the registry # cannot be rebuilt for some reason. Returns true if any ZClasses # were registered as a result of the call or the registry was # rebuilt. jar=self._p_jar result=0
3,541
def fixupZClassDependencies(self, rebuild=0): # Note that callers should not catch exceptions from this method # to ensure that the transaction gets aborted if the registry # cannot be rebuilt for some reason. Returns true if any ZClasses # were registered as a result of the call or the registry was # rebuilt. jar=self._p_jar result=0
def fixupZClassDependencies(self, rebuild=0): # Note that callers should not catch exceptions from this method # to ensure that the transaction gets aborted if the registry # cannot be rebuilt for some reason. Returns true if any ZClasses # were registered as a result of the call or the registry was # rebuilt. jar=self._p_jar result=0
3,542
def fixupZClassDependencies(self, rebuild=0): # Note that callers should not catch exceptions from this method # to ensure that the transaction gets aborted if the registry # cannot be rebuilt for some reason. Returns true if any ZClasses # were registered as a result of the call or the registry was # rebuilt. jar=self._p_jar result=0
def fixupZClassDependencies(self, rebuild=0): # Note that callers should not catch exceptions from this method # to ensure that the transaction gets aborted if the registry # cannot be rebuilt for some reason. Returns true if any ZClasses # were registered as a result of the call or the registry was # rebuilt. jar=self._p_jar result=0
3,543
def checkGlobalRegistry(self): """Check the global (zclass) registry for problems, which can be caused by things like disk-based products being deleted. Return true if a problem is found""" try: keys=list(self._p_jar.root()['ZGlobals'].keys()) except: return 1 return 0
def checkGlobalRegistry(self): """Check the global (zclass) registry for problems, which can be caused by things like disk-based products being deleted. Return true if a problem is found""" try: keys=list(self._p_jar.root()['ZGlobals'].keys()) except: LOG('Zope', ERROR, 'A problem was found when checking the global product '\ 'registry. This is probably due to a Product being '\ 'uninstalled or renamed. The traceback follows.', error=sys.exc_info()) return 1 return 0
3,544
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() # b/c: Ensure that std err msg exists. if not hasattr(app, 'standard_error_message'): import Document Document.manage_addDocument( app, 'standard_error_message', 'Standard Error Message', _standard_error_msg) get_transaction().note('Added standard_error_message') get_transaction().commit() # 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) # 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(): app.fixupZClassDependencies(rebuild=1) did_fixups=1 LOG('Zope', INFO, 'A broken ZClass dependency was found in the global ' \ 'class registry. This is probably due to a product ' \ 'being uninstalled. The registry has successfully ' \ 'been rebuilt.') get_transaction().note('Rebuilt global product registry') get_transaction().commit() except: bad_things=1 LOG('Zope', ERROR, 'A problem was found in the global product registry but ' '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: if app.fixupZClassDependencies(): 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: 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() # b/c: Ensure that std err msg exists. if not hasattr(app, 'standard_error_message'): import Document Document.manage_addDocument( app, 'standard_error_message', 'Standard Error Message', _standard_error_msg) get_transaction().note('Added standard_error_message') get_transaction().commit() # 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) # 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(): 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, 'A problem was found in the global product registry but ' '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: if app.fixupZClassDependencies(): 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()
3,545
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() # b/c: Ensure that std err msg exists. if not hasattr(app, 'standard_error_message'): import Document Document.manage_addDocument( app, 'standard_error_message', 'Standard Error Message', _standard_error_msg) get_transaction().note('Added standard_error_message') get_transaction().commit() # 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) # 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(): app.fixupZClassDependencies(rebuild=1) did_fixups=1 LOG('Zope', INFO, 'A broken ZClass dependency was found in the global ' \ 'class registry. This is probably due to a product ' \ 'being uninstalled. The registry has successfully ' \ 'been rebuilt.') get_transaction().note('Rebuilt global product registry') get_transaction().commit() except: bad_things=1 LOG('Zope', ERROR, 'A problem was found in the global product registry but ' '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: if app.fixupZClassDependencies(): 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: 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() # b/c: Ensure that std err msg exists. if not hasattr(app, 'standard_error_message'): import Document Document.manage_addDocument( app, 'standard_error_message', 'Standard Error Message', _standard_error_msg) get_transaction().note('Added standard_error_message') get_transaction().commit() # 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) # 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(): app.fixupZClassDependencies(rebuild=1) did_fixups=1 LOG('Zope', INFO, 'A broken ZClass dependency was found in the global ' \ 'class registry. This is probably due to a product ' \ 'being uninstalled. The 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: if app.fixupZClassDependencies(): 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()
3,546
def __init__(self, args, fmt=''):
def __init__(self, args, fmt=''):
3,547
def __init__(self, args, fmt=''):
def __init__(self, args, fmt=''):
3,548
def render(self, md):
def render(self, md):
3,549
def _setProperty(self, id, value, type='string', meta=None): # Set a new property with the given id, value and optional type. # Note that different property sets may support different typing # systems. if not self.valid_property_id(id): raise 'Bad Request', 'Invalid property id.' self=self.v_self() if meta is None: meta={} prop={'id':id, 'type':type, 'meta':meta} self._properties=self._properties+(prop,) setattr(self, id, value)
def _setProperty(self, id, value, type='string', meta=None): # Set a new property with the given id, value and optional type. # Note that different property sets may support different typing # systems. if not self.valid_property_id(id): raise 'Bad Request', 'Invalid property id.' self=self.v_self() if meta is None: meta={} prop={'id':id, 'type':type, 'meta':meta} self._properties=self._properties+(prop,) setattr(self, id, value)
3,550
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
def dav__propstat(self, allprop, names, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
3,551
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
3,552
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
3,553
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %%s</d:status>\n%%s' \ '</d:propstat>\n' % self.xml_namespace() errormsg=' <d:responsedescription>%s</d:responsedescription>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
3,554
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not allprop and not names: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
3,555
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ps:%s/>' % name) if not result: return '' result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
3,556
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') return propstat % (result, '200 OK', '') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') return propstat % (result, '200 OK', '') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
3,557
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for item in self.propertyMap(): name, type=item['id'], item.get('type','string') meta=item.get('meta', {}) value=self.getProperty(name) if type=='tokens': value=join(value, ' ') elif type=='lines': value=join(value, '\n') if meta.get('dav_xml', 0): prop=value else: prop=' <ps:%s>%s</ps:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
3,558
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') return propstat % (result, '200 OK', '') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') return propstat % (result, '200 OK', '') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
3,559
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
3,560
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() xml_id=self.xml_namespace() for name, ns in names: if ns==xml_id: if not propdict.has_key(name): prop=' <ps:%s/>' % name emsg=errormsg % 'No such property: %s' % name result.append(propstat % (prop, '404 Not Found', emsg)) else: item=propdict[name] name, type=item['id'], item.get('type','string') meta=item.get('meta', {}) value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
3,561
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
def dav__propstat(self, allprop, vals, join=string.join): # The dav__propstat method returns a chunk of xml containing # one or more propstat elements indicating property names, # values, errors and status codes. This is called by some # of the WebDAV support machinery. If a property set does # not support WebDAV, just override this method to return # an empty string. propstat='<d:propstat%s>\n' \ ' <d:prop>\n' \ '%s\n' \ ' </d:prop>\n' \ ' <d:status>HTTP/1.1 %s</d:status>\n' \ '</d:propstat>\n' result=[] if not self.propertyMap(): return '' if not allprop and not vals: # propname request for name in self.propertyIds(): result.append(' <ns0:%s/>' % name) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') elif allprop: for name, value in self.propertyItems(): prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(prop) result=join(result, '\n') nsdef=' xmlns:ns0="%s"' % self.xml_namespace() return propstat % (nsdef, result, '200 OK') else: xml_ns=self.xml_namespace() propdict=self.propdict() nsdef=' xmlns:ns0="%s"' % self.xml_namespace() for name, ns in vals: if ns==xml_ns: if propdict.has_key(name): value=self.getProperty(name) prop=' <ns0:%s>%s</ns0:%s>' % (name, value, name) result.append(propstat % (nsdef, prop, '200 OK')) else: prop=' <ns0:%s/>' % name result.append(propstat % (nsdef, prop,'404 Not Found')) return join(result, '\n')
3,562
def odav__propstat(self, url, allprop, vals, iscol, join=string.join): # The dav__propstat method returns an xml response element # containing one or more propstats indicating property names, # values, errors and status codes. result=[] propstat='<d:propstat>\n' \ '<d:prop%s>\n' \ '%s\n' \ '</d:prop>\n' \ '<d:status>HTTP/1.1 %s</d:status>\n' \ '</d:/propstat>' if not allprop and not vals: if hasattr(aq_base(self), 'propertyMap'): for md in self.propertyMap(): prop='<z:%s/>' % md['id'] result.append(propstat % ('', prop, '200 OK'))
def odav__propstat(self, url, allprop, vals, iscol, join=string.join): # The dav__propstat method returns an xml response element # containing one or more propstats indicating property names, # values, errors and status codes. result=[] propstat='<d:propstat>\n' \ '<d:prop%s>\n' \ '%s\n' \ '</d:prop>\n' \ '<d:status>HTTP/1.1 %s</d:status>\n' \ '</d:/propstat>' if not allprop and not vals: if hasattr(aq_base(self), 'propertyMap'): for md in self.propertyMap(): prop='<z:%s/>' % md['id'] result.append(propstat % ('', prop, '200 OK'))
3,563
def ZScriptHTML_tryAction(REQUEST, argvars): """
def ZScriptHTML_tryAction(REQUEST, argvars): """
3,564
def __init__(self, index, data, view_name): try: # This is a protective barrier that hopefully prevents # us from caching something that might result in memory # leaks. It's also convenient for determining the # approximate memory usage of the cache entry. self.size = len(dumps(index)) + len(dumps(data)) except: raise CacheException('The data for the cache is not pickleable.') self.created = time.time() self.data = data self.view_name = view_name self.access_count = 0
def __init__(self, index, data, view_name): try: # This is a protective barrier that hopefully prevents # us from caching something that might result in memory # leaks. It's also convenient for determining the # approximate memory usage of the cache entry. sizer = _ByteCounter() pickler = Pickler(sizer, HIGHEST_PROTOCOL) pickler.dump(index) pickler.dump(data) self.size = sizer.getCount() except: raise CacheException('The data for the cache is not pickleable.') self.created = time.time() self.data = data self.view_name = view_name self.access_count = 0
3,565
def highlight(self, text, positions, before, after): ws = WordSequence(text, self.synstop) positions = map(None, positions)
def highlight(self, text, positions, before, after): ws = WordSequence(text, self.synstop) positions = map(None, positions)
3,566
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 path_join=os.path.join product_dir=path_join(SOFTWARE_HOME,'Products') isdir=os.path.isdir exists=os.path.exists DictType=type({}) from Folder import Folder folder_permissions={} for p in Folder.__ac_permissions__: permission, names = p[:2] folder_permissions[permission]=names meta_types=list(Folder.dynamic_meta_types) product_names=os.listdir(product_dir) product_names.sort() for product_name in product_names: package_dir=path_join(product_dir, product_name) if not isdir(package_dir): continue if not exists(path_join(package_dir, '__init__.py')): if not exists(path_join(package_dir, '__init__.pyc')): continue product=getattr(__import__("Products.%s" % product_name), product_name) permissions={} new_permissions={} for permission, names in pgetattr(product, '__ac_permissions__', ()): if names: for name in names: permissions[name]=permission elif not folder_permissions.has_key(permission): new_permissions[permission]=() for meta_type in pgetattr(product, 'meta_types', ()): if product_name=='OFSP': meta_types.insert(0,meta_type) else: meta_types.append(meta_type) name=meta_type['name'] for name,method in pgetattr(product, 'methods', {}).items(): if not hasattr(Folder, name): setattr(Folder, name, method) if name[-9:]=='__roles__': continue # Just setting roles if (permissions.has_key(name) and not folder_permissions.has_key(permissions[name])): permission=permissions[name] if new_permissions.has_key(permission): new_permissions[permission].append(name) else: new_permissions[permission]=[name] if new_permissions: new_permissions=new_permissions.items() for permission, names in new_permissions: folder_permissions[permission]=names new_permissions.sort() Folder.__dict__['__ac_permissions__']=tuple( list(Folder.__ac_permissions__)+new_permissions) misc_=pgetattr(product, 'misc_', {}) if type(misc_) is DictType: misc_=Misc_(product_name, misc_) Application.misc_.__dict__[product_name]=misc_ # Set up dynamic project information. App.Product.initializeProduct(product_name, package_dir, app) Folder.dynamic_meta_types=tuple(meta_types) Globals.default__class_init__(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 path_join=os.path.join product_dir=path_join(SOFTWARE_HOME,'Products') isdir=os.path.isdir exists=os.path.exists DictType=type({}) from Folder import Folder folder_permissions={} for p in Folder.__ac_permissions__: permission, names = p[:2] folder_permissions[permission]=names meta_types=list(Folder.dynamic_meta_types) product_names=os.listdir(product_dir) product_names.sort() for product_name in product_names: package_dir=path_join(product_dir, product_name) if not isdir(package_dir): continue if not exists(path_join(package_dir, '__init__.py')): if not exists(path_join(package_dir, '__init__.pyc')): continue product=__import__("Products.%s" % product_name, global_dict, global_dict, silly) permissions={} new_permissions={} for permission, names in pgetattr(product, '__ac_permissions__', ()): if names: for name in names: permissions[name]=permission elif not folder_permissions.has_key(permission): new_permissions[permission]=() for meta_type in pgetattr(product, 'meta_types', ()): if product_name=='OFSP': meta_types.insert(0,meta_type) else: meta_types.append(meta_type) name=meta_type['name'] for name,method in pgetattr(product, 'methods', {}).items(): if not hasattr(Folder, name): setattr(Folder, name, method) if name[-9:]=='__roles__': continue # Just setting roles if (permissions.has_key(name) and not folder_permissions.has_key(permissions[name])): permission=permissions[name] if new_permissions.has_key(permission): new_permissions[permission].append(name) else: new_permissions[permission]=[name] if new_permissions: new_permissions=new_permissions.items() for permission, names in new_permissions: folder_permissions[permission]=names new_permissions.sort() Folder.__dict__['__ac_permissions__']=tuple( list(Folder.__ac_permissions__)+new_permissions) misc_=pgetattr(product, 'misc_', {}) if type(misc_) is DictType: misc_=Misc_(product_name, misc_) Application.misc_.__dict__[product_name]=misc_ # Set up dynamic project information. App.Product.initializeProduct(product_name, package_dir, app) Folder.dynamic_meta_types=tuple(meta_types) Globals.default__class_init__(Folder)
3,567
def emitOnError(self, name, onError, position): block = self.popProgram() key, expr = parseSubstitution(onError, position) cexpr = self.compileExpression(expr) if key == "text": self.emit("insertText", cexpr, []) else: assert key == "structure" self.emit("insertStructure", cexpr, attrDict, []) self.emitEndTag(name) handler = self.popProgram() self.emit("onError", block, handler)
def emitOnError(self, name, onError, position): block = self.popProgram() key, expr = parseSubstitution(onError, position) cexpr = self.compileExpression(expr) if key == "text": self.emit("insertText", cexpr, []) else: assert key == "structure" self.emit("insertStructure", cexpr, {}, []) self.emitEndTag(name) handler = self.popProgram() self.emit("onError", block, handler)
3,568
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
3,569
def manage_workspace(self, REQUEST): """Dispatch to first interface in manage_options """ options=self.filtered_manage_options(REQUEST) try: m=options[0]['action'] if m=='manage_workspace': raise TypeError except: raise Unauthorized, ( 'You are not authorized to view this object.')
def manage_workspace(self, REQUEST): """Dispatch to first interface in manage_options """ options=self.filtered_manage_options(REQUEST) try: m=options[0]['action'] if m=='manage_workspace': raise TypeError except: raise Unauthorized, ( 'You are not authorized to view this object.')
3,570
def declareProtected(self, permission_name, *names): """Declare names to be associated with a permission.""" self._setaccess(names, permission_name)
def declareProtected(self, permission_name, name, *names): """Declare names to be associated with a permission.""" self._setaccess(names, permission_name)
3,571
def declareProtected(self, permission_name, *names): """Declare names to be associated with a permission.""" self._setaccess(names, permission_name)
def declareProtected(self, permission_name, *names): """Declare names to be associated with a permission.""" self._setaccess(names, permission_name)
3,572
def enableHTTPCompression(self,REQUEST={},force=0,disable=0,query=0): """Enable HTTP Content Encoding with gzip compression if possible
defif not force: self.appendHeader('Vary', 'Accept-Encoding') enableHTTPCompression(self,REQUEST={},force=0,disable=0,query=0):if not force: self.appendHeader('Vary', 'Accept-Encoding') """Enableif not force: self.appendHeader('Vary', 'Accept-Encoding') HTTPif not force: self.appendHeader('Vary', 'Accept-Encoding') Contentif not force: self.appendHeader('Vary', 'Accept-Encoding') Encodingif not force: self.appendHeader('Vary', 'Accept-Encoding') withif not force: self.appendHeader('Vary', 'Accept-Encoding') gzipif not force: self.appendHeader('Vary', 'Accept-Encoding') compressionif not force: self.appendHeader('Vary', 'Accept-Encoding') ifif not force: self.appendHeader('Vary', 'Accept-Encoding') possible
3,573
def appendHeader(self, name, value, delimiter=","): '''\ Append a value to a cookie Sets an HTTP return header "name" with value "value", appending it following a comma if there was a previous value set for the header. ''' headers=self.headers if headers.has_key(name): h=self.header[name] h="%s%s\n\t%s" % (h,delimiter,value) else: h=value self.setHeader(name,h)
def appendHeader(self, name, value, delimiter=","): '''\ Append a value to a header. Sets an HTTP return header "name" with value "value", appending it following a comma if there was a previous value set for the header. ''' headers=self.headers if headers.has_key(name): h=self.header[name] h="%s%s\n\t%s" % (h,delimiter,value) else: h=value self.setHeader(name,h)
3,574
def appendHeader(self, name, value, delimiter=","): '''\ Append a value to a cookie Sets an HTTP return header "name" with value "value", appending it following a comma if there was a previous value set for the header. ''' headers=self.headers if headers.has_key(name): h=self.header[name] h="%s%s\n\t%s" % (h,delimiter,value) else: h=value self.setHeader(name,h)
def appendHeader(self, name, value, delimiter=","): '''\ Append a value to a cookie Sets an HTTP return header "name" with value "value", appending it following a comma if there was a previous value set for the header. ''' headers=self.headers if headers.has_key(name): h=headers[name] h="%s%s\n\t%s" % (h,delimiter,value) else: h=value self.setHeader(name,h)
3,575
def test_suite(): return unittest.makeSuite(TALESTests)
def test_suite(): return unittest.makeSuite(TALESTests)
3,576
def insertBase(self, base_re_search=regex.compile('\(<base[\0- ]+[^>]+>\)', regex.casefold).search ): if (self.headers.has_key('content-type') and self.headers['content-type'] != 'text/html'): return
defself.setHeader('content-length', len(self.body)) insertBase(self,self.setHeader('content-length', len(self.body)) base_re_search=regex.compile('\(<base[\0-self.setHeader('content-length', len(self.body)) ]+[^>]+>\)',self.setHeader('content-length', len(self.body)) regex.casefold).searchself.setHeader('content-length', len(self.body)) ):self.setHeader('content-length', len(self.body)) ifself.setHeader('content-length', len(self.body)) (self.headers.has_key('content-type')self.setHeader('content-length', len(self.body)) andself.setHeader('content-length', len(self.body)) self.headers['content-type']self.setHeader('content-length', len(self.body)) !=self.setHeader('content-length', len(self.body)) 'text/html'):self.setHeader('content-length', len(self.body)) return
3,577
def _apply_index(self, request, cid='', type=type, None=None): """Apply the index to query parameters given in the request arg.
def _apply_index(self, request, cid='', type=type, None=None): """Apply the index to query parameters given in the request arg.
3,578
def tpValues(self): # Return a list of subobjects, used by tree tag. r=[] if hasattr(aq_base(self), 'tree_ids'): tree_ids=self.tree_ids try: tree_ids=list(tree_ids) except TypeError: pass if hasattr(tree_ids, 'sort'): tree_ids.sort() for id in tree_ids: if hasattr(self, id): r.append(self._getOb(id)) else: obj_ids=self.objectIds() obj_ids.sort() for id in obj_ids: o=self._getOb(id) if hasattr(o, 'isPrincipiaFolderish') and \ o.isPrincipiaFolderish: r.append(o) return r
def tpValues(self): # Return a list of subobjects, used by tree tag. r=[] if hasattr(aq_base(self), 'tree_ids'): tree_ids=self.tree_ids try: tree_ids=list(tree_ids) except TypeError: pass if hasattr(tree_ids, 'sort'): tree_ids.sort() for id in tree_ids: if hasattr(self, id): r.append(self._getOb(id)) else: obj_ids=self.objectIds() obj_ids.sort() for id in obj_ids: o=self._getOb(id) if hasattr(aq_base(o), 'isPrincipiaFolderish') and \ o.isPrincipiaFolderish: r.append(o) return r
3,579
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
3,580
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
3,581
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
3,582
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
3,583
def findChildren(obj,dirname=''): """ recursive walk through the object hierarchy to find all children of an object (ajung) """ lst =[] for name,child in obj.objectItems(): if child.meta_type=="Folder": lst.extend(findChildren(child,dirname+ obj.id + '/')) else: lst.append( (dirname + obj.id + "/" + name,child) ) return lst
def findChildren(obj,dirname=''): """ recursive walk through the object hierarchy to find all children of an object (ajung) """ lst = [] for name, child in obj.objectItems(): if hasattr(aq_base(child), 'isPrincipiaFolderish') and child.isPrincipiaFolderish: lst.extend(findChildren(child, dirname + obj.id + '/')) else: lst.append( (dirname + obj.id + "/" + name,child) ) return lst
3,584
def findChildren(obj,dirname=''): """ recursive walk through the object hierarchy to find all children of an object (ajung) """ lst =[] for name,child in obj.objectItems(): if child.meta_type=="Folder": lst.extend(findChildren(child,dirname+ obj.id + '/')) else: lst.append( (dirname + obj.id + "/" + name,child) ) return lst
def findChildren(obj,dirname=''): """ recursive walk through the object hierarchy to find all children of an object (ajung) """ lst =[] for name,child in obj.objectItems(): if child.meta_type=="Folder": lst.extend(findChildren(child,dirname+ obj.id + '/')) else: lst.append((dirname + obj.id + "/" + name, child)) return lst
3,585
def update_data(self, data, content_type=None, size=None): if content_type is not None: self.content_type=content_type if size is None: size=len(data)
def update_data(self, data, content_type=None, size=None): if content_type is not None: self.content_type=content_type if size is None: size=len(data)
3,586
def untabify(aString): '''\ Convert indentation tabs to spaces. ''' result='' rest=aString while 1: ts_results = indent_tab.search_group(rest, (1,2)) if ts_results: start, grps = ts_results lnl=len(grps[0]) indent=len(grps[1]) result=result+rest[:start] rest="\n%s%s" % (' ' * ((indent/8+1)*8), rest[start+indent+1+lnl:]) else: return result+rest
def untabify(aString): '''\ Convert indentation tabs to spaces. ''' result='' rest=aString while 1: ts_results = indent_tab(rest, (1,2)) if ts_results: start, grps = ts_results lnl=len(grps[0]) indent=len(grps[1]) result=result+rest[:start] rest="\n%s%s" % (' ' * ((indent/8+1)*8), rest[start+indent+1+lnl:]) else: return result+rest
3,587
def indent_level(aString): '''\ Find the minimum indentation for a string, not counting blank lines. ''' start=0 text='\n'+aString indent=l=len(text) while 1: ts_results = indent_space.search_group(text, (1,2), start) if ts_results: start, grps = ts_results i=len(grps[0]) start=start+i+1 if start < l and text[start] != '\n': # Skip blank lines if not i: return (0,aString) if i < indent: indent = i else: return (indent,aString)
def indent_level(aString, indent_space=ts_regex.compile('\n\( *\)').search_group, ): '''\ Find the minimum indentation for a string, not counting blank lines. ''' start=0 text='\n'+aString indent=l=len(text) while 1: ts_results = indent_space.search_group(text, (1,2), start) if ts_results: start, grps = ts_results i=len(grps[0]) start=start+i+1 if start < l and text[start] != '\n': # Skip blank lines if not i: return (0,aString) if i < indent: indent = i else: return (indent,aString)
3,588
def indent_level(aString): '''\ Find the minimum indentation for a string, not counting blank lines. ''' start=0 text='\n'+aString indent=l=len(text) while 1: ts_results = indent_space.search_group(text, (1,2), start) if ts_results: start, grps = ts_results i=len(grps[0]) start=start+i+1 if start < l and text[start] != '\n': # Skip blank lines if not i: return (0,aString) if i < indent: indent = i else: return (indent,aString)
def indent_level(aString): '''\ Find the minimum indentation for a string, not counting blank lines. ''' start=0 text='\n'+aString indent=l=len(text) while 1: ts_results = indent_space(text, (1,2), start) if ts_results: start, grps = ts_results i=len(grps[0]) start=start+i+1 if start < l and text[start] != '\n': # Skip blank lines if not i: return (0,aString) if i < indent: indent = i else: return (indent,aString)
3,589
def structure(list): if not list: return [] i=0 l=len(list) r=[] while i < l: sublen=paragraphs(list,i) i=i+1 r.append((list[i-1][1],structure(list[i:i+sublen]))) i=i+sublen return r
def structure(list): if not list: return [] i=0 l=len(list) r=[] while i < l: sublen=paragraphs(list,i) i=i+1 r.append((list[i-1][1],structure(list[i:i+sublen]))) i=i+sublen return r
3,590
def __init__(self, aStructuredString, level=0): '''Convert a structured text string into a structured text object.
def __init__(self, aStructuredString, level=0, paragraph_divider=regex.compile('\(\n *\)+\n'), ): '''Convert a structured text string into a structured text object.
3,591
def __str__(self): return str(self.structure)
def __str__(self): return str(self.structure)
3,592
def ctag(s): if s is None: s='' s=gsub(strong,'\\1<strong>\\2</strong>\\3',s) s=gsub(under, '\\1<u>\\2</u>\\3',s) s=gsub(code, '\\1<code>\\2</code>\\3',s) s=gsub(em, '\\1<em>\\2</em>\\3',s) return s
def ctag(s, em=regex.compile( ctag_prefix+(ctag_middle % (("*",)*6) )+ctag_suffix), strong=regex.compile( ctag_prefix+(ctag_middl2 % (("*",)*8))+ctag_suffix), under=regex.compile( ctag_prefix+(ctag_middle % (("_",)*6) )+ctag_suffix), code=regex.compile( ctag_prefix+(ctag_middle % (("\'",)*6))+ctag_suffix), ): if s is None: s='' s=gsub(strong,'\\1<strong>\\2</strong>\\3',s) s=gsub(under, '\\1<u>\\2</u>\\3',s) s=gsub(code, '\\1<code>\\2</code>\\3',s) s=gsub(em, '\\1<em>\\2</em>\\3',s) return s
3,593
def __str__(self, extra_dl=ts_regex.compile("</dl>\n<dl>"), extra_ul=ts_regex.compile("</ul>\n<ul>"), extra_ol=ts_regex.compile("</ol>\n<ol>"), ): '''\ Return an HTML string representation of the structured text data.
def __str__(self, extra_dl=regex.compile("</dl>\n<dl>"), extra_ul=regex.compile("</ul>\n<ul>"), extra_ol=regex.compile("</ol>\n<ol>"), ): '''\ Return an HTML string representation of the structured text data.
3,594
def _str(self,structure,level): r='' for s in structure: # print s[0],'\n', len(s[1]), '\n\n' ts_results = bullet.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ul(r,p,self._str(s[1],level)) else: ts_results = ol.match_group(s[0], (3,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = olp.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = dl.match_group(s[0], (1,2)) if ts_results: t,d = ts_results[1] r=self.dl(r,t,d,self._str(s[1],level)) else: if example(s[0]) >= 0 and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0],self.pre(s[1])) else: if s[0][-2:]=='::' and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0][:-1],self.pre(s[1])) else:
def _str(self,structure,level, bullet=ts_regex.compile('[ \t\n]*[o*-][ \t\n]+\([^\0]*\)' ).match_group, example=ts_regex.compile('[\0- ]examples?:[\0- ]*$' ).search, dl=ts_regex.compile('\([^\n]+\)[ \t]+--[ \t\n]+\([^\0]*\)' ).match_group, nl=ts_regex.compile('\n').search, ol=ts_regex.compile( '[ \t]*\(\([0-9]+\|[a-zA-Z]+\)[.)]\)+[ \t\n]+\([^\0]*\|$\)' ).match_group, olp=ts_regex.compile('[ \t]*([0-9]+)[ \t\n]+\([^\0]*\|$\)' ).match_group, ): r='' for s in structure: # print s[0],'\n', len(s[1]), '\n\n' ts_results = bullet.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ul(r,p,self._str(s[1],level)) else: ts_results = ol.match_group(s[0], (3,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = olp.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = dl.match_group(s[0], (1,2)) if ts_results: t,d = ts_results[1] r=self.dl(r,t,d,self._str(s[1],level)) else: if example(s[0]) >= 0 and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0],self.pre(s[1])) else: if s[0][-2:]=='::' and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0][:-1],self.pre(s[1])) else:
3,595
def _str(self,structure,level): r='' for s in structure: # print s[0],'\n', len(s[1]), '\n\n' ts_results = bullet.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ul(r,p,self._str(s[1],level)) else: ts_results = ol.match_group(s[0], (3,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = olp.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = dl.match_group(s[0], (1,2)) if ts_results: t,d = ts_results[1] r=self.dl(r,t,d,self._str(s[1],level)) else: if example(s[0]) >= 0 and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0],self.pre(s[1])) else: if s[0][-2:]=='::' and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0][:-1],self.pre(s[1])) else:
def _str(self,structure,level): r='' for s in structure: # print s[0],'\n', len(s[1]), '\n\n' ts_results = bullet(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ul(r,p,self._str(s[1],level)) else: ts_results = ol.match_group(s[0], (3,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = olp.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = dl.match_group(s[0], (1,2)) if ts_results: t,d = ts_results[1] r=self.dl(r,t,d,self._str(s[1],level)) else: if example(s[0]) >= 0 and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0],self.pre(s[1])) else: if s[0][-2:]=='::' and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0][:-1],self.pre(s[1])) else:
3,596
def _str(self,structure,level): r='' for s in structure: # print s[0],'\n', len(s[1]), '\n\n' ts_results = bullet.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ul(r,p,self._str(s[1],level)) else: ts_results = ol.match_group(s[0], (3,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = olp.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = dl.match_group(s[0], (1,2)) if ts_results: t,d = ts_results[1] r=self.dl(r,t,d,self._str(s[1],level)) else: if example(s[0]) >= 0 and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0],self.pre(s[1])) else: if s[0][-2:]=='::' and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0][:-1],self.pre(s[1])) else:
def _str(self,structure,level): r='' for s in structure: # print s[0],'\n', len(s[1]), '\n\n' ts_results = bullet.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ul(r,p,self._str(s[1],level)) else: ts_results = ol(s[0], (3,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = olp.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = dl.match_group(s[0], (1,2)) if ts_results: t,d = ts_results[1] r=self.dl(r,t,d,self._str(s[1],level)) else: if example(s[0]) >= 0 and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0],self.pre(s[1])) else: if s[0][-2:]=='::' and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0][:-1],self.pre(s[1])) else:
3,597
def _str(self,structure,level): r='' for s in structure: # print s[0],'\n', len(s[1]), '\n\n' ts_results = bullet.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ul(r,p,self._str(s[1],level)) else: ts_results = ol.match_group(s[0], (3,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = olp.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = dl.match_group(s[0], (1,2)) if ts_results: t,d = ts_results[1] r=self.dl(r,t,d,self._str(s[1],level)) else: if example(s[0]) >= 0 and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0],self.pre(s[1])) else: if s[0][-2:]=='::' and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0][:-1],self.pre(s[1])) else:
def _str(self,structure,level): r='' for s in structure: # print s[0],'\n', len(s[1]), '\n\n' ts_results = bullet.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ul(r,p,self._str(s[1],level)) else: ts_results = ol.match_group(s[0], (3,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = olp(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = dl.match_group(s[0], (1,2)) if ts_results: t,d = ts_results[1] r=self.dl(r,t,d,self._str(s[1],level)) else: if example(s[0]) >= 0 and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0],self.pre(s[1])) else: if s[0][-2:]=='::' and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0][:-1],self.pre(s[1])) else:
3,598
def _str(self,structure,level): r='' for s in structure: # print s[0],'\n', len(s[1]), '\n\n' ts_results = bullet.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ul(r,p,self._str(s[1],level)) else: ts_results = ol.match_group(s[0], (3,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = olp.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = dl.match_group(s[0], (1,2)) if ts_results: t,d = ts_results[1] r=self.dl(r,t,d,self._str(s[1],level)) else: if example(s[0]) >= 0 and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0],self.pre(s[1])) else: if s[0][-2:]=='::' and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0][:-1],self.pre(s[1])) else:
def _str(self,structure,level): r='' for s in structure: # print s[0],'\n', len(s[1]), '\n\n' ts_results = bullet.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ul(r,p,self._str(s[1],level)) else: ts_results = ol.match_group(s[0], (3,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = olp.match_group(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = dl(s[0], (1,2)) if ts_results: t,d = ts_results[1] r=self.dl(r,t,d,self._str(s[1],level)) else: if example(s[0]) >= 0 and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0],self.pre(s[1])) else: if s[0][-2:]=='::' and s[1]: # Introduce an example, using pre tags: r=self.normal(r,s[0][:-1],self.pre(s[1])) else:
3,599