bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def _search_before(self, c, oid, tid, end_tid): # Operates on the cursor created by loadBefore(). p = c.prev() if p is None: return None key, rec = p # If the previous record is for a different oid, then # there is no matching record. if key[:8] != oid: return None vid, nvrevid, lrevid = unpack(">8s8s8s", rec[:24]) if vid == ZERO: revid = lrevid else: revid = nvrevid data = self._pickles[oid+revid] start_tid = key[8:] return data, start_tid, end_tid
def _search_before(self, c, oid, tid, end_tid): # Operates on the cursor created by loadBefore(). p = c.prev() if p is None: return None key, rec = p # If the previous record is for a different oid, then # there is no matching record. if key[:8] != oid: return None vid, nvrevid, lrevid = unpack(">8s8s8s", rec[:24]) if vid == ZERO: revid = lrevid else: revid = start_tid = nvrevid while True: rec = c.next() if rec is None or rec[0][:8] <> oid: end_tid = None break vid = rec[1][:8] if vid == ZERO: end_tid = rec[0][8:] break data = self._pickles[oid+revid] start_tid = key[8:] return data, start_tid, end_tid
2,200
def _search_before(self, c, oid, tid, end_tid): # Operates on the cursor created by loadBefore(). p = c.prev() if p is None: return None key, rec = p # If the previous record is for a different oid, then # there is no matching record. if key[:8] != oid: return None vid, nvrevid, lrevid = unpack(">8s8s8s", rec[:24]) if vid == ZERO: revid = lrevid else: revid = nvrevid data = self._pickles[oid+revid] start_tid = key[8:] return data, start_tid, end_tid
def _search_before(self, c, oid, tid, end_tid): # Operates on the cursor created by loadBefore(). p = c.prev() if p is None: return None key, rec = p # If the previous record is for a different oid, then # there is no matching record. if key[:8] != oid: return None vid, nvrevid, lrevid = unpack(">8s8s8s", rec[:24]) if vid == ZERO: revid = lrevid else: revid = nvrevid data = self._pickles[oid+revid] return data, start_tid, end_tid
2,201
def manage_convertIndexes(self, REQUEST=None, RESPONSE=None, URL1=None): """Recreate indexes derived from UnIndex because the implementation of __len__ changed in Zope 2.8. Pre-Zope 2.7 installation used to implement __len__ as persistent attribute of the index instance which is totally incompatible with the new extension class implementation based on new-style classes. """
def manage_convertIndexes(self, REQUEST=None, RESPONSE=None, URL1=None): """Recreate indexes derived from UnIndex because the implementation of __len__ changed in Zope 2.8. Pre-Zope 2.7 installation used to implement __len__ as persistent attribute of the index instance which is totally incompatible with the new extension class implementation based on new-style classes. """
2,202
def has_codec(x): try: codecs.lookup(x) except LookupError: return 0 else: return 1
def has_codec(x): try: codecs.lookup(x) except (LookupError, SystemError): return 0 else: return 1
2,203
def parse_params(text, result=None, tag='', unparmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)\)'), qunparmre=regex.compile( '\([\0- ]*\("[^\0- =\"]+"\)\)'), parmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)=\([^\0- =\"]+\)\)'), qparmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)="\([^"]*\)\"\)'), **parms): """Parse tag parameters The format of tag parameters consists of 1 or more parameter specifications separated by whitespace. Each specification consists of an unnamed and unquoted value, a valueless name, or a name-value pair. A name-value pair consists of a name and a quoted or unquoted value separated by an '='. The input parameter, text, gives the text to be parsed. The keyword parameters give valid parameter names and default values. If a specification is not a name-value pair and it is not the first specification and it is a valid parameter name, then it is treated as a name-value pair with a value as given in the keyword argument. Otherwise, if it is not a name-value pair, it is treated as an unnamed value. The data are parsed into a dictionary mapping names to values. Unnamed values are mapped from the name '""'. Only one value may be given for a name and there may be only one unnamed value. """ result=result or {} if parmre.match(text) >= 0: name=lower(parmre.group(2)) value=parmre.group(3) l=len(parmre.group(1)) elif qparmre.match(text) >= 0: name=lower(qparmre.group(2)) value=qparmre.group(3) l=len(qparmre.group(1)) elif unparmre.match(text) >= 0: name=unparmre.group(2) l=len(unparmre.group(1)) if result: if parms.has_key(name): if parms[name] is None: raise ParseError, ( 'Attribute %s requires a value' % name, tag) result[name]=parms[name] else: raise ParseError, ( 'Invalid attribute name, "%s"' % name, tag) else: result['']=name return apply(parse_params,(text[l:],result),parms) elif qunparmre.match(text) >= 0: name=qunparmre.group(2) l=len(qunparmre.group(1)) if result: raise ParseError, ( 'Invalid attribute name, "%s"' % name, tag) else: result['']=name return apply(parse_params,(text[l:],result),parms) else: if not text or not strip(text): return result raise ParseError, ('invalid parameter: "%s"' % text, tag) if not parms.has_key(name): raise ParseError, ( 'Invalid attribute name, "%s"' % name, tag) if result.has_key(name): p=parms[name] if type(p) is not ListType or p: raise ParseError, ( 'Duplicate values for attribute "%s"' % name, tag) result[name]=value text=strip(text[l:]) if text: return apply(parse_params,(text,result),parms) else: return result
def parse_params(text, result=None, tag='', unparmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)\)'), qunparmre=regex.compile( '\([\0- ]*\("[^"]*"\)\)'), parmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)=\([^\0- =\"]+\)\)'), qparmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)="\([^"]*\)\"\)'), **parms): """Parse tag parameters The format of tag parameters consists of 1 or more parameter specifications separated by whitespace. Each specification consists of an unnamed and unquoted value, a valueless name, or a name-value pair. A name-value pair consists of a name and a quoted or unquoted value separated by an '='. The input parameter, text, gives the text to be parsed. The keyword parameters give valid parameter names and default values. If a specification is not a name-value pair and it is not the first specification and it is a valid parameter name, then it is treated as a name-value pair with a value as given in the keyword argument. Otherwise, if it is not a name-value pair, it is treated as an unnamed value. The data are parsed into a dictionary mapping names to values. Unnamed values are mapped from the name '""'. Only one value may be given for a name and there may be only one unnamed value. """ result=result or {} if parmre.match(text) >= 0: name=lower(parmre.group(2)) value=parmre.group(3) l=len(parmre.group(1)) elif qparmre.match(text) >= 0: name=lower(qparmre.group(2)) value=qparmre.group(3) l=len(qparmre.group(1)) elif unparmre.match(text) >= 0: name=unparmre.group(2) l=len(unparmre.group(1)) if result: if parms.has_key(name): if parms[name] is None: raise ParseError, ( 'Attribute %s requires a value' % name, tag) result[name]=parms[name] else: raise ParseError, ( 'Invalid attribute name, "%s"' % name, tag) else: result['']=name return apply(parse_params,(text[l:],result),parms) elif qunparmre.match(text) >= 0: name=qunparmre.group(2) l=len(qunparmre.group(1)) if result: raise ParseError, ( 'Invalid attribute name, "%s"' % name, tag) else: result['']=name return apply(parse_params,(text[l:],result),parms) else: if not text or not strip(text): return result raise ParseError, ('invalid parameter: "%s"' % text, tag) if not parms.has_key(name): raise ParseError, ( 'Invalid attribute name, "%s"' % name, tag) if result.has_key(name): p=parms[name] if type(p) is not ListType or p: raise ParseError, ( 'Duplicate values for attribute "%s"' % name, tag) result[name]=value text=strip(text[l:]) if text: return apply(parse_params,(text,result),parms) else: return result
2,204
def parse(text, result=None, keys=None, unparmre=re.compile( r'([\000- ]*([^\000- ="]+))'), parmre=re.compile( r'([\000- ]*([^\000- ="]+)=([^\000- ="]+))'), qparmre=re.compile( r'([\000- ]*([^\000- ="]+)="([^"]*)")'), ): if result is None: result = {} keys=[] __traceback_info__=text mo = parmre.match(text) if mo: name=mo.group(2) value={'default':mo.group(3)} l=len(mo.group(1)) else: mo = qparmre.match(text) if mo: name=mo.group(1) value={'default':mo.group(3)} l=len(mo.group(2)) else: mo = unparmre.match(text) if ts_results: name=mo.group(2) l=len(mo.group(1)) value={} else: if not text or not strip(text): return Args(result,keys) raise InvalidParameter, text lt=string.find(name,':') if lt > 0: value['type']=name[lt+1:] name=name[:lt] result[name]=value keys.append(name) return parse(text[l:],result,keys)
def parse(text, result=None, keys=None, unparmre=re.compile( r'([\000- ]*([^\000- ="]+))'), parmre=re.compile( r'([\000- ]*([^\000- ="]+)=([^\000- ="]+))'), qparmre=re.compile( r'([\000- ]*([^\000- ="]+)="([^"]*)")'), ): if result is None: result = {} keys=[] __traceback_info__=text mo = parmre.match(text) if mo: name=mo.group(2) value={'default':mo.group(3)} l=len(mo.group(1)) else: mo = qparmre.match(text) if mo: name=mo.group(1) value={'default':mo.group(3)} l=len(mo.group(2)) else: mo = unparmre.match(text) if mo: name=mo.group(2) l=len(mo.group(1)) value={} else: if not text or not strip(text): return Args(result,keys) raise InvalidParameter, text lt=string.find(name,':') if lt > 0: value['type']=name[lt+1:] name=name[:lt] result[name]=value keys.append(name) return parse(text[l:],result,keys)
2,205
def emitEndElement(self, name, isend=0, implied=0): todo = self.todoPop() if not todo: # Shortcut if not isend: self.emitEndTag(name) return
def emitEndElement(self, name, isend=0, implied=0): todo = self.todoPop() if not todo: # Shortcut if not isend: self.emitEndTag(name) return
2,206
def addAttribute(dic, attr, msgid, position, xml): if not xml: attr = attr.lower() if attr in dic: raise TALError( "attribute may only be specified once in i18n:attributes: " + attr, position) dic[attr] = msgid
def addAttribute(dic, attr, msgid, position, xml): if not xml: attr = attr.lower() if attr in dic: raise TALError( "attribute may only be specified once in i18n:attributes: " + attr, position) dic[attr] = msgid
2,207
def __init__(self, args): args = parse_params(args, name='', type=None, column=None, multiple=1, optional=1, op=None) self.__name__ = name_param(args,'sqlvar') has_key=args.has_key if not has_key('type'): raise ParseError, ('the type attribute is required', 'sqltest') self.type=t=args['type'] if not valid_type(t): raise ParseError, ('invalid type, %s' % t, 'sqltest') if has_key('optional'): self.optional=args['optional'] if has_key('multiple'): self.multiple=args['multiple'] if has_key('column'): self.column=args['column'] else: self.column=self.__name__
def __init__(self, args): args = parse_params(args, name='', expr='', type=None, column=None, multiple=1, optional=1, op=None) self.__name__ = name_param(args,'sqlvar') has_key=args.has_key if not has_key('type'): raise ParseError, ('the type attribute is required', 'sqltest') self.type=t=args['type'] if not valid_type(t): raise ParseError, ('invalid type, %s' % t, 'sqltest') if has_key('optional'): self.optional=args['optional'] if has_key('multiple'): self.multiple=args['multiple'] if has_key('column'): self.column=args['column'] else: self.column=self.__name__
2,208
def __init__(self, args): args = parse_params(args, name='', type=None, column=None, multiple=1, optional=1, op=None) self.__name__ = name_param(args,'sqlvar') has_key=args.has_key if not has_key('type'): raise ParseError, ('the type attribute is required', 'sqltest') self.type=t=args['type'] if not valid_type(t): raise ParseError, ('invalid type, %s' % t, 'sqltest') if has_key('optional'): self.optional=args['optional'] if has_key('multiple'): self.multiple=args['multiple'] if has_key('column'): self.column=args['column'] else: self.column=self.__name__
def __init__(self, args): args = parse_params(args, name='', type=None, column=None, multiple=1, optional=1, op=None) name,expr = name_param(args,'sqlvar',1) if expr is None: expr=name else: expr=expr.eval self.__name__, self.expr = name, expr self.args=args if not args.has_key('type'): raise ParseError, ('the type attribute is required', 'sqltest') self.type=t=args['type'] if not valid_type(t): raise ParseError, ('invalid type, %s' % t, 'sqltest') if has_key('optional'): self.optional=args['optional'] if has_key('multiple'): self.multiple=args['multiple'] if has_key('column'): self.column=args['column'] else: self.column=self.__name__
2,209
def __init__(self, args): args = parse_params(args, name='', type=None, column=None, multiple=1, optional=1, op=None) self.__name__ = name_param(args,'sqlvar') has_key=args.has_key if not has_key('type'): raise ParseError, ('the type attribute is required', 'sqltest') self.type=t=args['type'] if not valid_type(t): raise ParseError, ('invalid type, %s' % t, 'sqltest') if has_key('optional'): self.optional=args['optional'] if has_key('multiple'): self.multiple=args['multiple'] if has_key('column'): self.column=args['column'] else: self.column=self.__name__
def __init__(self, args): args = parse_params(args, name='', type=None, column=None, multiple=1, optional=1, op=None) self.__name__ = name_param(args,'sqlvar') has_key=args.has_key if not has_key('type'): raise ParseError, ('the type attribute is required', 'sqltest') self.type=t=args['type'] if not valid_type(t): raise ParseError, ('invalid type, %s' % t, 'sqltest') if has_key('optional'): self.optional=args['optional'] if has_key('multiple'): self.multiple=args['multiple'] if has_key('column'): self.column=args['column'] else: self.column=self.__name__
2,210
def __init__(self, args): args = parse_params(args, name='', type=None, column=None, multiple=1, optional=1, op=None) self.__name__ = name_param(args,'sqlvar') has_key=args.has_key if not has_key('type'): raise ParseError, ('the type attribute is required', 'sqltest') self.type=t=args['type'] if not valid_type(t): raise ParseError, ('invalid type, %s' % t, 'sqltest') if has_key('optional'): self.optional=args['optional'] if has_key('multiple'): self.multiple=args['multiple'] if has_key('column'): self.column=args['column'] else: self.column=self.__name__
def __init__(self, args): args = parse_params(args, name='', type=None, column=None, multiple=1, optional=1, op=None) self.__name__ = name_param(args,'sqlvar') has_key=args.has_key if not has_key('type'): raise ParseError, ('the type attribute is required', 'sqltest') self.type=t=args['type'] if not valid_type(t): raise ParseError, ('invalid type, %s' % t, 'sqltest') if has_key('optional'): self.optional=args['optional'] if has_key('multiple'): self.multiple=args['multiple'] if has_key('column'): self.column=args['column'] else: self.column=self.__name__
2,211
def render(self, md): name=self.__name__ t=self.type try: v = md[name] except KeyError, key: if str(key)==name and self.optional: return '' raise KeyError, key, sys.exc_info()[2] if type(v) in (ListType, TupleType): if len(v) > 1 and not self.multiple: raise 'Multiple Values', ( 'multiple values are not allowed for <em>%s</em>' % name) else: v=[v] vs=[] for v in v: if not v and type(v) is StringType and t != 'string': continue if t=='int': try: if type(v) is StringType: atoi(v) else: v=str(int(v)) except: raise ValueError, ( 'Invalid integer value for <em>%s</em>' % name) elif t=='float': if not v and type(v) is StringType: continue try: if type(v) is StringType: atof(v) else: v=str(float(v)) except: raise ValueError, ( 'Invalid floating-point value for <em>%s</em>' % name) else: v=str(v) v=md.getitem('sql_quote__',0)(v) #if find(v,"\'") >= 0: v=join(split(v,"\'"),"''") #v="'%s'" % v vs.append(v)
def render(self, md): name=self.__name__ t=self.type try: v = md[name] except KeyError, key: if str(key)==name and self.optional: return '' raise KeyError, key, sys.exc_info()[2] if type(v) in (ListType, TupleType): if len(v) > 1 and not self.multiple: raise 'Multiple Values', ( 'multiple values are not allowed for <em>%s</em>' % name) else: v=[v] vs=[] for v in v: if not v and type(v) is StringType and t != 'string': continue if t=='int': try: if type(v) is StringType: atoi(v) else: v=str(int(v)) except: raise ValueError, ( 'Invalid integer value for <em>%s</em>' % name) elif t=='float': if not v and type(v) is StringType: continue try: if type(v) is StringType: atof(v) else: v=str(float(v)) except: raise ValueError, ( 'Invalid floating-point value for <em>%s</em>' % name) else: v=str(v) v=md.getitem('sql_quote__',0)(v) #if find(v,"\'") >= 0: v=join(split(v,"\'"),"''") #v="'%s'" % v vs.append(v)
2,212
def render(self, md): name=self.__name__ t=self.type try: v = md[name] except KeyError, key: if str(key)==name and self.optional: return '' raise KeyError, key, sys.exc_info()[2] if type(v) in (ListType, TupleType): if len(v) > 1 and not self.multiple: raise 'Multiple Values', ( 'multiple values are not allowed for <em>%s</em>' % name) else: v=[v] vs=[] for v in v: if not v and type(v) is StringType and t != 'string': continue if t=='int': try: if type(v) is StringType: atoi(v) else: v=str(int(v)) except: raise ValueError, ( 'Invalid integer value for <em>%s</em>' % name) elif t=='float': if not v and type(v) is StringType: continue try: if type(v) is StringType: atof(v) else: v=str(float(v)) except: raise ValueError, ( 'Invalid floating-point value for <em>%s</em>' % name) else: v=str(v) v=md.getitem('sql_quote__',0)(v) #if find(v,"\'") >= 0: v=join(split(v,"\'"),"''") #v="'%s'" % v vs.append(v)
def render(self, md): name=self.__name__ t=self.type args=self.args try: expr=self.expr if type(expr) is type(''): v=md[expr] else: v=expr(md) except KeyError: if args.has_key('optional') and args['optional']: return '' raise 'Missing Input', 'Missing input variable, <em>%s</em>' % name if type(v) in (ListType, TupleType): if len(v) > 1 and not self.multiple: raise 'Multiple Values', ( 'multiple values are not allowed for <em>%s</em>' % name) else: v=[v] vs=[] for v in v: if not v and type(v) is StringType and t != 'string': continue if t=='int': try: if type(v) is StringType: atoi(v) else: v=str(int(v)) except: raise ValueError, ( 'Invalid integer value for <em>%s</em>' % name) elif t=='float': if not v and type(v) is StringType: continue try: if type(v) is StringType: atof(v) else: v=str(float(v)) except: raise ValueError, ( 'Invalid floating-point value for <em>%s</em>' % name) else: v=str(v) v=md.getitem('sql_quote__',0)(v) #if find(v,"\'") >= 0: v=join(split(v,"\'"),"''") #v="'%s'" % v vs.append(v)
2,213
def render(self, md): name=self.__name__ t=self.type try: v = md[name] except KeyError, key: if str(key)==name and self.optional: return '' raise KeyError, key, sys.exc_info()[2] if type(v) in (ListType, TupleType): if len(v) > 1 and not self.multiple: raise 'Multiple Values', ( 'multiple values are not allowed for <em>%s</em>' % name) else: v=[v] vs=[] for v in v: if not v and type(v) is StringType and t != 'string': continue if t=='int': try: if type(v) is StringType: atoi(v) else: v=str(int(v)) except: raise ValueError, ( 'Invalid integer value for <em>%s</em>' % name) elif t=='float': if not v and type(v) is StringType: continue try: if type(v) is StringType: atof(v) else: v=str(float(v)) except: raise ValueError, ( 'Invalid floating-point value for <em>%s</em>' % name) else: v=str(v) v=md.getitem('sql_quote__',0)(v) #if find(v,"\'") >= 0: v=join(split(v,"\'"),"''") #v="'%s'" % v vs.append(v)
def render(self, md): name=self.__name__ t=self.type try: v = md[name] except KeyError, key: if str(key)==name and self.optional: return '' raise KeyError, key, sys.exc_info()[2] if type(v) in (ListType, TupleType): if len(v) > 1 and not self.multiple: raise 'Multiple Values', ( 'multiple values are not allowed for <em>%s</em>' % name) else: v=[v] vs=[] for v in v: if not v and type(v) is StringType and t != 'string': continue if t=='int': try: if type(v) is StringType: if v[-1:]=='L': v=v[:-1] atoi(v) else: v=str(int(v)) except: raise ValueError, ( 'Invalid integer value for <em>%s</em>' % name) elif t=='float': if not v and type(v) is StringType: continue try: if type(v) is StringType: atof(v) else: v=str(float(v)) except: raise ValueError, ( 'Invalid floating-point value for <em>%s</em>' % name) else: v=str(v) v=md.getitem('sql_quote__',0)(v) #if find(v,"\'") >= 0: v=join(split(v,"\'"),"''") #v="'%s'" % v vs.append(v)
2,214
def render(self, md): name=self.__name__ t=self.type try: v = md[name] except KeyError, key: if str(key)==name and self.optional: return '' raise KeyError, key, sys.exc_info()[2] if type(v) in (ListType, TupleType): if len(v) > 1 and not self.multiple: raise 'Multiple Values', ( 'multiple values are not allowed for <em>%s</em>' % name) else: v=[v] vs=[] for v in v: if not v and type(v) is StringType and t != 'string': continue if t=='int': try: if type(v) is StringType: atoi(v) else: v=str(int(v)) except: raise ValueError, ( 'Invalid integer value for <em>%s</em>' % name) elif t=='float': if not v and type(v) is StringType: continue try: if type(v) is StringType: atof(v) else: v=str(float(v)) except: raise ValueError, ( 'Invalid floating-point value for <em>%s</em>' % name) else: v=str(v) v=md.getitem('sql_quote__',0)(v) #if find(v,"\'") >= 0: v=join(split(v,"\'"),"''") #v="'%s'" % v vs.append(v)
def render(self, md): name=self.__name__ t=self.type try: v = md[name] except KeyError, key: if str(key)==name and self.optional: return '' raise KeyError, key, sys.exc_info()[2] if type(v) in (ListType, TupleType): if len(v) > 1 and not self.multiple: raise 'Multiple Values', ( 'multiple values are not allowed for <em>%s</em>' % name) else: v=[v] vs=[] for v in v: if not v and type(v) is StringType and t != 'string': continue if t=='int': try: if type(v) is StringType: atoi(v) else: v=str(int(v)) except ValueError: raise ValueError, ( 'Invalid integer value for <em>%s</em>' % name) elif t=='float': if not v and type(v) is StringType: continue try: if type(v) is StringType: atof(v) else: v=str(float(v)) except ValueError: raise ValueError, ( 'Invalid floating-point value for <em>%s</em>' % name) else: v=str(v) v=md.getitem('sql_quote__',0)(v) #if find(v,"\'") >= 0: v=join(split(v,"\'"),"''") #v="'%s'" % v vs.append(v)
2,215
def render(self, md): name=self.__name__ t=self.type try: v = md[name] except KeyError, key: if str(key)==name and self.optional: return '' raise KeyError, key, sys.exc_info()[2] if type(v) in (ListType, TupleType): if len(v) > 1 and not self.multiple: raise 'Multiple Values', ( 'multiple values are not allowed for <em>%s</em>' % name) else: v=[v] vs=[] for v in v: if not v and type(v) is StringType and t != 'string': continue if t=='int': try: if type(v) is StringType: atoi(v) else: v=str(int(v)) except: raise ValueError, ( 'Invalid integer value for <em>%s</em>' % name) elif t=='float': if not v and type(v) is StringType: continue try: if type(v) is StringType: atof(v) else: v=str(float(v)) except: raise ValueError, ( 'Invalid floating-point value for <em>%s</em>' % name) else: v=str(v) v=md.getitem('sql_quote__',0)(v) #if find(v,"\'") >= 0: v=join(split(v,"\'"),"''") #v="'%s'" % v vs.append(v)
def render(self, md): name=self.__name__ t=self.type try: v = md[name] except KeyError, key: if str(key)==name and self.optional: return '' raise KeyError, key, sys.exc_info()[2] if type(v) in (ListType, TupleType): if len(v) > 1 and not self.multiple: raise 'Multiple Values', ( 'multiple values are not allowed for <em>%s</em>' % name) else: v=[v] vs=[] for v in v: if not v and type(v) is StringType and t != 'string': continue if t=='int': try: if type(v) is StringType: atoi(v) else: v=str(int(v)) except ValueError: raise ValueError, ( 'Invalid integer value for <em>%s</em>' % name) elif t=='float': if not v and type(v) is StringType: continue try: if type(v) is StringType: atof(v) else: v=str(float(v)) except ValueError: raise ValueError, ( 'Invalid floating-point value for <em>%s</em>' % name) else: v=str(v) v=md.getitem('sql_quote__',0)(v) #if find(v,"\'") >= 0: v=join(split(v,"\'"),"''") #v="'%s'" % v vs.append(v)
2,216
def render(self, md): name=self.__name__ t=self.type try: v = md[name] except KeyError, key: if str(key)==name and self.optional: return '' raise KeyError, key, sys.exc_info()[2] if type(v) in (ListType, TupleType): if len(v) > 1 and not self.multiple: raise 'Multiple Values', ( 'multiple values are not allowed for <em>%s</em>' % name) else: v=[v] vs=[] for v in v: if not v and type(v) is StringType and t != 'string': continue if t=='int': try: if type(v) is StringType: atoi(v) else: v=str(int(v)) except: raise ValueError, ( 'Invalid integer value for <em>%s</em>' % name) elif t=='float': if not v and type(v) is StringType: continue try: if type(v) is StringType: atof(v) else: v=str(float(v)) except: raise ValueError, ( 'Invalid floating-point value for <em>%s</em>' % name) else: v=str(v) v=md.getitem('sql_quote__',0)(v) #if find(v,"\'") >= 0: v=join(split(v,"\'"),"''") #v="'%s'" % v vs.append(v)
defrender(self,md):name=self.__name__t=self.typetry:v=md[name]exceptKeyError,key:ifstr(key)==nameandself.optional:return''raiseKeyError,key,sys.exc_info()[2]iftype(v)in(ListType,TupleType):iflen(v)>1andnotself.multiple:raise'MultipleValues',('multiplevaluesarenotallowedfor<em>%s</em>'%name)else:v=[v]vs=[]forvinv:ifnotvandtype(v)isStringTypeandt!='string':continueift=='int':try:iftype(v)isStringType:atoi(v)else:v=str(int(v))except:raiseValueError,('Invalidintegervaluefor<em>%s</em>'%name)elift=='float':ifnotvandtype(v)isStringType:continuetry:iftype(v)isStringType:atof(v)else:v=str(float(v))except:raiseValueError,('Invalidfloating-pointvaluefor<em>%s</em>'%name)else:v=str(v)v=md.getitem('sql_quote__',0)(v)#iffind(v,"\'")>=0:v=join(split(v,"\'"),"''")#v="'%s'"%vvs.append(v)
2,217
def manage_paste(self, moniker, clip_id, REQUEST=None): """ """
def manage_paste(self, moniker, clip_id, REQUEST=None): """ """
2,218
def _er(self,title,connection_id,arguments,template, SUBMIT,dtpref_cols,dtpref_rows,REQUEST): dr,dc = self._size_changes[SUBMIT] rows=max(1,atoi(dtpref_rows)+dr) cols=max(40,atoi(dtpref_cols)+dc) e='Friday, 31-Dec-99 23:59:59 GMT' resp=REQUEST['RESPONSE'] resp.setCookie('dtpref_rows',str(rows),path='/',expires=e) resp.setCookie('dtpref_cols',str(cols),path='/',expires=e) return self.manage_main( self,REQUEST, title=title, arguments_src=arguments, connection_id=connection_id, template=template, dtpref_cols=cols,dtpref_rows=rows)
def _er(self,title,connection_id,arguments,template, SUBMIT,sql_pref__cols,sql_pref__rows,REQUEST): dr,dc = self._size_changes[SUBMIT] rows=max(1,atoi(dtpref_rows)+dr) cols=max(40,atoi(dtpref_cols)+dc) e='Friday, 31-Dec-99 23:59:59 GMT' resp=REQUEST['RESPONSE'] resp.setCookie('dtpref_rows',str(rows),path='/',expires=e) resp.setCookie('dtpref_cols',str(cols),path='/',expires=e) return self.manage_main( self,REQUEST, title=title, arguments_src=arguments, connection_id=connection_id, template=template, dtpref_cols=cols,dtpref_rows=rows)
2,219
def _er(self,title,connection_id,arguments,template, SUBMIT,dtpref_cols,dtpref_rows,REQUEST): dr,dc = self._size_changes[SUBMIT] rows=max(1,atoi(dtpref_rows)+dr) cols=max(40,atoi(dtpref_cols)+dc) e='Friday, 31-Dec-99 23:59:59 GMT' resp=REQUEST['RESPONSE'] resp.setCookie('dtpref_rows',str(rows),path='/',expires=e) resp.setCookie('dtpref_cols',str(cols),path='/',expires=e) return self.manage_main( self,REQUEST, title=title, arguments_src=arguments, connection_id=connection_id, template=template, dtpref_cols=cols,dtpref_rows=rows)
def _er(self,title,connection_id,arguments,template, SUBMIT,dtpref_cols,dtpref_rows,REQUEST): dr,dc = self._size_changes[SUBMIT] rows=max(1,atoi(sql_pref__rows)+dr) cols=max(40,atoi(sql_pref__cols)+dc) e='Friday, 31-Dec-99 23:59:59 GMT' resp=REQUEST['RESPONSE'] resp.setCookie('dtpref_rows',str(rows),path='/',expires=e) resp.setCookie('dtpref_cols',str(cols),path='/',expires=e) return self.manage_main( self,REQUEST, title=title, arguments_src=arguments, connection_id=connection_id, template=template, dtpref_cols=cols,dtpref_rows=rows)
2,220
def _er(self,title,connection_id,arguments,template, SUBMIT,dtpref_cols,dtpref_rows,REQUEST): dr,dc = self._size_changes[SUBMIT] rows=max(1,atoi(dtpref_rows)+dr) cols=max(40,atoi(dtpref_cols)+dc) e='Friday, 31-Dec-99 23:59:59 GMT' resp=REQUEST['RESPONSE'] resp.setCookie('dtpref_rows',str(rows),path='/',expires=e) resp.setCookie('dtpref_cols',str(cols),path='/',expires=e) return self.manage_main( self,REQUEST, title=title, arguments_src=arguments, connection_id=connection_id, template=template, dtpref_cols=cols,dtpref_rows=rows)
def _er(self,title,connection_id,arguments,template, SUBMIT,dtpref_cols,dtpref_rows,REQUEST): dr,dc = self._size_changes[SUBMIT] rows=max(1,atoi(dtpref_rows)+dr) cols=max(40,atoi(dtpref_cols)+dc) e='Friday, 31-Dec-99 23:59:59 GMT' resp=REQUEST['RESPONSE'] resp.setCookie('sql_pref__rows',str(rows),path='/',expires=e) resp.setCookie('sql_pref__cols',str(cols),path='/',expires=e) return self.manage_main( self,REQUEST, title=title, arguments_src=arguments, connection_id=connection_id, template=template, dtpref_cols=cols,dtpref_rows=rows)
2,221
def _er(self,title,connection_id,arguments,template, SUBMIT,dtpref_cols,dtpref_rows,REQUEST): dr,dc = self._size_changes[SUBMIT] rows=max(1,atoi(dtpref_rows)+dr) cols=max(40,atoi(dtpref_cols)+dc) e='Friday, 31-Dec-99 23:59:59 GMT' resp=REQUEST['RESPONSE'] resp.setCookie('dtpref_rows',str(rows),path='/',expires=e) resp.setCookie('dtpref_cols',str(cols),path='/',expires=e) return self.manage_main( self,REQUEST, title=title, arguments_src=arguments, connection_id=connection_id, template=template, dtpref_cols=cols,dtpref_rows=rows)
def _er(self,title,connection_id,arguments,template, SUBMIT,dtpref_cols,dtpref_rows,REQUEST): dr,dc = self._size_changes[SUBMIT] rows=max(1,atoi(dtpref_rows)+dr) cols=max(40,atoi(dtpref_cols)+dc) e='Friday, 31-Dec-99 23:59:59 GMT' resp=REQUEST['RESPONSE'] resp.setCookie('dtpref_rows',str(rows),path='/',expires=e) resp.setCookie('dtpref_cols',str(cols),path='/',expires=e) return self.manage_main( self,REQUEST, title=title, arguments_src=arguments, connection_id=connection_id, template=template, dtpref_cols=cols,dtpref_rows=rows)
2,222
def manage_edit(self,title,connection_id,arguments,template, SUBMIT='Change',dtpref_cols='50', dtpref_rows='20', REQUEST=None):
def manage_edit(self,title,connection_id,arguments,template, SUBMIT='Change',sql_pref__cols='50', sql_pref__rows='20', REQUEST=None):
2,223
def manage_edit(self,title,connection_id,arguments,template, SUBMIT='Change',dtpref_cols='50', dtpref_rows='20', REQUEST=None):
def manage_edit(self,title,connection_id,arguments,template, SUBMIT='Change',dtpref_cols='50', dtpref_rows='20', REQUEST=None):
2,224
def manage_catalogObject(self, REQUEST, urls=None, blah=None): """ index all Zope objects that 'urls' point to """ if urls: for url in urls: try: # if an error happens here, the catalog will be in # an unstable state. If this happens, ignore the # object. obj = self.resolve_url(url, REQUEST) except: continue self.catalog_object(obj, url)
def manage_catalogObject(self, REQUEST, urls=None, blah=None): """ index all Zope objects that 'urls' point to """ if urls: for url in urls: try: # if an error happens here, the catalog will be in # an unstable state. If this happens, ignore the # object. obj = REQUEST.resolve_url(url, REQUEST) except: continue self.catalog_object(obj, url)
2,225
def manage_uncatalogObject(self, REQUEST, urls=None): """ removes Zope object 'urls' from catalog """
def manage_uncatalogObject(self, REQUEST, urls=None): """ removes Zope object 'urls' from catalog """
2,226
def manage_catalogReindex(self, REQUEST): """ iterate over the whole catalog, deleting inexistent references and refreshing objects""" items = tuple(self._catalog.uids.items())
def manage_catalogReindex(self, REQUEST): """ iterate over the whole catalog, deleting inexistent references and refreshing objects""" items = tuple(self._catalog.uids.items())
2,227
def manage_catalogReindex(self, REQUEST): """ iterate over the whole catalog, deleting inexistent references and refreshing objects""" items = tuple(self._catalog.uids.items())
def manage_catalogReindex(self, REQUEST): """ iterate over the whole catalog, deleting inexistent references and refreshing objects""" items = tuple(self._catalog.uids.items())
2,228
def manage_catalogReindex(self, REQUEST): """ iterate over the whole catalog, deleting inexistent references and refreshing objects""" items = tuple(self._catalog.uids.items())
def manage_catalogReindex(self, REQUEST): """ iterate over the whole catalog, deleting inexistent references and refreshing objects""" items = tuple(self._catalog.uids.items())
2,229
def manage_catalogFoundItems(self, REQUEST, obj_metatypes=None, obj_ids=None, obj_searchterm=None, obj_expr=None, obj_mtime=None, obj_mspec=None, obj_roles=None, obj_permission=None): """ Find object according to search criteria and Catalog them """ results = self.ZopeFind(REQUEST.PARENTS[1], obj_metatypes=obj_metatypes, obj_ids=obj_ids, obj_searchterm=obj_searchterm, obj_expr=obj_expr, obj_mtime=obj_mtime, obj_mspec=obj_mspec, obj_permission=obj_permission, obj_roles=obj_roles, search_sub=1, REQUEST=REQUEST)
def manage_catalogFoundItems(self, REQUEST, obj_metatypes=None, obj_ids=None, obj_searchterm=None, obj_expr=None, obj_mtime=None, obj_mspec=None, obj_roles=None, obj_permission=None): """ Find object according to search criteria and Catalog them """ results = self.ZopeFind(REQUEST.PARENTS[1], obj_metatypes=obj_metatypes, obj_ids=obj_ids, obj_searchterm=obj_searchterm, obj_expr=obj_expr, obj_mtime=obj_mtime, obj_mspec=obj_mspec, obj_permission=obj_permission, obj_roles=obj_roles, search_sub=1, REQUEST=REQUEST)
2,230
def getobject(self, rid, REQUEST=None): """ Return a cataloged object given a 'data_record_id_' """ if REQUEST is None: REQUEST=self.REQUEST url='%s/%s' %(REQUEST.script, self.getpath(rid)) return REQUEST.clone().resolve_url(url)
def getobject(self, rid, REQUEST=None): """ Return a cataloged object given a 'data_record_id_' """ if REQUEST is None: REQUEST=self.REQUEST url='%s/%s' %(REQUEST.script, self.getpath(rid)) return REQUEST.clone().resolve_url(url)
2,231
def resolve_url(self, path, REQUEST): # Attempt to resolve a url into an object in the Zope # namespace. The url must be a fully-qualified url. The # method will return the requested object if it is found # or raise the same HTTP error that would be raised in # the case of a real web request. If the passed in url # does not appear to describe an object in the system # namespace (e.g. the host, port or script name dont # match that of the current request), a ValueError will # be raised.
def resolve_url(self, path, REQUEST): # Attempt to resolve a url into an object in the Zope # namespace. The url must be a fully-qualified url. The # method will return the requested object if it is found # or raise the same HTTP error that would be raised in # the case of a real web request. If the passed in url # does not appear to describe an object in the system # namespace (e.g. the host, port or script name dont # match that of the current request), a ValueError will # be raised.
2,232
def logmsg(self, event): # log a service event using servicemanager.LogMsg from servicemanager import LogMsg LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, event, (self._svc_name_, " (%s)" % self._svc_display_name_))
def logmsg(self, event): # log a service event using servicemanager.LogMsg from servicemanager import LogMsg, EVENTLOG_INFORMATION_TYPE LogMsg(EVENTLOG_INFORMATION_TYPE, event, (self._svc_name_, " (%s)" % self._svc_display_name_))
2,233
def main(): import getopt from string import split user=None try: optlist, args = getopt.getopt(sys.argv[1:],'u:') url=args[0] u =filter(lambda o: o[0]=='-u', optlist) if u: [user, pw] = split(u[0][1],':') kw={} for arg in args[1:]: [name,v]=split(arg) kw[name]=v except: print """ Usage: %s [-u username:password] url [name=value ...] where url is the web resource to call. The -u option may be used to provide a user name and password. Optional arguments may be provides as name=value pairs. """ sys.exit(1) # The "main" program for this module f=BoboFunction(url) if user: f.username, f.password = user, pw print apply(f,(),kw)
def main(): import getopt from string import split user=None try: optlist, args = getopt.getopt(sys.argv[1:],'u:') url=args[0] u =filter(lambda o: o[0]=='-u', optlist) if u: [user, pw] = split(u[0][1],':') kw={} for arg in args[1:]: [name,v]=split(arg) kw[name]=v except: print """ % sys.argv[0] Usage: %s [-u username:password] url [name=value ...] where url is the web resource to call. The -u option may be used to provide a user name and password. Optional arguments may be provides as name=value pairs. """ % sys.argv[0] sys.exit(1) # The "main" program for this module f=BoboFunction(url) if user: f.username, f.password = user, pw print apply(f,(),kw)
2,234
def orify(seq, query_map={ type(regex.compile('')): Query.Regex, type(''): Query.String, }): subqueries=[] for q in seq: try: q=query_map[type(q)](q) except: q=Query.Cmp(q) subqueries.append(q) return apply(Query.Or,tuple(subqueries))
def orify(seq, query_map={ type(regex.compile('')): Query.Regex, type(''): Query.String, }): subqueries=[] for q in seq: try: q=query_map[type(q)](q) except: q=Query.Cmp(q) subqueries.append(q) return apply(Query.Or,tuple(subqueries))
2,235
def __init__(self, brains=None):
def __init__(self, brains=None):
2,236
def __init__(self, brains=None):
def __init__(self, brains=None):
2,237
def uncatalogObject(self, uid): """ Uncatalog and object from the Catalog. and 'uid' is a unique Catalog identifier
def uncatalogObject(self, uid): """ Uncatalog and object from the Catalog. and 'uid' is a unique Catalog identifier
2,238
def _indexedSearch(self, args, sort_index, append, used, IIBType=type(IIBucket()), intSType=type(intSet())): """ Iterate through the indexes, applying the query to each one. Do some magic to join result sets. Be intelligent about handling intSets and IIBuckets. """
def _indexedSearch(self, args, sort_index, append, used, IIBType=type(IIBucket()), intSType=type(intSet())): """ Iterate through the indexes, applying the query to each one. Do some magic to join result sets. Be intelligent about handling intSets and IIBuckets. """
2,239
def __init__(self,id,title=None): self.id=id self.title=title self._ztable=ZTablesCore.ZTable(id)
def __init__(self,id,title=None): self.id=id self.title=title self._ztable=ZTablesCore.ZTable(id)
2,240
def __init__(self,id,title=None): self.id=id self.title=title self._ztable=ZTablesCore.ZTable(id)
def __init__(self,id,title=None): self.id=id self.title=title self._ztable=ZTablesCore.ZTable(id)
2,241
def register_loop_callback(callback, args=(), kw=None): _loop_lock.acquire() try: if _looping: apply(callback, (map,)+args, kw or {}) else: _loop_callbacks.append((callback, args, kw)) finally: _loop_lock.release()
def register_loop_callback(callback, args=(), kw=None): _loop_lock.acquire() try: if _looping is not None: apply(callback, (_looping,) + args, kw or {}) else: _loop_callbacks.append((callback, args, kw)) finally: _loop_lock.release()
2,242
def _start_loop(map): _loop_lock.acquire() try: global _looping _looping=1 while _loop_callbacks: cb, args, kw = _loop_callbacks.pop() apply(cb, (map,)+args, kw or {}) finally: _loop_lock.release()
def _start_loop(map): _loop_lock.acquire() try: global _looping _looping = map while _loop_callbacks: cb, args, kw = _loop_callbacks.pop() apply(cb, (map,)+args, kw or {}) finally: _loop_lock.release()
2,243
def _start_loop(map): _loop_lock.acquire() try: global _looping _looping=1 while _loop_callbacks: cb, args, kw = _loop_callbacks.pop() apply(cb, (map,)+args, kw or {}) finally: _loop_lock.release()
def _start_loop(map): _loop_lock.acquire() try: global _looping _looping=1 while _loop_callbacks: cb, args, kw = _loop_callbacks.pop() apply(cb, (map,) + args, kw or {}) finally: _loop_lock.release()
2,244
def _stop_loop(): _loop_lock.acquire() try: global _looping _looping=0 finally: _loop_lock.release()
def _stop_loop(): _loop_lock.acquire() try: global _looping _looping = None finally: _loop_lock.release()
2,245
def loop (timeout=30.0, use_poll=0, map=None): if use_poll: poll_fun = asyncore.poll2 else: poll_fun = asyncore.poll if map is None: map=asyncore.socket_map _start_loop(map) while map: poll_fun (timeout, map) _stop_loop()
def loop (timeout=30.0, use_poll=0, map=None): This function functions like the regular asyncore.loop() function except that it also triggers ThreadedAsync callback functions before starting the loop. """ if use_poll: if hasattr(select, 'poll'): poll_fun = asyncore.poll3 else: poll_fun = asyncore.poll2 else: poll_fun = asyncore.poll if map is None: map=asyncore.socket_map _start_loop(map) while map: poll_fun (timeout, map) _stop_loop()
2,246
def loop (timeout=30.0, use_poll=0, map=None): if use_poll: poll_fun = asyncore.poll2 else: poll_fun = asyncore.poll if map is None: map=asyncore.socket_map _start_loop(map) while map: poll_fun (timeout, map) _stop_loop()
def loop (timeout=30.0, use_poll=0, map=None): if use_poll: poll_fun = asyncore.poll2 else: poll_fun = asyncore.poll if map is None: map = asyncore.socket_map _start_loop(map) while map: poll_fun (timeout, map) _stop_loop()
2,247
def loop (timeout=30.0, use_poll=0, map=None): if use_poll: poll_fun = asyncore.poll2 else: poll_fun = asyncore.poll if map is None: map=asyncore.socket_map _start_loop(map) while map: poll_fun (timeout, map) _stop_loop()
def loop (timeout=30.0, use_poll=0, map=None): if use_poll: poll_fun = asyncore.poll2 else: poll_fun = asyncore.poll if map is None: map=asyncore.socket_map _start_loop(map) while map: poll_fun(timeout, map) _stop_loop()
2,248
def exception(self, fatal=0, info=None, absuri_match=re.compile(r'\w+://[\w\.]+').match, tag_search=re.compile('[a-zA-Z]>').search, abort=1 ): if type(info) is type(()) and len(info)==3: t, v, tb = info else: t, v, tb = sys.exc_info()
def exception(self, fatal=0, info=None, absuri_match=re.compile(r'\w+://[\w\.]+').match, tag_search=re.compile('[a-zA-Z]>').search, abort=1 ): if type(info) is type(()) and len(info)==3: t, v, tb = info else: t, v, tb = sys.exc_info()
2,249
def setUp(self): self.open() StorageTestBase.StorageTestBase.setUp(self)
def setUp(self): self.open() StorageTestBase.StorageTestBase.setUp(self)
2,250
def validate(self, accessed, container, name, value, context, roles=_noroles, getattr=getattr, _noroles=_noroles, valid_aq_=('aq_parent','aq_inner', 'aq_explicit')):
def validate(self, accessed, container, name, value, context, roles=_noroles, getattr=getattr, _noroles=_noroles, valid_aq_=('aq_parent','aq_inner', 'aq_explicit')):
2,251
def validate(self, accessed, container, name, value, context, roles=_noroles, getattr=getattr, _noroles=_noroles, valid_aq_=('aq_parent','aq_inner', 'aq_explicit')):
def validate(self, accessed, container, name, value, context, roles=_noroles, getattr=getattr, _noroles=_noroles, valid_aq_=('aq_parent','aq_inner', 'aq_explicit')):
2,252
def validate(self, accessed, container, name, value, context, roles=_noroles, getattr=getattr, _noroles=_noroles, valid_aq_=('aq_parent','aq_inner', 'aq_explicit')):
def validate(self, accessed, container, name, value, context, roles=_noroles, getattr=getattr, _noroles=_noroles, valid_aq_=('aq_parent','aq_inner', 'aq_explicit')):
2,253
def validate(self, accessed, container, name, value, context, roles=_noroles, getattr=getattr, _noroles=_noroles, valid_aq_=('aq_parent','aq_inner', 'aq_explicit')):
def validate(self, accessed, container, name, value, context, roles=_noroles, getattr=getattr, _noroles=_noroles, valid_aq_=('aq_parent','aq_inner', 'aq_explicit')):
2,254
def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: match = self.interesting.search(rawdata, i) # < or & if match: j = match.start() self.interesting = interesting_normal else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): # < + letter k = self.parse_starttag(i) elif endtagopen.match(rawdata, i): # </ k = self.parse_endtag(i) elif commentopen.match(rawdata, i): # <!-- k = self.parse_comment(i) elif piopen.match(rawdata, i): # <? k = self.parse_pi(i) elif declopen.match(rawdata, i): # <! k = self.parse_declaration(i) else: if i < n-1: raise HTMLParseError( "invalid '<' construct: %s" % `rawdata[i:i+2]`, self.getpos()) k = -1 if k < 0: if end: raise HTMLParseError("EOF in middle of construct", self.getpos()) break i = self.updatepos(i, k) elif rawdata[i] == '&': match = charref.match(rawdata, i) if match: name = match.group(1) self.handle_charref(name) k = match.end() if rawdata[k-1] != ';': k = k-1 i = self.updatepos(i, k) continue match = entityref.match(rawdata, i) if match: name = match.group(1) self.handle_entityref(name) k = match.end() if rawdata[k-1] != ';': k = k-1 i = self.updatepos(i, k) continue if incomplete.match(rawdata, i): if end: raise HTMLParseError( "EOF in middle of entity or char ref", self.getpos()) return -1 # incomplete raise HTMLParseError("'&' not part of entity or char ref", self.getpos()) else: assert 0, "interesting.search() lied" # end while if end and i < n: self.handle_data(rawdata[i:n]) i = self.updatepos(i, n) self.rawdata = rawdata[i:]
def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: match = self.interesting.search(rawdata, i) # < or & if match: j = match.start() else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): # < + letter k = self.parse_starttag(i) elif endtagopen.match(rawdata, i): # </ k = self.parse_endtag(i) elif commentopen.match(rawdata, i): # <!-- k = self.parse_comment(i) elif piopen.match(rawdata, i): # <? k = self.parse_pi(i) elif declopen.match(rawdata, i): # <! k = self.parse_declaration(i) else: if i < n-1: raise HTMLParseError( "invalid '<' construct: %s" % `rawdata[i:i+2]`, self.getpos()) k = -1 if k < 0: if end: raise HTMLParseError("EOF in middle of construct", self.getpos()) break i = self.updatepos(i, k) elif rawdata[i] == '&': match = charref.match(rawdata, i) if match: name = match.group(1) self.handle_charref(name) k = match.end() if rawdata[k-1] != ';': k = k-1 i = self.updatepos(i, k) continue match = entityref.match(rawdata, i) if match: name = match.group(1) self.handle_entityref(name) k = match.end() if rawdata[k-1] != ';': k = k-1 i = self.updatepos(i, k) continue if incomplete.match(rawdata, i): if end: raise HTMLParseError( "EOF in middle of entity or char ref", self.getpos()) return -1 # incomplete raise HTMLParseError("'&' not part of entity or char ref", self.getpos()) else: assert 0, "interesting.search() lied" # end while if end and i < n: self.handle_data(rawdata[i:n]) i = self.updatepos(i, n) self.rawdata = rawdata[i:]
2,255
def index(self, src, srckey): '''\ index(src, srckey)
def index(self, src, srckey): '''\ index(src, srckey)
2,256
def raise_standardErrorMessage( self, client=None, REQUEST={}, error_type=None, error_value=None, tb=None, error_tb=None, error_message='', tagSearch=regex.compile('[a-zA-Z]>').search):
def raise_standardErrorMessage( self, client=None, REQUEST={}, error_type=None, error_value=None, tb=None, error_tb=None, error_message='', tagSearch=regex.compile('[a-zA-Z]>').search):
2,257
def raise_standardErrorMessage( self, client=None, REQUEST={}, error_type=None, error_value=None, tb=None, error_tb=None, error_message='', tagSearch=regex.compile('[a-zA-Z]>').search):
def raise_standardErrorMessage( self, client=None, REQUEST={}, error_type=None, error_value=None, tb=None, error_tb=None, error_message='', tagSearch=regex.compile('[a-zA-Z]>').search):
2,258
def _setId(self, id): if id != self.id: raise Globals.MessageDialog( title='Invalid Id', message='Cannot change the id of a %s' % self.meta_type, action ='./manage_main',)
def _setId(self, id): if id != self.id: raise MessageDialog( title='Invalid Id', message='Cannot change the id of a %s' % self.meta_type, action ='./manage_main',)
2,259
def rolejoin(roles, other): dict={} for role in roles: dict[role]=1 for role in other: dict[role]=1 roles=dict.keys() roles.sort() return roles
def rolejoin(roles, other): dict={} for role in roles: dict[role]=1 for role in other: dict[role]=1 roles=dict.keys() roles.sort() return roles
2,260
def marshal_tuple(n,l): return join(map(lambda v, n=n: "%s:tuple=%s" % (n,quote(v)),l),'&')
def marshal_tuple(n,l): return join(map(lambda v, n=n: "%s:tuple=%s" % (n,quote(v)),l),'&')
2,261
def __init__(self,*args): """Return a new date-time object
def __init__(self,*args): """Return a new date-time object
2,262
def testConstructor3(self): '''Constructor from date/time string''' dt = DateTime() dt1 = DateTime('%d/%d/%d %d:%d:%f %s' % ( dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute(), dt.second(), dt.timezone())) assert dt.debugCompare(dt1), (dt, dt1)
def testConstructor3(self): '''Constructor from date/time string''' dt = DateTime() dt1s = '%d/%d/%d %d:%d:%f %s' % ( dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute(), dt.second(), dt.timezone())) assert dt.debugCompare(dt1), (dt, dt1)
2,263
def testConstructor3(self): '''Constructor from date/time string''' dt = DateTime() dt1 = DateTime('%d/%d/%d %d:%d:%f %s' % ( dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute(), dt.second(), dt.timezone())) assert dt.debugCompare(dt1), (dt, dt1)
def testConstructor3(self): '''Constructor from date/time string''' dt = DateTime() dt1 = DateTime('%d/%d/%d %d:%d:%f %s' % ( dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute(), dt.second(), dt.timezone())) assert dt.debugCompare(dt1), (dt, dt1)
2,264
def testConstructor6(self): '''Constructor from year and julian date''' dt = DateTime('1980/1/5 12:00:00.050 pm') dt1 = DateTime(1980, 5.500000578705) assert dt.debugCompare(dt1), (dt, dt1)
def testConstructor6(self): '''Constructor from year and julian date''' dt = DateTime('1980/1/5 12:00:00.050 pm') dt1 = DateTime(1980, 5.500000578705) assert dt.debugCompare(dt1), (dt, dt1)
2,265
def testY10KDate(self): '''Comparison of a Y10K date and a Y2K date''' dt = DateTime('10213/09/21') dt1 = DateTime(2000, 1, 1) assert dt - dt1 == 3000000.0, (dt, dt1)
def testY10KDate(self): '''Comparison of a Y10K date and a Y2K date''' dt = DateTime('10213/09/21') dt1 = DateTime(2000, 1, 1) assert dt - dt1 == 3000000.0, (dt, dt1)
2,266
def _isNotBeingUsedAsAMethod(self): return not aq_get(self, '_isBeingUsedAsAMethod_', 0)
def _isNotBeingUsedAsAMethod(self): return not aq_get(self, '_isBeingUsedAsAMethod_', 0)
2,267
def manage_getPermissionMapping(self): """Return the permission mapping for the object
def manage_getPermissionMapping(self): """Return the permission mapping for the object
2,268
def manage_setPermissionMapping(self, permission_names=[], class_permissions=[], REQUEST=None): """Change the permission mapping """ wrapper=getattr(self, '_permissionMapper', None) if wrapper is None: wrapper=PM()
def manage_setPermissionMapping(self, permission_names=[], class_permissions=[], REQUEST=None): """Change the permission mapping """ wrapper=getattr(self, '_permissionMapper', None) if wrapper is None: wrapper=PM()
2,269
def _isBeingAccessedAsZClassDefinedInstanceMethod(self): p=getattr(self,'aq_parent',None) if p is None: return 0 # Not wrapped base=getattr(p, 'aq_base', None) return type(base) is PermissionMapper
def_isBeingAccessedAsZClassDefinedInstanceMethod(self):p=getattr(self,'aq_parent',None)ifpisNone:return0#Notwrappedbase=getattr(p,'aq_base',None)returntype(base)isPermissionMapper
2,270
def registerClass(self, instance_class=None, meta_type='', permission=None, constructors=(), icon=None, permissions=None, legacy=(), ): """Register a constructor
def registerClass(self, instance_class=None, meta_type='', permission=None, constructors=(), icon=None, permissions=None, legacy=(), ): """Register a constructor
2,271
def close(self): if self._root_connection is not None: raise RuntimeError("Should not close mounted connections directly") conns = self._mounted_connections if conns: for conn in conns.values(): # Notify the activity monitor db = conn.db() f = getattr(db, 'getActivityMonitor', None) if f is not None: am = f() if am is not None: am.closedConnection(conn) conn._incrgc() # This is a good time to do some GC # XXX maybe we ought to call the close callbacks. conn._storage = conn._tmp = conn.new_oid = conn._opened = None conn._debug_info = () # The mounted connection keeps a reference to # its database, but nothing else. # Note that mounted connections can not operate # independently, so don't use _closeConnection() to # return them to the pool. Only the root connection # should be returned. # Close this connection only after the mounted connections # have been closed. Otherwise, this connection gets returned # to the pool too early and another thread might use this # connection before the mounted connections have all been # closed. self._real_close()
def close(self): if self._root_connection is not None: raise RuntimeError("Should not close mounted connections directly") conns = self._mounted_connections if conns: for conn in conns.values(): # Notify the activity monitor db = conn.db() f = getattr(db, 'getActivityMonitor', None) if f is not None: am = f() if am is not None: am.closedConnection(conn) conn._incrgc() # This is a good time to do some GC # XXX maybe we ought to call the close callbacks. conn._storage = conn._tmp = conn.new_oid = conn._opened = None conn._debug_info = () # The mounted connection keeps a reference to # its database, but nothing else. # Note that mounted connections can not operate # independently, so don't use _closeConnection() to # return them to the pool. Only the root connection # should be returned. # Close this connection only after the mounted connections # have been closed. Otherwise, this connection gets returned # to the pool too early and another thread might use this # connection before the mounted connections have all been # closed. self._real_close()
2,272
def __init__(self, stdin, environ, response, clean=0): # Avoid the overhead of scrubbing the environment in the # case of request cloning for traversal purposes. If the # clean flag is set, we know we can use the passed in # environ dict directly. if not clean: environ=sane_environment(environ) if environ.get('REQUEST_METHOD','GET') != 'GET': fp=stdin else: fp=None
def__init__(self,stdin,environ,response,clean=0):#Avoidtheoverheadofscrubbingtheenvironmentinthe#caseofrequestcloningfortraversalpurposes.Ifthe#cleanflagisset,weknowwecanusethepassedin#environdictdirectly.ifnotclean:environ=sane_environment(environ)ifenviron.get('REQUEST_METHOD','GET')!='GET':fp=stdinelse:fp=None
2,273
def __init__(self,*args): """Return a new date-time object
def __init__(self,*args): """Return a new date-time object
2,274
def include(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """Include a reST file as part of the content of this reST file.""" import pdb pdb.set_trace() print '1' if not state.document.settings.file_insertion_enabled: warning = state_machine.reporter.warning( '"%s" directive disabled.' % name, nodes.literal_block(block_text, block_text), line=lineno) return [warning] source = state_machine.input_lines.source( lineno - state_machine.input_offset - 1) source_dir = os.path.dirname(os.path.abspath(source)) path = directives.path(arguments[0]) path = os.path.normpath(os.path.join(source_dir, path)) path = utils.relative_path(None, path) encoding = options.get('encoding', state.document.settings.input_encoding) try: state.document.settings.record_dependencies.add(path) include_file = io.FileInput( source_path=path, encoding=encoding, error_handler=state.document.settings.input_encoding_error_handler, handle_io_errors=None) except IOError, error: severe = state_machine.reporter.severe( 'Problems with "%s" directive path:\n%s: %s.' % (name, error.__class__.__name__, error), nodes.literal_block(block_text, block_text), line=lineno) return [severe] try: include_text = include_file.read() except UnicodeError, error: severe = state_machine.reporter.severe( 'Problem with "%s" directive:\n%s: %s' % (name, error.__class__.__name__, error), nodes.literal_block(block_text, block_text), line=lineno) return [severe] if options.has_key('literal'): literal_block = nodes.literal_block(include_text, include_text, source=path) literal_block.line = 1 return literal_block else: include_lines = statemachine.string2lines(include_text, convert_whitespace=1) state_machine.insert_input(include_lines, path) return []
def include(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """Include a reST file as part of the content of this reST file.""" if not state.document.settings.file_insertion_enabled: warning = state_machine.reporter.warning( '"%s" directive disabled.' % name, nodes.literal_block(block_text, block_text), line=lineno) return [warning] source = state_machine.input_lines.source( lineno - state_machine.input_offset - 1) source_dir = os.path.dirname(os.path.abspath(source)) path = directives.path(arguments[0]) path = os.path.normpath(os.path.join(source_dir, path)) path = utils.relative_path(None, path) encoding = options.get('encoding', state.document.settings.input_encoding) try: state.document.settings.record_dependencies.add(path) include_file = io.FileInput( source_path=path, encoding=encoding, error_handler=state.document.settings.input_encoding_error_handler, handle_io_errors=None) except IOError, error: severe = state_machine.reporter.severe( 'Problems with "%s" directive path:\n%s: %s.' % (name, error.__class__.__name__, error), nodes.literal_block(block_text, block_text), line=lineno) return [severe] try: include_text = include_file.read() except UnicodeError, error: severe = state_machine.reporter.severe( 'Problem with "%s" directive:\n%s: %s' % (name, error.__class__.__name__, error), nodes.literal_block(block_text, block_text), line=lineno) return [severe] if options.has_key('literal'): literal_block = nodes.literal_block(include_text, include_text, source=path) literal_block.line = 1 return literal_block else: include_lines = statemachine.string2lines(include_text, convert_whitespace=1) state_machine.insert_input(include_lines, path) return []
2,275
def PROPFIND(self, REQUEST, RESPONSE): """Retrieve properties defined on the resource.""" self.dav__init(REQUEST, RESPONSE) cmd=davcmds.PropFind(REQUEST) result=cmd.apply(self) RESPONSE.setStatus(207) RESPONSE.setHeader('Content-Type', 'text/xml; charset="utf-8"') RESPONSE.setBody(result) return RESPONSE # work around MSIE DAV bug for creation and modified date if (REQUEST.get_header('User-Agent') == 'Microsoft Data Access Internet Publishing Provider DAV 1.1'): result = result.replace('<n:getlastmodified xmlns:n="DAV:">', '<n:getlastmodified xmlns:n="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.rfc1123">') result = result.replace('<n:creationdate xmlns:n="DAV:">', '<n:creationdate xmlns:n="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.tz">')
def PROPFIND(self, REQUEST, RESPONSE): """Retrieve properties defined on the resource.""" self.dav__init(REQUEST, RESPONSE) cmd=davcmds.PropFind(REQUEST) result=cmd.apply(self) # work around MSIE DAV bug for creation and modified date if (REQUEST.get_header('User-Agent') == 'Microsoft Data Access Internet Publishing Provider DAV 1.1'): result = result.replace('<n:getlastmodified xmlns:n="DAV:">', '<n:getlastmodified xmlns:n="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.rfc1123">') result = result.replace('<n:creationdate xmlns:n="DAV:">', '<n:creationdate xmlns:n="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.tz">')
2,276
def _doChangeUser(self, name, password, roles, domains, **kw): user=self.data[name] if password is not None: if self.encrypt_passwords and not self._isPasswordEncrypted(pw): password = self._encryptPassword(password) user.__=password user.roles=roles user.domains=domains
def _doChangeUser(self, name, password, roles, domains, **kw): user=self.data[name] if password is not None: if self.encrypt_passwords and not self._isPasswordEncrypted(password): password = self._encryptPassword(password) user.__=password user.roles=roles user.domains=domains
2,277
def get_catalog(self): return self.catalog
def get_catalog(self): return self.catalog
2,278
def setUp(self): self.index=SearchIndex.UnTextIndex.UnTextIndex('text') self.doc=Dummy(text='this is the time, when all good zopes') catch_log_errors()
def setUp(self): self.index=SearchIndex.UnTextIndex.UnTextIndex('text') self.doc=Dummy(text='this is the time, when all good zopes') catch_log_errors()
2,279
def tearDown(self): ignore_log_errors() get_transaction().abort() if hasattr(self, 'jar'): self.dbclose() cleanDB() self.__dict__.clear()
def tearDown(self): get_transaction().abort() if hasattr(self, 'jar'): self.dbclose() cleanDB() self.__dict__.clear()
2,280
def __call__(self, REQUEST=None, __ick__=None, src__=0, test__=0, **kw): """Call the database method
def __call__(self, REQUEST=None, __ick__=None, src__=0, test__=0, **kw): """Call the database method
2,281
def _docommit(self, txn, tid): self._pending.put(self._serial, COMMIT, txn) deltas = {} co = cs = None try: co = self._oids.cursor(txn=txn) cs = self._serials.cursor(txn=txn) rec = co.first() while rec: oid = rec[0] rec = co.next() # Remove from the serials table all entries with key oid where # the serial is not tid. These are the old revisions of the # object. At the same time, we want to collect the oids of # the objects referred to by this revision's pickle, so that # later we can decref those reference counts. srec = cs.set(oid) while srec: soid, stid = srec if soid <> oid: break if stid == tid: # This is the current revision of the object, so # increment the refcounts of all referents data = self._pickles.get(oid+stid, txn=txn) assert data is not None self._update(deltas, data, 1) else: # This is the previous revision of the object, so # decref its referents and clean up its pickles. cs.delete() data = self._pickles.get(oid+stid, txn=txn) assert data is not None self._update(deltas, data, -1) self._pickles.delete(oid+stid, txn=txn) srec = cs.next_dup() # Now add incref deltas for all objects referenced by the new # revision of this object. data = self._pickles.get(oid+tid, txn=txn) assert data is not None self._update(deltas, data, 1) finally: # There's a small window of opportunity for leaking a cursor here, # if co.close() were to fail. In practice this shouldn't happen. if co: co.close() if cs: cs.close() # We're done with this table self._pending.truncate(txn) # If we're in the middle of a pack, we need to add to the packmark # table any objects that were modified in this transaction. # Otherwise, there's a race condition where mark might have happened, # then the object is added, then sweep runs, deleting the object # created in the interrim. if self._packing: for oid in self._oids.keys(): self._packmark.put(oid, PRESENT, txn=txn) self._oids.truncate(txn) # Now, to finish up, we need apply the refcount deltas to the # refcounts table, and do recursive collection of all refcount == 0 # objects. while deltas: deltas = self._update_refcounts(deltas, txn)
def _docommit(self, txn, tid): self._pending.put(self._serial, COMMIT, txn) deltas = {} co = cs = None try: co = self._oids.cursor(txn=txn) cs = self._serials.cursor(txn=txn) rec = co.first() while rec: oid = rec[0] rec = co.next() # Remove from the serials table all entries with key oid where # the serial is not tid. These are the old revisions of the # object. At the same time, we want to collect the oids of # the objects referred to by this revision's pickle, so that # later we can decref those reference counts. srec = cs.set(oid) while srec: soid, stid = srec if soid <> oid: break if stid == tid: # This is the current revision of the object, so # increment the refcounts of all referents data = self._pickles.get(oid+stid, txn=txn) assert data is not None self._update(deltas, data, 1) else: # This is the previous revision of the object, so # decref its referents and clean up its pickles. cs.delete() data = self._pickles.get(oid+stid, txn=txn) assert data is not None self._update(deltas, data, -1) self._pickles.delete(oid+stid, txn=txn) srec = cs.next_dup() # Now add incref deltas for all objects referenced by the new # revision of this object. data = self._pickles.get(oid+tid, txn=txn) assert data is not None self._update(deltas, data, 1) finally: # There's a small window of opportunity for leaking a cursor here, # if co.close() were to fail. In practice this shouldn't happen. if co: co.close() if cs: cs.close() # We're done with this table self._pending.truncate(txn) # If we're in the middle of a pack, we need to add to the packmark # table any objects that were modified in this transaction. # Otherwise, there's a race condition where mark might have happened, # then the object is added, then sweep runs, deleting the object # created in the interrim. if self._packing: for oid in self._oids.keys(): self._packmark.put(oid, PRESENT, txn=txn) self._oids.truncate(txn) # Now, to finish up, we need apply the refcount deltas to the # refcounts table, and do recursive collection of all refcount == 0 # objects. while deltas: deltas = self._update_refcounts(deltas, txn)
2,282
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=regex.compile('\(:[a-zA-Z][a-zA-Z0-9_]+\|\.[xy]\)$').search, rfind=string.rfind, ): """Process request inputs
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, rfind=string.rfind, ): """Process request inputs
2,283
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=regex.compile('\(:[a-zA-Z][a-zA-Z0-9_]+\|\.[xy]\)$').search, rfind=string.rfind, ): """Process request inputs
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=regex.compile('\(:[a-zA-Z][a-zA-Z0-9_]+\|\.[xy]\)$').search, rfind=string.rfind, ): """Process request inputs
2,284
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=regex.compile('\(:[a-zA-Z][a-zA-Z0-9_]+\|\.[xy]\)$').search, rfind=string.rfind, ): """Process request inputs
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=regex.compile('\(:[a-zA-Z][a-zA-Z0-9_]+\|\.[xy]\)$').search, rfind=string.rfind, ): """Process request inputs
2,285
def parse_cookie(text, result=None, qparmre=regex.compile( '\([\0- ]*' '\([^\0- ;,=\"]+\)="\([^"]*\)\"' '\([\0- ]*[;,]\)?[\0- ]*\)' ), parmre=regex.compile( '\([\0- ]*' '\([^\0- ;,=\"]+\)=\([^\0- ;,\"]*\)' '\([\0- ]*[;,]\)?[\0- ]*\)' ), acquire=parse_cookie_lock.acquire, release=parse_cookie_lock.release, ): if result is None: result={} already_have=result.has_key acquire() try: 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: # this may be an invalid cookie. # We'll simply bail without raising an error # if the cookie is invalid. return result finally: release() if not already_have(name): result[name]=value return apply(parse_cookie,(text[l:],result))
def parse_cookie(text, result=None, qparmre=re.compile( '([\x00- ]*([^\x00- ;,="]+)="([^"]*)"([\x00- ]*[;,])?[\x00- ]*)'), parmre=re.compile( '([\x00- ]*([^\x00- ;,="]+)=([^\x00- ;,"]*)([\x00- ]*[;,])?[\x00- ]*)'), acquire=parse_cookie_lock.acquire, release=parse_cookie_lock.release, ): if result is None: result={} already_have=result.has_key acquire() try: 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: # this may be an invalid cookie. # We'll simply bail without raising an error # if the cookie is invalid. return result finally: release() if not already_have(name): result[name]=value return apply(parse_cookie,(text[l:],result))
2,286
def parse_cookie(text, result=None, qparmre=regex.compile( '\([\0- ]*' '\([^\0- ;,=\"]+\)="\([^"]*\)\"' '\([\0- ]*[;,]\)?[\0- ]*\)' ), parmre=regex.compile( '\([\0- ]*' '\([^\0- ;,=\"]+\)=\([^\0- ;,\"]*\)' '\([\0- ]*[;,]\)?[\0- ]*\)' ), acquire=parse_cookie_lock.acquire, release=parse_cookie_lock.release, ): if result is None: result={} already_have=result.has_key acquire() try: 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: # this may be an invalid cookie. # We'll simply bail without raising an error # if the cookie is invalid. return result finally: release() if not already_have(name): 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- ]*\)' ), acquire=parse_cookie_lock.acquire, release=parse_cookie_lock.release, ): if result is None: result={} already_have=result.has_key acquire() try: mo_q = qparmre.match(text) if mo_q: # 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: # this may be an invalid cookie. # We'll simply bail without raising an error # if the cookie is invalid. return result finally: release() if not already_have(name): result[name]=value return apply(parse_cookie,(text[l:],result))
2,287
def parse_cookie(text, result=None, qparmre=regex.compile( '\([\0- ]*' '\([^\0- ;,=\"]+\)="\([^"]*\)\"' '\([\0- ]*[;,]\)?[\0- ]*\)' ), parmre=regex.compile( '\([\0- ]*' '\([^\0- ;,=\"]+\)=\([^\0- ;,\"]*\)' '\([\0- ]*[;,]\)?[\0- ]*\)' ), acquire=parse_cookie_lock.acquire, release=parse_cookie_lock.release, ): if result is None: result={} already_have=result.has_key acquire() try: 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: # this may be an invalid cookie. # We'll simply bail without raising an error # if the cookie is invalid. return result finally: release() if not already_have(name): 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- ]*\)' ), acquire=parse_cookie_lock.acquire, release=parse_cookie_lock.release, ): if result is None: result={} already_have=result.has_key acquire() try: if qparmre.match(text) >= 0: # Match quoted correct cookies l = len(mo_q.group(1)) name = mo_q.group(2) value = mo_q.group(3) else: # Match evil MSIE cookies ;) name=parmre.group(2) value=parmre.group(3) l=len(parmre.group(1)) else: # this may be an invalid cookie. # We'll simply bail without raising an error # if the cookie is invalid. return result finally: release() if not already_have(name): result[name]=value return apply(parse_cookie,(text[l:],result))
2,288
def parse_cookie(text, result=None, qparmre=regex.compile( '\([\0- ]*' '\([^\0- ;,=\"]+\)="\([^"]*\)\"' '\([\0- ]*[;,]\)?[\0- ]*\)' ), parmre=regex.compile( '\([\0- ]*' '\([^\0- ;,=\"]+\)=\([^\0- ;,\"]*\)' '\([\0- ]*[;,]\)?[\0- ]*\)' ), acquire=parse_cookie_lock.acquire, release=parse_cookie_lock.release, ): if result is None: result={} already_have=result.has_key acquire() try: 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: # this may be an invalid cookie. # We'll simply bail without raising an error # if the cookie is invalid. return result finally: release() if not already_have(name): 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- ]*\)' ), acquire=parse_cookie_lock.acquire, release=parse_cookie_lock.release, ): if result is None: result={} already_have=result.has_key acquire() try: 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: # this may be an invalid cookie. # We'll simply bail without raising an error # if the cookie is invalid. return result finally: release() if not already_have(name): result[name]=value return apply(parse_cookie,(text[l:],result))
2,289
def sendTemplate(trueself, self, messageTemplate, statusTemplate=None, mto=None, mfrom=None, REQUEST): 'render a mail template, then send it...' mtemplate = getattr(self, messageTemplate) messageText = mtemplate(self, trueself.REQUEST)
def sendTemplate(trueself, self, messageTemplate, statusTemplate=None, mto=None, mfrom=None, REQUEST=None): 'render a mail template, then send it...' mtemplate = getattr(self, messageTemplate) messageText = mtemplate(self, trueself.REQUEST)
2,290
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' \ 'To use localization options, you must ensure\n' \ 'that the locale module is compiled into your\n' \ 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The specified locale is not supported by your system.\n' \ 'See your operating system documentation for more\n' \ 'information on locale support.' )
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' \ 'To use localization options, you must ensure\n' \ 'that the locale module is compiled into your\n' \ 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The specified locale is not supported by your system.\n' \ 'See your operating system documentation for more\n' \ 'information on locale support.' )
2,291
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
2,292
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
2,293
def main(): # The "main" program for this module pass
def main(): # The "main" program for this module pass
2,294
def main(): # The "main" program for this module pass
def main(): # The "main" program for this module pass
2,295
def str_field(v): if type(v) is types.ListType: return map(str_field,v) if type(v) is types.InstanceType and v.__class__ is newcgi.MiniFieldStorage: v=v.value elif type(v) is not types.StringType: try: if v.file: v=v.file else: v=v.value except: pass return v
def str_field(v): if type(v) is types.ListType: return map(str_field,v) if type(v) is types.InstanceType and v.__class__ is FieldStorage: v=v.value elif type(v) is not types.StringType: try: if v.file: v=v.file else: v=v.value except: pass return v
2,296
def __init__(self,
def __init__(self,
2,297
def __init__(self,body='',status=200,headers=None,
def __init__(self,body='',status=200,headers=None,
2,298
def exception(self):
def exception(self):
2,299