bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
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
3,300
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. """
3,301
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. """
3,302
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,303
def emitRepeat(self, arg, position=(None, None)): m = re.match("(?s)\s*(%s)\s+(.*)\Z" % NAME_RE, arg) if not m: raise TALError("invalid repeat syntax: " + `repeat`, position) name, expr = m.group(1, 2) cexpr = self.compileExpression(expr) program = self.popProgram() self.emit("loop", name, cexpr, program)
def emitRepeat(self, arg, position=(None, None)): m = re.match("(?s)\s*(%s)\s+(.*)\Z" % NAME_RE, arg) if not m: raise TALError("invalid repeat syntax: " + `arg`, position) name, expr = m.group(1, 2) cexpr = self.compileExpression(expr) program = self.popProgram() self.emit("loop", name, cexpr, program)
3,304
def emitFillSlot(self, slotName, position=(None, None)): program = self.popProgram() if self.slots.has_key(slotName): raise METALError("duplicate slot definition: %s" % slotName, position) self.slots[slotName] = program self.emit("fillSlot", slotName, program)
def emitFillSlot(self, slotName, position=(None, None)): program = self.popProgram() if self.slots.has_key(slotName): raise METALError("duplicate fill-slot name: %s" % slotName, position) self.slots[slotName] = program self.emit("fillSlot", slotName, program)
3,305
def __init__(self, product, dest, REQUEST): self._product=product.__dict__ self._d=dest v=REQUEST['URL'] v=v[:rfind(v,'/')] self._u=v[:rfind(v,'/')]
def __init__(self, product, dest, REQUEST): if hasattr(product,'aq_base'): product=product.aq_base self._product=product self._d=dest v=REQUEST['URL'] v=v[:rfind(v,'/')] self._u=v[:rfind(v,'/')]
3,306
def manage_catalogObject(self, REQUEST, urls=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)
def manage_catalogObject(self, REQUEST, urls=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)
3,307
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 """
3,308
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 """
3,309
def manage_catalogReindex(self, REQUEST): """ clear the catalog, then re-index everything """
def manage_catalogReindex(self, REQUEST): """ clear the catalog, then re-index everything """
3,310
def manage_catalogReindex(self, REQUEST): """ clear the catalog, then re-index everything """
def manage_catalogReindex(self, REQUEST): """ clear the catalog, then re-index everything """
3,311
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))
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))
3,312
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))
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))
3,313
def resolve_url(self, path, REQUEST): """ The use of this function is depricated. Use 'getobject' """ # 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): """ The use of this function is depricated.Use 'getobject' """ # 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.
3,314
def install_products(): # 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,'lib/python/Products') isdir=os.path.isdir exists=os.path.exists DictType=type({}) meta_types=list(Folder.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) if product_name not in ['OFSP','MailHost']: if not lic_check(product_name): continue 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'] if (not meta_type.has_key('prefix') and not regex.match('[^a-zA-Z0-9_]', name)): meta_type['prefix']=lower(name) if meta_type.has_key('prefix'): prefix=meta_type['prefix'] def productNames(self, name=name): t=[] for i in self.objectMap(): if i['meta_type']==name: t.append(i['name']) return t setattr(Folder.Folder, "%sNames" % prefix , productNames) def productValues(self, name=name): t=[] for i in self.objectMap(): if i['meta_type']==name: t.append(getattr(self,i['name'])) return t setattr(Folder.Folder, "%sValues" % prefix , productValues) def productItems(self, name=name): t=[] for i in self.objectMap(): if i['meta_type']=='Image': n=i['name'] t.append((n,getattr(self,n))) return t setattr(Folder.Folder, "%sItems" % prefix , productItems) for name,method in pgetattr(product, 'methods', {}).items(): setattr(Folder.Folder, name, method) misc_=pgetattr(product, 'misc_', {}) if type(misc_) is DictType: misc_=Misc_(product_name, misc_) Application.misc_.__dict__[product_name]=misc_ Folder.Folder.dynamic_meta_types=tuple(meta_types)
def install_products(): # 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,'lib/python/Products') isdir=os.path.isdir exists=os.path.exists DictType=type({}) meta_types=list(Folder.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) if not lic_check(product_name): continue 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'] if (not meta_type.has_key('prefix') and not regex.match('[^a-zA-Z0-9_]', name)): meta_type['prefix']=lower(name) if meta_type.has_key('prefix'): prefix=meta_type['prefix'] def productNames(self, name=name): t=[] for i in self.objectMap(): if i['meta_type']==name: t.append(i['name']) return t setattr(Folder.Folder, "%sNames" % prefix , productNames) def productValues(self, name=name): t=[] for i in self.objectMap(): if i['meta_type']==name: t.append(getattr(self,i['name'])) return t setattr(Folder.Folder, "%sValues" % prefix , productValues) def productItems(self, name=name): t=[] for i in self.objectMap(): if i['meta_type']=='Image': n=i['name'] t.append((n,getattr(self,n))) return t setattr(Folder.Folder, "%sItems" % prefix , productItems) for name,method in pgetattr(product, 'methods', {}).items(): setattr(Folder.Folder, name, method) misc_=pgetattr(product, 'misc_', {}) if type(misc_) is DictType: misc_=Misc_(product_name, misc_) Application.misc_.__dict__[product_name]=misc_ Folder.Folder.dynamic_meta_types=tuple(meta_types)
3,315
def lic_check(product_name): path_join =os.path.join product_dir=path_join(SOFTWARE_HOME,'lib/python/Products') package_dir=path_join(product_dir, product_name) bobobase =Globals.Bobobase try: f=open(path_join(package_dir,'%s.lic' % product_name), 'rb') except: try: product=getattr(__import__("Products.%s" % product_name), product_name) for s in pgetattr(product, 'classes', ()): p=rfind(s,'.') m='Products.%s.%s' % (product_name, s[:p]) c=s[p+1:] __import__(m) setattr(sys.modules[m], c, Expired) except: pass return 0 dat=f.read() f.close() rot=rotor.newrotor('\357\261\390\247\357\362\306\216\226', 13) dat=rot.decrypt(dat) dat=list(dat) dat.reverse() dat=join(dat,'') dat=marshal.loads(dat) del rot name=dat[0] val =dat[1] if name != product_name: return 0 if val is None: return 1 else: if not bobobase.has_key('_t_'): bobobase['_t_']={} get_transaction().commit() t=bobobase['_t_'] if not t.has_key(product_name): t[product_name]=time.time() bobobase['_t_']=t get_transaction().commit() if (t[product_name] + (86400.0 * val)) < time.time(): product=getattr(__import__("Products.%s" % product_name), product_name) for s in pgetattr(product, 'classes', ()): p=rfind(s,'.') m='Products.%s.%s' % (product_name, s[:p]) c=s[p+1:] __import__(m) setattr(sys.modules[m], c, Expired) return 0
def lic_check(product_name): path_join =os.path.join product_dir=path_join(SOFTWARE_HOME,'lib/python/Products') package_dir=path_join(product_dir, product_name) bobobase =Globals.Bobobase try: f=open(path_join(package_dir,'%s.lic' % product_name), 'rb') except: try: product=getattr(__import__("Products.%s" % product_name), product_name) for s in pgetattr(product, 'classes', ()): p=rfind(s,'.') m='Products.%s.%s' % (product_name, s[:p]) c=s[p+1:] try: __import__(m) except: m=s[:p] __import__(m) setattr(sys.modules[m], c, Expired) except: pass return 0 dat=f.read() f.close() rot=rotor.newrotor('\357\261\390\247\357\362\306\216\226', 13) dat=rot.decrypt(dat) dat=list(dat) dat.reverse() dat=join(dat,'') dat=marshal.loads(dat) del rot name=dat[0] val =dat[1] if name != product_name: return 0 if val is None: return 1 else: if not bobobase.has_key('_t_'): bobobase['_t_']={} get_transaction().commit() t=bobobase['_t_'] if not t.has_key(product_name): t[product_name]=time.time() bobobase['_t_']=t get_transaction().commit() if (t[product_name] + (86400.0 * val)) < time.time(): product=getattr(__import__("Products.%s" % product_name), product_name) for s in pgetattr(product, 'classes', ()): p=rfind(s,'.') m='Products.%s.%s' % (product_name, s[:p]) c=s[p+1:] try: __import__(m) except: m=s[:p] __import__(m) setattr(sys.modules[m], c, Expired) return 0
3,316
def lic_check(product_name): path_join =os.path.join product_dir=path_join(SOFTWARE_HOME,'lib/python/Products') package_dir=path_join(product_dir, product_name) bobobase =Globals.Bobobase try: f=open(path_join(package_dir,'%s.lic' % product_name), 'rb') except: try: product=getattr(__import__("Products.%s" % product_name), product_name) for s in pgetattr(product, 'classes', ()): p=rfind(s,'.') m='Products.%s.%s' % (product_name, s[:p]) c=s[p+1:] __import__(m) setattr(sys.modules[m], c, Expired) except: pass return 0 dat=f.read() f.close() rot=rotor.newrotor('\357\261\390\247\357\362\306\216\226', 13) dat=rot.decrypt(dat) dat=list(dat) dat.reverse() dat=join(dat,'') dat=marshal.loads(dat) del rot name=dat[0] val =dat[1] if name != product_name: return 0 if val is None: return 1 else: if not bobobase.has_key('_t_'): bobobase['_t_']={} get_transaction().commit() t=bobobase['_t_'] if not t.has_key(product_name): t[product_name]=time.time() bobobase['_t_']=t get_transaction().commit() if (t[product_name] + (86400.0 * val)) < time.time(): product=getattr(__import__("Products.%s" % product_name), product_name) for s in pgetattr(product, 'classes', ()): p=rfind(s,'.') m='Products.%s.%s' % (product_name, s[:p]) c=s[p+1:] __import__(m) setattr(sys.modules[m], c, Expired) return 0
def lic_check(product_name): path_join =os.path.join product_dir=path_join(SOFTWARE_HOME,'lib/python/Products') package_dir=path_join(product_dir, product_name) bobobase =Globals.Bobobase try: f=open(path_join(package_dir,'%s.lic' % product_name), 'rb') except: try: product=getattr(__import__("Products.%s" % product_name), product_name) for s in pgetattr(product, 'classes', ()): p=rfind(s,'.') m='Products.%s.%s' % (product_name, s[:p]) c=s[p+1:] __import__(m) setattr(sys.modules[m], c, Expired) except: pass return 0 dat=f.read() f.close() rot=rotor.newrotor('\357\261\390\247\357\362\306\216\226', 13) dat=rot.decrypt(dat) dat=list(dat) dat.reverse() dat=join(dat,'') dat=marshal.loads(dat) del rot name=dat[0] val =dat[1] if name != product_name: return 0 if val is None: return 1 else: if not bobobase.has_key('_t_'): bobobase['_t_']={} get_transaction().commit() t=bobobase['_t_'] if not t.has_key(product_name): t[product_name]=time.time() bobobase['_t_']=t get_transaction().commit() if (t[product_name] + (86400.0 * val)) < time.time(): product=getattr(__import__("Products.%s" % product_name), product_name) for s in pgetattr(product, 'classes', ()): p=rfind(s,'.') m='Products.%s.%s' % (product_name, s[:p]) c=s[p+1:] __import__(m) setattr(sys.modules[m], c, Expired) return 0
3,317
def absolute_url(self, relative=0): """Return an absolute url to the object. Note that the url will reflect the acquisition path of the object if the object has been acquired.""" obj=self url=[] while hasattr(obj, 'aq_parent') and hasattr(obj.aq_parent, 'id'): id=callable(obj.id) and obj.id() or str(obj.id) url.append(quote(id)) obj=obj.aq_parent if not relative: url.append(self.aq_acquire('REQUEST').script) url.reverse() return join(url, '/')
def absolute_url(self, relative=0): """Return an absolute url to the object. Note that the url will reflect the acquisition path of the object if the object has been acquired.""" obj=self url=[] while hasattr(obj, 'aq_parent') and hasattr(obj.aq_parent, 'id'): id=callable(obj.id) and obj.id() or str(obj.id) url.append(quote(id)) obj=obj.aq_parent if not relative: url.append(self.aq_acquire('REQUEST').script) url.reverse() return join(url, '/')
3,318
def __len__(self): return 1
def def absolute_url(self, relative=0): id=quote(self.id) p=getattr(self,'aq_inner', None) if p is not None: url=p.aq_parent.absolute_url(relative) if url: id=url+'/'+id return id __len__(self): def absolute_url(self, relative=0): id=quote(self.id) p=getattr(self,'aq_inner', None) if p is not None: url=p.aq_parent.absolute_url(relative) if url: id=url+'/'+id return id return def absolute_url(self, relative=0): id=quote(self.id) p=getattr(self,'aq_inner', None) if p is not None: url=p.aq_parent.absolute_url(relative) if url: id=url+'/'+id return id 1 def absolute_url(self, relative=0): id=quote(self.id) p=getattr(self,'aq_inner', None) if p is not None: url=p.aq_parent.absolute_url(relative) if url: id=url+'/'+id return id
3,319
def justify_and_indent(text, level, munge=0, width=72): """ indent and justify text, rejustify (munge) if specified """ lines = [] if munge: line = " " * level text = string.split(string.strip(string.translate(text, string.maketrans("\r\n", " ")))) for word in text: line = string.join([line, word]) if len(line) > width: lines.append(line) line = " " * level else: lines.append(line) return string.join(lines, "\n") else: text = string.split(string.replace(text,"\r\n", "\n"), "\n") for line in text: lines.append( (" " * level) + line) return string.join(lines, "\n")
defjustify_and_indent(text,level,munge=0,width=72):"""indentandjustifytext,rejustify(munge)ifspecified"""lines=[]ifmunge:line=""*leveltext=string.split(string.strip(string.translate(text,string.maketrans("\r\n",""))))forwordintext:line=string.join([line,word])iflen(line)>width:lines.append(line)line=""*levelelse:lines.append(line)returnstring.join(lines,"\n")else:text=string.split(string.replace(text,"\r\n","\n"),"\n")forlineintext:lines.append((""*level)+line)returnstring.join(lines,"\n")
3,320
def __init__(self, *attrs): Distribution.__init__(self, *attrs) self.cmdclass['build'] = MyBuilder self.cmdclass['build_ext'] = MyExtBuilder self.cmdclass['install_lib'] = MyLibInstaller
def __init__(self, *attrs): Distribution.__init__(self, *attrs) self.cmdclass['build'] = MyBuilder self.cmdclass['build_ext'] = MyExtBuilder self.cmdclass['install_lib'] = MyLibInstaller
3,321
def __init__(self, *attrs): Distribution.__init__(self, *attrs) self.cmdclass['build'] = MyBuilder self.cmdclass['build_ext'] = MyExtBuilder self.cmdclass['install_lib'] = MyLibInstaller
def __init__(self, *attrs): Distribution.__init__(self, *attrs) self.cmdclass['build'] = MyBuilder self.cmdclass['build_ext'] = MyExtBuilder self.cmdclass['install_lib'] = MyLibInstaller
3,322
def render(self,md): args=self.args have=args.has_key
def render(self,md): args=self.args have=args.has_key
3,323
def tpRenderTABLE(self, id, root_url, url, state, substate, diff, data, colspan, section, md, treeData, level=0, args=None, simple_type={type(''):0, type(1):0, type(1.0):0}.has_key, ): "Render a tree as a table" have_arg=args.has_key exp=0 if level >= 0: urlattr=args['url'] if urlattr and hasattr(self, urlattr): tpUrl=getattr(self, urlattr) if not simple_type(type(tpUrl)): tpUrl=tpUrl() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl root_url = root_url or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 idattr=args['id'] output=data.append items=None if (have_arg('assume_children') and args['assume_children'] and substate is not state): # We should not compute children unless we have to. # See if we've been asked to expand our children. for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if not exp: items=1 if items is None: validate=md.validate if have_arg('branches') and hasattr(self, args['branches']): if validate is None or not hasattr(self, 'aq_acquire'): items=getattr(self, args['branches']) else: items=self.aq_acquire(args['branches'],validate,md) items=items() elif have_arg('branches_expr'): items=args['branches_expr'](md) if not items and have_arg('leaves'): items=1 if items and items != 1: if validate is not None: unauth=[] index=0 for i in items: try: v=validate(items,items,index,i,md) except: v=0 if not v: unauth.append(index) index=index+1 if unauth: if have_arg('skip_unauthorized') and args['skip_unauthorized']: items=list(items) unauth.reverse() for i in unauth: del items[i] else: raise ValidationError, unauth if have_arg('sort'): # Faster/less mem in-place sort if type(items)==type(()): items=list(items) sort=args['sort'] size=range(len(items)) for i in size: v=items[i] k=getattr(v,sort) try: k=k() except: pass items[i]=(k,v) items.sort() for i in size: items[i]=items[i][1] if have_arg('reverse'): items=self.reverse_items(items) diff.append(id) sub=None if substate is state: output('<TABLE CELLSPACING="0">\n') sub=substate[0] exp=items else: # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break #################################### # Mostly inline encode_seq for speed s=compress(str(diff)) if len(s) > 57: s=encode_str(s) else: s=b2a_base64(s)[:-1] l=find(s,'=') if l >= 0: s=s[:l] s=translate(s, tplus) #################################### script=md['SCRIPT_NAME'] if exp: treeData['tree-item-expanded']=1 output('<A NAME="%s">' '<A HREF="%s?tree-c=%s#%s">' '<IMG SRC="%s/p_/mi" BORDER=0></A></A>' % (id, root_url, s, id, script)) else: output('<A NAME="%s">' '<A HREF="%s?tree-e=%s#%s">' '<IMG SRC="%s/p_/pl" BORDER=0></A></A>' % (id, root_url, s, id, script)) output('</TD>\n') else: if level > 2: output('<TD COLSPAN="%s"></TD>' % level) elif level > 0: output('<TD></TD>' * level) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD%s%s VALIGN="TOP" ALIGN="LEFT">' % ((dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''), (have_arg('nowrap') and args['nowrap'] and ' NOWRAP' or '')) ) output(render_blocks(section, md)) output('</TD>\n</TR>\n') if exp: level=level+1 dataspan=colspan-level if level > 3: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): doc=args['header'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: output(doc( None, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) if items==1: # leaves if have_arg('leaves'): doc=args['leaves'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) try: output(doc( None,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) finally: md._pop(1) elif have_arg('expand'): doc=args['expand'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) try: output(doc( None,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) finally: md._pop(1) else: __traceback_info__=sub, args, state, substate ids={} for item in items: if hasattr(item, idattr): id=getattr(item, idattr) if not simple_type(type(id)): id=id() elif hasattr(item, '_p_oid'): id=oid(item) else: id=pyid(item) if len(sub)==1: sub.append([]) substate=sub[1] ids[id]=1 md._push(InstanceDict(item,md)) try: data=tpRenderTABLE( item,id,root_url,url,state,substate,diff,data, colspan, section, md, treeData, level, args) finally: md._pop() if not sub[1]: del sub[1] ids=ids.has_key for i in range(len(substate)-1,-1): if not ids(substate[i][0]): del substate[i] if have_arg('footer'): doc=args['footer'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: output(doc( None, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) del diff[-1] if not diff: output('</TABLE>\n') return data
def tpRenderTABLE(self, id, root_url, url, state, substate, diff, data, colspan, section, md, treeData, level=0, args=None, simple_type={type(''):0, type(1):0, type(1.0):0}.has_key, ): "Render a tree as a table" have_arg=args.has_key exp=0 if level >= 0: urlattr=args['url'] if urlattr and hasattr(self, urlattr): tpUrl=getattr(self, urlattr) if not simple_type(type(tpUrl)): tpUrl=tpUrl() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl root_url = root_url or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 idattr=args['id'] output=data.append items=None if (have_arg('assume_children') and args['assume_children'] and substate is not state): # We should not compute children unless we have to. # See if we've been asked to expand our children. for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if not exp: items=1 if items is None: validate=md.validate if have_arg('branches') and hasattr(self, args['branches']): if validate is None or not hasattr(self, 'aq_acquire'): items=getattr(self, args['branches']) else: items=self.aq_acquire(args['branches'],validate,md) items=items() elif have_arg('branches_expr'): items=args['branches_expr'](md) if not items and have_arg('leaves'): items=1 if items and items != 1: if validate is not None: unauth=[] index=0 for i in items: try: v=validate(items,items,index,i,md) except: v=0 if not v: unauth.append(index) index=index+1 if unauth: if have_arg('skip_unauthorized') and args['skip_unauthorized']: items=list(items) unauth.reverse() for i in unauth: del items[i] else: raise ValidationError, unauth if have_arg('sort'): # Faster/less mem in-place sort if type(items)==type(()): items=list(items) sort=args['sort'] size=range(len(items)) for i in size: v=items[i] k=getattr(v,sort) try: k=k() except: pass items[i]=(k,v) items.sort() for i in size: items[i]=items[i][1] if have_arg('reverse'): items=list(items) items.reverse() diff.append(id) sub=None if substate is state: output('<TABLE CELLSPACING="0">\n') sub=substate[0] exp=items else: # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break #################################### # Mostly inline encode_seq for speed s=compress(str(diff)) if len(s) > 57: s=encode_str(s) else: s=b2a_base64(s)[:-1] l=find(s,'=') if l >= 0: s=s[:l] s=translate(s, tplus) #################################### script=md['SCRIPT_NAME'] if exp: treeData['tree-item-expanded']=1 output('<A NAME="%s">' '<A HREF="%s?tree-c=%s#%s">' '<IMG SRC="%s/p_/mi" BORDER=0></A></A>' % (id, root_url, s, id, script)) else: output('<A NAME="%s">' '<A HREF="%s?tree-e=%s#%s">' '<IMG SRC="%s/p_/pl" BORDER=0></A></A>' % (id, root_url, s, id, script)) output('</TD>\n') else: if level > 2: output('<TD COLSPAN="%s"></TD>' % level) elif level > 0: output('<TD></TD>' * level) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD%s%s VALIGN="TOP" ALIGN="LEFT">' % ((dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''), (have_arg('nowrap') and args['nowrap'] and ' NOWRAP' or '')) ) output(render_blocks(section, md)) output('</TD>\n</TR>\n') if exp: level=level+1 dataspan=colspan-level if level > 3: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): doc=args['header'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: output(doc( None, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) if items==1: # leaves if have_arg('leaves'): doc=args['leaves'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) try: output(doc( None,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) finally: md._pop(1) elif have_arg('expand'): doc=args['expand'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) try: output(doc( None,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) finally: md._pop(1) else: __traceback_info__=sub, args, state, substate ids={} for item in items: if hasattr(item, idattr): id=getattr(item, idattr) if not simple_type(type(id)): id=id() elif hasattr(item, '_p_oid'): id=oid(item) else: id=pyid(item) if len(sub)==1: sub.append([]) substate=sub[1] ids[id]=1 md._push(InstanceDict(item,md)) try: data=tpRenderTABLE( item,id,root_url,url,state,substate,diff,data, colspan, section, md, treeData, level, args) finally: md._pop() if not sub[1]: del sub[1] ids=ids.has_key for i in range(len(substate)-1,-1): if not ids(substate[i][0]): del substate[i] if have_arg('footer'): doc=args['footer'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: output(doc( None, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) del diff[-1] if not diff: output('</TABLE>\n') return data
3,324
def _checkId(self, id, allow_dup=0): # If allow_dup is false, an error will be raised if an object # with the given id already exists. If allow_dup is true, # only check that the id string contains no illegal chars; # _checkId() will be called again later with allow_dup # set to false before the object is added. if not id or (type(id) != type('')): raise 'Bad Request', 'Empty or invalid id specified.' if bad_id(id) != -1: raise 'Bad Request', ( 'The id "%s" contains characters illegal in URLs.' % id) if id[0]=='_': raise 'Bad Request', ( 'The id "%s" is invalid - it begins with an underscore.' % id) if not allow_dup: obj = getattr(self, id, None) if obj is not None: # An object by the given id exists either in this # ObjectManager or in the acquisition path. print obj, dir(obj) flag = getattr(obj, '__replaceable__', NOT_REPLACEABLE) if flag == UNIQUE: raise 'Bad Request', \ ('The id "%s" is reserved by another object.' % id) base = getattr(self, 'aq_base', self) if hasattr(base, id): # The object is located in this ObjectManager. if flag != REPLACEABLE: raise 'Bad Request', ('The id "%s" is invalid - ' \ 'it is already in use.' % id) if id == 'REQUEST': raise 'Bad Request', 'REQUEST is a reserved name.' if '/' in id: raise 'Bad Request', ( 'The id "%s" contains characters illegal in URLs.' % id )
def _checkId(self, id, allow_dup=0): # If allow_dup is false, an error will be raised if an object # with the given id already exists. If allow_dup is true, # only check that the id string contains no illegal chars; # _checkId() will be called again later with allow_dup # set to false before the object is added. if not id or (type(id) != type('')): raise 'Bad Request', 'Empty or invalid id specified.' if bad_id(id) != -1: raise 'Bad Request', ( 'The id "%s" contains characters illegal in URLs.' % id) if id[0]=='_': raise 'Bad Request', ( 'The id "%s" is invalid - it begins with an underscore.' % id) if not allow_dup: obj = getattr(self, id, None) if obj is not None: # An object by the given id exists either in this # ObjectManager or in the acquisition path. flag = getattr(obj, '__replaceable__', NOT_REPLACEABLE) if flag == UNIQUE: raise 'Bad Request', \ ('The id "%s" is reserved by another object.' % id) base = getattr(self, 'aq_base', self) if hasattr(base, id): # The object is located in this ObjectManager. if flag != REPLACEABLE: raise 'Bad Request', ('The id "%s" is invalid - ' \ 'it is already in use.' % id) if id == 'REQUEST': raise 'Bad Request', 'REQUEST is a reserved name.' if '/' in id: raise 'Bad Request', ( 'The id "%s" contains characters illegal in URLs.' % id )
3,325
def render(self, md): args=self.args has_key=args.has_key
def render(self, md): args=self.args has_key=args.has_key
3,326
def log(self, subsystem, severity, summary, detail, error): if _log_dest is None or severity < _log_level: return buf = ["------"] line = ("%s %s %s %s" % (log_time(), severity_string(severity), subsystem, summary)) if not textwrap or len(line) < 80: buf.append(line) else: buf.extend(textwrap.wrap(line, width=79, subsequent_indent=" "*20, break_long_words=0))
def log(self, subsystem, severity, summary, detail, error): if _log_dest is None or severity < _log_level: return buf = ["------"] line = ("%s %s %s %s" % (log_time(), severity_string(severity), subsystem, summary)) if not textwrap or len(line) < 80: buf.append(line) else: buf.extend(textwrap.wrap(line, width=79, subsequent_indent=" "*20, break_long_words=0))
3,327
def search(self,path,default_level=0): """ path is either a string representing a relative URL or a part of a relative URL or a tuple (path,level).
def search(self,path,default_level=0): """ path is either a string representing a relative URL or a part of a relative URL or a tuple (path,level).
3,328
def search(self,path,default_level=0): """ path is either a string representing a relative URL or a part of a relative URL or a tuple (path,level).
def search(self,path,default_level=0): """ path is either a string representing a relative URL or a part of a relative URL or a tuple (path,level).
3,329
def PersistentClassDict(doc=None, meta_type=None): # Build new class dict dict={} dict.update(Template.__dict__) if meta_type is not None: dict['meta_type']=dict['__doc__']=meta_type if doc is not None: dict['__doc__']=doc return dict
def _marker=[] PersistentClassDict(doc=None, _marker=[] meta_type=None): _marker=[] # _marker=[] Build _marker=[] new _marker=[] class _marker=[] dict _marker=[] dict={} _marker=[] dict.update(Template.__dict__) _marker=[] if _marker=[] meta_type _marker=[] is _marker=[] not _marker=[] None: _marker=[] dict['meta_type']=dict['__doc__']=meta_type _marker=[] if _marker=[] doc _marker=[] is _marker=[] not _marker=[] None: _marker=[] dict['__doc__']=doc _marker=[] return _marker=[] dict _marker=[]
3,330
def getClassAttr(self, name): r=self._zclass_.__dict__[name] return r
def getClassAttr(self, name): r=self._zclass_.__dict__[name] return r
3,331
def parse_params(text, result=None, tag='', unparmre=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 that is not a name-value pair 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.has_key(''): 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) else: if not text or not strip(text): return result raise InvalidParameter, text if not parms.has_key(name): raise ParseError, ( 'Invalid attribute name, "%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- =\"]+\)\)'), 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 that is not a name-value pair 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.has_key(''): 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) 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) result[name]=value text=strip(text[l:]) if text: return apply(parse_params,(text,result),parms) else: return result
3,332
def unindex_item(self,i):
def unindex_item(self,i):
3,333
def call_with_ns(f, ns, arg=1): td = TemplateDict() td.validate = getSecurityManager().validate td.this = None td._push(ns['request']) td._push(InstanceDict(ns['here'], td)) td._push(ns['var']) try: if arg==2: return f(None, td) else: return f(td) finally: td._pop(3)
def call_with_ns(f, ns, arg=1): td = TemplateDict() td.validate = validate td.this = None td._push(ns['request']) td._push(InstanceDict(ns['here'], td)) td._push(ns['var']) try: if arg==2: return f(None, td) else: return f(td) finally: td._pop(3)
3,334
def index_html(self, REQUEST, PARENTS, RESPONSE):
def index_html(self, REQUEST, PARENTS, RESPONSE):
3,335
def manage_edit(self,data,title,roles,REQUEST=None):
def manage_edit(self,data,title,roles,REQUEST=None):
3,336
def manage_edit(self,data,title,roles,REQUEST=None):
def manage_edit(self,data,title,roles,REQUEST=None):
3,337
def manage_addDocument(self,id,title,roles,REQUEST,file=''):
def manage_addDocument(self,id,title,roles,REQUEST,file=''):
3,338
def __bobo_traverse__(self, request, name): '''Traversing away''' if name in ('manage_main', 'manage_workspace'): return self.manage_main request.setVirtualRoot([]) stack = request['TraversalRequestNameStack'] stack.append(name) parents = request.PARENTS parents.pop() # I don't belong there return parents.pop() # He'll get put back on
def __bobo_traverse__(self, request, name): '''Traversing away''' if name in ('manage_main', 'manage_workspace'): return self.manage_main request.setVirtualRoot([]) stack = request['TraversalRequestNameStack'] stack.append(name) # I don't belong there return parents.pop() # He'll get put back on
3,339
def tpRenderTABLE(self, id, root_url, url, state, substate, diff, data, colspan, section, md, treeData, level=0, args=None, simple_type={type(''):0, type(1):0, type(1.0):0}.has_key, ): "Render a tree as a table" have_arg=args.has_key exp=0 if level >= 0: urlattr=args['url'] if urlattr and hasattr(self, urlattr): tpUrl=getattr(self, urlattr) if not simple_type(type(tpUrl)): tpUrl=tpUrl() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl root_url = root_url or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 idattr=args['id'] output=data.append items=None if (have_arg('assume_children') and args['assume_children'] and substate is not state): # We should not compute children unless we have to. # See if we've been asked to expand our children. for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if not exp: items=1 if items is None: validate=md.validate if have_arg('branches') and hasattr(self, args['branches']): if validate is None or not hasattr(self, 'aq_acquire'): items=getattr(self, args['branches']) else: items=self.aq_acquire(args['branches'],validate,md) items=items() elif have_arg('branches_expr'): items=args['branches_expr'](md) if not items and have_arg('leaves'): items=1 if items and items != 1: if validate is not None: unauth=[] index=0 for i in items: try: v=validate(items,items,index,i,md) except: v=0 if not v: unauth.append(index) index=index+1 if unauth: if have_arg('skip_unauthorized') and args['skip_unauthorized']: items=list(items) unauth.reverse() for i in unauth: del items[i] else: raise ValidationError, unauth if have_arg('sort'): # Faster/less mem in-place sort if type(items)==type(()): items=list(items) sort=args['sort'] size=range(len(items)) for i in size: v=items[i] k=getattr(v,sort) try: k=k() except: pass items[i]=(k,v) items.sort() for i in size: items[i]=items[i][1] diff.append(id) sub=None if substate is state: output('<TABLE CELLSPACING="0">\n') sub=substate[0] exp=items else: # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break #################################### # Mostly inline encode_seq for speed s=compress(str(diff)) if len(s) > 57: s=encode_str(s) else: s=b2a_base64(s)[:-1] l=find(s,'=') if l >= 0: s=s[:l] s=translate(s, tplus) #################################### script=md['SCRIPT_NAME'] if exp: treeData['tree-item-expanded']=1 output('<A NAME="%s">' '<A HREF="%s?tree-c=%s#%s">' '<IMG SRC="%s/p_/mi" BORDER=0></A>' % (id, root_url, s, id, script)) else: output('<A NAME="%s">' '<A HREF="%s?tree-e=%s#%s">' '<IMG SRC="%s/p_/pl" BORDER=0></A>' % (id, root_url, s, id, script)) output('</TD>\n') else: if level > 2: output('<TD COLSPAN="%s"></TD>' % level) elif level > 0: output('<TD></TD>' * level) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD%s%s VALIGN="TOP" ALLIGN="LEFT">' % ((dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''), (have_arg('nowrap') and args['nowrap'] and ' NOWRAP' or '')) ) output(render_blocks(section, md)) output('</TD>\n</TR>\n') if exp: level=level+1 dataspan=colspan-level if level > 3: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): doc=args['header'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: output(doc( None, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) if items==1: # leaves if have_arg['leaves']: doc=args['leaves'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) try: output(doc( None,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) finally: md._pop(1) elif have_arg('expand'): doc=args['expand'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) try: output(doc( None,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) finally: md._pop(1) else: __traceback_info__=sub, args, state, substate ids={} for item in items: if hasattr(item, idattr): id=getattr(item, idattr) if not simple_type(type(id)): id=id() elif hasattr(item, '_p_oid'): id=item._p_oid else: id=pyid(item) if len(sub)==1: sub.append([]) substate=sub[1] ids[id]=1 md._push(InstanceDict(item,md)) try: data=tpRenderTABLE( item,id,root_url,url,state,substate,diff,data, colspan, section, md, treeData, level, args) finally: md._pop() if not sub[1]: del sub[1] ids=ids.has_key for i in range(len(substate)-1,-1): if not ids(substate[i][0]): del substate[i] if have_arg('footer'): doc=args['footer'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: output(doc( None, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) del diff[-1] if not diff: output('</TABLE>\n') return data
def tpRenderTABLE(self, id, root_url, url, state, substate, diff, data, colspan, section, md, treeData, level=0, args=None, simple_type={type(''):0, type(1):0, type(1.0):0}.has_key, ): "Render a tree as a table" have_arg=args.has_key exp=0 if level >= 0: urlattr=args['url'] if urlattr and hasattr(self, urlattr): tpUrl=getattr(self, urlattr) if not simple_type(type(tpUrl)): tpUrl=tpUrl() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl root_url = root_url or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 idattr=args['id'] output=data.append items=None if (have_arg('assume_children') and args['assume_children'] and substate is not state): # We should not compute children unless we have to. # See if we've been asked to expand our children. for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if not exp: items=1 if items is None: validate=md.validate if have_arg('branches') and hasattr(self, args['branches']): if validate is None or not hasattr(self, 'aq_acquire'): items=getattr(self, args['branches']) else: items=self.aq_acquire(args['branches'],validate,md) items=items() elif have_arg('branches_expr'): items=args['branches_expr'](md) if not items and have_arg('leaves'): items=1 if items and items != 1: if validate is not None: unauth=[] index=0 for i in items: try: v=validate(items,items,index,i,md) except: v=0 if not v: unauth.append(index) index=index+1 if unauth: if have_arg('skip_unauthorized') and args['skip_unauthorized']: items=list(items) unauth.reverse() for i in unauth: del items[i] else: raise ValidationError, unauth if have_arg('sort'): # Faster/less mem in-place sort if type(items)==type(()): items=list(items) sort=args['sort'] size=range(len(items)) for i in size: v=items[i] k=getattr(v,sort) try: k=k() except: pass items[i]=(k,v) items.sort() for i in size: items[i]=items[i][1] diff.append(id) sub=None if substate is state: output('<TABLE CELLSPACING="0">\n') sub=substate[0] exp=items else: # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break #################################### # Mostly inline encode_seq for speed s=compress(str(diff)) if len(s) > 57: s=encode_str(s) else: s=b2a_base64(s)[:-1] l=find(s,'=') if l >= 0: s=s[:l] s=translate(s, tplus) #################################### script=md['SCRIPT_NAME'] if exp: treeData['tree-item-expanded']=1 output('<A NAME="%s">' '<A HREF="%s?tree-c=%s#%s">' '<IMG SRC="%s/p_/mi" BORDER=0></A>' % (id, root_url, s, id, script)) else: output('<A NAME="%s">' '<A HREF="%s?tree-e=%s#%s">' '<IMG SRC="%s/p_/pl" BORDER=0></A>' % (id, root_url, s, id, script)) output('</TD>\n') else: if level > 2: output('<TD COLSPAN="%s"></TD>' % level) elif level > 0: output('<TD></TD>' * level) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD%s%s VALIGN="TOP" ALLIGN="LEFT">' % ((dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''), (have_arg('nowrap') and args['nowrap'] and ' NOWRAP' or '')) ) output(render_blocks(section, md)) output('</TD>\n</TR>\n') if exp: level=level+1 dataspan=colspan-level if level > 3: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): doc=args['header'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: output(doc( None, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) if items==1: # leaves if have_arg('leaves'): doc=args['leaves'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) try: output(doc( None,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) finally: md._pop(1) elif have_arg('expand'): doc=args['expand'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) try: output(doc( None,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) finally: md._pop(1) else: __traceback_info__=sub, args, state, substate ids={} for item in items: if hasattr(item, idattr): id=getattr(item, idattr) if not simple_type(type(id)): id=id() elif hasattr(item, '_p_oid'): id=item._p_oid else: id=pyid(item) if len(sub)==1: sub.append([]) substate=sub[1] ids[id]=1 md._push(InstanceDict(item,md)) try: data=tpRenderTABLE( item,id,root_url,url,state,substate,diff,data, colspan, section, md, treeData, level, args) finally: md._pop() if not sub[1]: del sub[1] ids=ids.has_key for i in range(len(substate)-1,-1): if not ids(substate[i][0]): del substate[i] if have_arg('footer'): doc=args['footer'] if md.has_key(doc): doc=md.getitem(doc,0) else: doc=None if doc is not None: output(doc( None, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) del diff[-1] if not diff: output('</TABLE>\n') return data
3,340
def add(self, id='aMailHost', title='Some mail thing', smtp_host=None, localhost='localhost', smtp_port=25, REQUEST): ' add a MailHost into the system ' i=MailHost() #create new mail host i.id=id #give it id i.title=title #title i._init(localHost=localhost, smtpHost=smtp_host, smtpPort=smtp_port) self._setObject(id,i) #register it return self.manage_main(self,REQUEST) #and whatever this does.. :)
def add(self, id='aMailHost', title='Some mail thing', smtp_host=None, localhost='localhost', smtp_port=25, REQUEST): ' add a MailHost into the system ' i=MailHost() #create new mail host i.id=id #give it id i.title=title #title i._init(localHost=localhost, smtpHost=smtp_host, smtpPort=smtp_port) self._setObject(id,i) #register it return self.manage_main(self,REQUEST) #and whatever this does.. :)
3,341
def add(self, id='aMailHost', title='Some mail thing', smtp_host=None, localhost='localhost', smtp_port=25, REQUEST): ' add a MailHost into the system ' i=MailHost() #create new mail host i.id=id #give it id i.title=title #title i._init(localHost=localhost, smtpHost=smtp_host, smtpPort=smtp_port) self._setObject(id,i) #register it return self.manage_main(self,REQUEST) #and whatever this does.. :)
def add(self, id='aMailHost', title='Some mail thing', smtp_host=None, localhost='localhost', smtp_port=25, REQUEST): ' add a MailHost into the system ' i=MailHost() #create new mail host i.id=id #give it id i.title=title #title i._init(localHost=localhost, smtpHost=smtp_host, smtpPort=smtp_port) self._setObject(id,i) #register it return self.manage_main(self,REQUEST) #and whatever this does.. :)
3,342
def newDecapitate(message): blank_re =regex.compile('^[%s]+$' % string.whitespace) header_re=regex.symcomp('^\(<headerName>[^\0- <>:]+\):\(<headerText>.*\)$') linecount=0; headerDict={} maxwell=map(lambda x: string.strip(x),string.split(message,'\n')) for line in maxwell: if not line: break if blank_re.match(line) >= 0: break if header_re.match(line) >=0: headerDict[string.lower(header_re.group('headerName'))] =\ string.strip(header_re.group('headerText')) linecount=linecount+1 if headerDict.has_key('to'): headerDict['to']=map( lambda x: string.strip(x), string.split(headerDict['to'], ',') ) body=string.join(maxwell[linecount:],'\n') return headerDict, body
def newDecapitate(message): blank_re =regex.compile('^[%s]+$' % string.whitespace) header_re=regex.symcomp('^\(<headerName>[^\0- <>:]+\):\(<headerText>.*\)$') space_re =regex.compile('^[%s]+' % string.whitespace) linecount=0; headerDict={};curHeader={} maxwell=map(lambda x: string.rstrip(x),string.split(message,'\n')) for line in maxwell: if not line: break if blank_re.match(line) >= 0: break if header_re.match(line) >=0: curHeader=string.lower(header_re.group('headerName')) headerDict[curHeader] =\ string.strip(header_re.group('headerText')) elif space_re.match(line)>=0: headerDict[curHeader] = "%s %s" % (headerDict[curHeader], line) linecount=linecount+1 if headerDict.has_key('to'): headerDict['to']=map( lambda x: string.strip(x), string.split(headerDict['to'], ',') ) body=string.join(maxwell[linecount:],'\n') return headerDict, body
3,343
def decapitate(message, header_re=regex.compile( '\(\(' '[^\0- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), #r'(([^\0- <>:]+:[^\n]*\n|[ \t]+[^\0- ][^\n]*\n)+)[ \t]*\n([\0-\377]+)' space_re=regex.compile('\([ \t]+\)'), name_re=regex.compile('\([^\0- <>:]+\):\([^\n]*\)'), ): if header_re.match(message) < 0: return message headers, body = header_re.group(1,3) headers=string.split(headers,'\n') headerDict={} i=1 while i < len(headers): if not headers[i]: del headers[i] elif space_re.match(headers[i]) >= 0: headers[i-1]="%s %s" % (headers[i-1], headers[i][len(space_re.group(1)):]) del headers[i] else: i=i+1 for i in range(len(headers)): if name_re.match(headers[i]) >= 0: k, v = name_re.group(1,2) k=string.lower(k); v=string.strip(v) headerDict[k]=v else: raise ValueError, 'Invalid Header (%d): %s ' % (i,headers[i]) if headerDict.has_key('to'): headerDict['to']=map( lambda x: string.strip(x), string.split(headerDict['to'], ',') ) return (headerDict, body)
def decapitate(message, header_re=regex.compile( '\(\(' '[^\0- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), #r'(([^\0- <>:]+:[^\n]*\n|[ \t]+[^\0- ][^\n]*\n)+)[ \t]*\n([\0-\377]+)' space_re=regex.compile('\([ \t]+\)'), name_re=regex.compile('\([^\0- <>:]+\):\([^\n]*\)'), ): if header_re.match(message) < 0: return message headers, body = header_re.group(1,3) headers=string.split(headers,'\n') headerDict={} i=1 while i < len(headers): if not headers[i]: del headers[i] elif space_re.match(headers[i]) >= 0: headers[i-1]="%s %s" % (headers[i-1], headers[i][len(space_re.group(1)):]) del headers[i] else: i=i+1 for i in range(len(headers)): if name_re.match(headers[i]) >= 0: k, v = name_re.group(1,2) k=string.lower(k); v=string.strip(v) headerDict[k]=v else: raise ValueError, 'Invalid Header (%d): %s ' % (i,headers[i]) if headerDict.has_key('to'): headerDict['to']=map( lambda x: string.strip(x), string.split(headerDict['to'], ',') ) return (headerDict, body)
3,344
def decapitate(message, header_re=regex.compile( '\(\(' '[^\0- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), #r'(([^\0- <>:]+:[^\n]*\n|[ \t]+[^\0- ][^\n]*\n)+)[ \t]*\n([\0-\377]+)' space_re=regex.compile('\([ \t]+\)'), name_re=regex.compile('\([^\0- <>:]+\):\([^\n]*\)'), ): if header_re.match(message) < 0: return message headers, body = header_re.group(1,3) headers=string.split(headers,'\n') headerDict={} i=1 while i < len(headers): if not headers[i]: del headers[i] elif space_re.match(headers[i]) >= 0: headers[i-1]="%s %s" % (headers[i-1], headers[i][len(space_re.group(1)):]) del headers[i] else: i=i+1 for i in range(len(headers)): if name_re.match(headers[i]) >= 0: k, v = name_re.group(1,2) k=string.lower(k); v=string.strip(v) headerDict[k]=v else: raise ValueError, 'Invalid Header (%d): %s ' % (i,headers[i]) if headerDict.has_key('to'): headerDict['to']=map( lambda x: string.strip(x), string.split(headerDict['to'], ',') ) return (headerDict, body)
def decapitate(message, header_re=regex.compile( '\(\(' '[^\0- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), #r'(([^\0- <>:]+:[^\n]*\n|[ \t]+[^\0- ][^\n]*\n)+)[ \t]*\n([\0-\377]+)' space_re=regex.compile('\([ \t]+\)'), name_re=regex.compile('\([^\0- <>:]+\):\([^\n]*\)'), ): if header_re.match(message) < 0: return message headers, body = header_re.group(1,3) headers=string.split(headers,'\n') headerDict={} i=1 while i < len(headers): if not headers[i]: del headers[i] elif space_re.match(headers[i]) >= 0: headers[i-1]="%s %s" % (headers[i-1], headers[i][len(space_re.group(1)):]) del headers[i] else: i=i+1 for i in range(len(headers)): if name_re.match(headers[i]) >= 0: k, v = name_re.group(1,2) k=string.lower(k); v=string.strip(v) headerDict[k]=v else: raise ValueError, 'Invalid Header (%d): %s ' % (i,headers[i]) if headerDict.has_key('to'): headerDict['to']=map( lambda x: string.strip(x), string.split(headerDict['to'], ',') ) return (headerDict, body)
3,345
def check_zglobals(self): if not doInstall(): return
def check_zglobals(self): if not doInstall(): return
3,346
def __of__(self, parent): return parent.pt_macros()
def __of__(self, parent): return parent.pt_macros()
3,347
def _getOb(self, id, default=_marker): if hasattr(self, 'aq_base'): self=self.aq_base if default is _marker: return getattr(self, id) try: return getattr(self, id) except: return default
def _getOb(self, id, default=_marker): if hasattr(self, 'aq_base'): self=self.aq_base if default is _marker: return getattr(self, id) try: return getattr(self, id) except: return default
3,348
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,349
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
3,350
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
3,351
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
3,352
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
3,353
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,354
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,355
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp s=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < s: oid, ldata = unpack(">8sI", read(12)) data=read(ldata)
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp s=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < s: oid, ldata = unpack(">8sI", read(12)) data=read(ldata)
3,356
def render(self, md): name=self.__name__ args=self.args t=args['type'] try: expr=self.expr if type(expr) is type(''): v=md[expr] else: v=expr(md) except: if args.has_key('optional') and args['optional']: return 'null' raise 'Missing Input', 'Missing input variable, <em>%s</em>' % name
def render(self, md): name=self.__name__ args=self.args t=args['type'] try: expr=self.expr if type(expr) is type(''): v=md[expr] else: v=expr(md) except: if args.has_key('optional') and args['optional']: return 'null' raise 'Missing Input', 'Missing input variable, <em>%s</em>' % name
3,357
def render(self, md): args=self.args have_arg=args.has_key name=self.__name__
def render(self, md): args=self.args have_arg=args.has_key name=self.__name__
3,358
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0, args=None): have_arg=args.has_key try: items=self.tpValues() except: items=None if not items and have_arg('leaves'): items=1 tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: treeData['tree-item-expanded']=1 del substate[exp-1] output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] output('</TD>\n') else: level=level+1 if level > 3: output('<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD COLSPAN="%s" VALIGN="TOP">' % dataspan) output(section(self, md)) output('</TD>\n</TR>\n') if exp: level=level+1 if level > 2: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): if md.has_key(args['header']): output(md.getitem(args['header'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) if items==1: # leaves treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['leaves'],0)( self,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) md._pop(1) elif have_arg('expand'): treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['expand'],0)(self,md)) md._pop(1) else: __traceback_info__=sub, args, state, substate for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level, args) if not sub[1]: del sub[1] if have_arg('footer'): if md.has_key(args['footer']): output(md.getitem(args['footer'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) return data
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0, args=None): have_arg=args.has_key try: items=self.tpValues() except: items=None if not items and have_arg('leaves'): items=1 tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: treeData['tree-item-expanded']=1 del substate[exp-1] output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] output('</TD>\n') else: if level > 3: output('<TD COLSPAN="%s"></TD>' % level) elif level > 1: output('<TD></TD>' * level) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD COLSPAN="%s" VALIGN="TOP">' % dataspan) output(section(self, md)) output('</TD>\n</TR>\n') if exp: level=level+1 if level > 2: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): if md.has_key(args['header']): output(md.getitem(args['header'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) if items==1: # leaves treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['leaves'],0)( self,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) md._pop(1) elif have_arg('expand'): treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['expand'],0)(self,md)) md._pop(1) else: __traceback_info__=sub, args, state, substate for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level, args) if not sub[1]: del sub[1] if have_arg('footer'): if md.has_key(args['footer']): output(md.getitem(args['footer'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) return data
3,359
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0, args=None): have_arg=args.has_key try: items=self.tpValues() except: items=None if not items and have_arg('leaves'): items=1 tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: treeData['tree-item-expanded']=1 del substate[exp-1] output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] output('</TD>\n') else: level=level+1 if level > 3: output('<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD COLSPAN="%s" VALIGN="TOP">' % dataspan) output(section(self, md)) output('</TD>\n</TR>\n') if exp: level=level+1 if level > 2: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): if md.has_key(args['header']): output(md.getitem(args['header'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) if items==1: # leaves treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['leaves'],0)( self,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) md._pop(1) elif have_arg('expand'): treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['expand'],0)(self,md)) md._pop(1) else: __traceback_info__=sub, args, state, substate for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level, args) if not sub[1]: del sub[1] if have_arg('footer'): if md.has_key(args['footer']): output(md.getitem(args['footer'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) return data
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0, args=None): have_arg=args.has_key try: items=self.tpValues() except: items=None if not items and have_arg('leaves'): items=1 tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: treeData['tree-item-expanded']=1 del substate[exp-1] output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] output('</TD>\n') else: level=level+1 if level > 3: output('<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD%s VALIGN="TOP">' % (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or '')) output(section(self, md)) output('</TD>\n</TR>\n') if exp: level=level+1 if level > 2: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): if md.has_key(args['header']): output(md.getitem(args['header'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) if items==1: # leaves treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['leaves'],0)( self,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) md._pop(1) elif have_arg('expand'): treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['expand'],0)(self,md)) md._pop(1) else: __traceback_info__=sub, args, state, substate for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level, args) if not sub[1]: del sub[1] if have_arg('footer'): if md.has_key(args['footer']): output(md.getitem(args['footer'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) return data
3,360
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0, args=None): have_arg=args.has_key try: items=self.tpValues() except: items=None if not items and have_arg('leaves'): items=1 tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: treeData['tree-item-expanded']=1 del substate[exp-1] output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] output('</TD>\n') else: level=level+1 if level > 3: output('<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD COLSPAN="%s" VALIGN="TOP">' % dataspan) output(section(self, md)) output('</TD>\n</TR>\n') if exp: level=level+1 if level > 2: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): if md.has_key(args['header']): output(md.getitem(args['header'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) if items==1: # leaves treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['leaves'],0)( self,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) md._pop(1) elif have_arg('expand'): treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['expand'],0)(self,md)) md._pop(1) else: __traceback_info__=sub, args, state, substate for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level, args) if not sub[1]: del sub[1] if have_arg('footer'): if md.has_key(args['footer']): output(md.getitem(args['footer'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) return data
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0, args=None): have_arg=args.has_key try: items=self.tpValues() except: items=None if not items and have_arg('leaves'): items=1 tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: treeData['tree-item-expanded']=1 del substate[exp-1] output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] output('</TD>\n') else: level=level+1 if level > 3: output('<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD COLSPAN="%s" VALIGN="TOP">' % dataspan) output(section(self, md)) output('</TD>\n</TR>\n') if exp: level=level+1 dataspan=colspan-level if level > 3: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): if md.has_key(args['header']): output(md.getitem(args['header'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) if items==1: # leaves treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['leaves'],0)( self,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) md._pop(1) elif have_arg('expand'): treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['expand'],0)(self,md)) md._pop(1) else: __traceback_info__=sub, args, state, substate for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level, args) if not sub[1]: del sub[1] if have_arg('footer'): if md.has_key(args['footer']): output(md.getitem(args['footer'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) return data
3,361
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0, args=None): have_arg=args.has_key try: items=self.tpValues() except: items=None if not items and have_arg('leaves'): items=1 tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: treeData['tree-item-expanded']=1 del substate[exp-1] output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] output('</TD>\n') else: level=level+1 if level > 3: output('<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD COLSPAN="%s" VALIGN="TOP">' % dataspan) output(section(self, md)) output('</TD>\n</TR>\n') if exp: level=level+1 if level > 2: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): if md.has_key(args['header']): output(md.getitem(args['header'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) if items==1: # leaves treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['leaves'],0)( self,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) md._pop(1) elif have_arg('expand'): treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['expand'],0)(self,md)) md._pop(1) else: __traceback_info__=sub, args, state, substate for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level, args) if not sub[1]: del sub[1] if have_arg('footer'): if md.has_key(args['footer']): output(md.getitem(args['footer'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) return data
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0, args=None): have_arg=args.has_key try: items=self.tpValues() except: items=None if not items and have_arg('leaves'): items=1 tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: treeData['tree-item-expanded']=1 del substate[exp-1] output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] output('</TD>\n') else: level=level+1 if level > 3: output('<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD COLSPAN="%s" VALIGN="TOP">' % dataspan) output(section(self, md)) output('</TD>\n</TR>\n') if exp: level=level+1 if level > 2: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): if md.has_key(args['header']): output(md.getitem(args['header'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) if items==1: # leaves treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['leaves'],0)( self,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) md._pop(1) elif have_arg('expand'): treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['expand'],0)(self,md)) md._pop(1) else: __traceback_info__=sub, args, state, substate for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level, args) if not sub[1]: del sub[1] if have_arg('footer'): if md.has_key(args['footer']): output(md.getitem(args['footer'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) return data
3,362
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0, args=None): have_arg=args.has_key try: items=self.tpValues() except: items=None if not items and have_arg('leaves'): items=1 tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: treeData['tree-item-expanded']=1 del substate[exp-1] output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] output('</TD>\n') else: level=level+1 if level > 3: output('<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD COLSPAN="%s" VALIGN="TOP">' % dataspan) output(section(self, md)) output('</TD>\n</TR>\n') if exp: level=level+1 if level > 2: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): if md.has_key(args['header']): output(md.getitem(args['header'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) if items==1: # leaves treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['leaves'],0)( self,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) md._pop(1) elif have_arg('expand'): treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['expand'],0)(self,md)) md._pop(1) else: __traceback_info__=sub, args, state, substate for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level, args) if not sub[1]: del sub[1] if have_arg('footer'): if md.has_key(args['footer']): output(md.getitem(args['footer'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) return data
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0, args=None): have_arg=args.has_key try: items=self.tpValues() except: items=None if not items and have_arg('leaves'): items=1 tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: treeData['tree-item-expanded']=1 del substate[exp-1] output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] output('</TD>\n') else: level=level+1 if level > 3: output('<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD COLSPAN="%s" VALIGN="TOP">' % dataspan) output(section(self, md)) output('</TD>\n</TR>\n') if exp: level=level+1 if level > 2: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): if md.has_key(args['header']): output(md.getitem(args['header'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) if items==1: # leaves treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['leaves'],0)( self,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) md._pop(1) elif have_arg('expand'): treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['expand'],0)(self,md)) md._pop(1) else: __traceback_info__=sub, args, state, substate for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level, args) if not sub[1]: del sub[1] if have_arg('footer'): if md.has_key(args['footer']): output(md.getitem(args['footer'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) return data
3,363
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0, args=None): have_arg=args.has_key try: items=self.tpValues() except: items=None if not items and have_arg('leaves'): items=1 tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: treeData['tree-item-expanded']=1 del substate[exp-1] output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] output('</TD>\n') else: level=level+1 if level > 3: output('<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD COLSPAN="%s" VALIGN="TOP">' % dataspan) output(section(self, md)) output('</TD>\n</TR>\n') if exp: level=level+1 if level > 2: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): if md.has_key(args['header']): output(md.getitem(args['header'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) if items==1: # leaves treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['leaves'],0)( self,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) md._pop(1) elif have_arg('expand'): treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['expand'],0)(self,md)) md._pop(1) else: __traceback_info__=sub, args, state, substate for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level, args) if not sub[1]: del sub[1] if have_arg('footer'): if md.has_key(args['footer']): output(md.getitem(args['footer'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD COLSPAN="%s" VALIGN="TOP">' % (h, dataspan-1)), standard_html_footer='</TD></TR>', )) return data
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0, args=None): have_arg=args.has_key try: items=self.tpValues() except: items=None if not items and have_arg('leaves'): items=1 tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url treeData['tree-level']=level treeData['tree-item-expanded']=0 try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<TR>\n') # Add +/- icon if items: if level: if level > 3: output( '<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') output('<TD WIDTH="16" VALIGN="TOP">') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: treeData['tree-item-expanded']=1 del substate[exp-1] output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?tree-state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] output('</TD>\n') else: level=level+1 if level > 3: output('<TD COLSPAN="%s"></TD>' % (level-1)) elif level > 1: output('<TD></TD>' * (level-1)) output('<TD WIDTH="16"></TD>\n') # add item text dataspan=colspan-level output('<TD COLSPAN="%s" VALIGN="TOP">' % dataspan) output(section(self, md)) output('</TD>\n</TR>\n') if exp: level=level+1 if level > 2: h='<TD COLSPAN="%s"></TD>' % (level-1) elif level > 1: h='<TD></TD>' * (level-1) else: h='' if have_arg('header'): if md.has_key(args['header']): output(md.getitem(args['header'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) if items==1: # leaves treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['leaves'],0)( self,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) md._pop(1) elif have_arg('expand'): treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['expand'],0)(self,md)) md._pop(1) else: __traceback_info__=sub, args, state, substate for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level, args) if not sub[1]: del sub[1] if have_arg('footer'): if md.has_key(args['footer']): output(md.getitem(args['footer'],0)( self, md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) return data
3,364
def import_products(): # Try to import each product, checking for and catching errors. path_join=os.path.join product_dir=path_join(SOFTWARE_HOME,'Products') isdir=os.path.isdir exists=os.path.exists DictType=type({}) product_names=os.listdir(product_dir) product_names.sort() global_dict=globals() silly=('__doc__',) 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 pname="Products.%s" % product_name try: product=__import__(pname, global_dict, global_dict, silly) if hasattr(product, '__module_aliases__'): for k, v in product.__aliases__: if not sys.modules.has_key(k): sys.modules[k]=v except: f=StringIO() traceback.print_exc(100,f) f=f.getvalue() try: sys.modules[pname].__import_error__=f except: pass
def import_products(): # Try to import each product, checking for and catching errors. path_join=os.path.join product_dir=path_join(SOFTWARE_HOME,'Products') isdir=os.path.isdir exists=os.path.exists DictType=type({}) product_names=os.listdir(product_dir) product_names.sort() global_dict=globals() silly=('__doc__',) 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 pname="Products.%s" % product_name try: product=__import__(pname, global_dict, global_dict, silly) if hasattr(product, '__module_aliases__'): for k, v in product.__module_aliases__: if not sys.modules.has_key(k): sys.modules[k]=v except: f=StringIO() traceback.print_exc(100,f) f=f.getvalue() try: sys.modules[pname].__import_error__=f except: pass
3,365
def _delObject(self,id): # Ick! This is necessary to deal with spaces. Waaa! id=strip(id) if id=='acl_users': if hasattr(self, '__allow_groups__') and \ self.__dict__.has_key('__allow_groups__'): delattr(self, '__allow_groups__')
def _delObject(self, id, dp=1): # Ick! This is necessary to deal with spaces. Waaa! id=strip(id) if id=='acl_users': if hasattr(self, '__allow_groups__') and \ self.__dict__.has_key('__allow_groups__'): delattr(self, '__allow_groups__')
3,366
def _validateProxy(self, request, roles=None): if roles is None: roles=self._proxy_roles if not roles: return user=u=request.get('AUTHENTICATED_USER',None) if user is not None: user=user.hasRole for r in roles: if r and not user(None, (r,)): user=None break
def _validateProxy(self, request, roles=None): if roles is None: roles=self._proxy_roles if not roles: return user=u=request.get('AUTHENTICATED_USER',None) if user is not None: user=user.hasRole for r in roles: if r and not user(self, (r,)): user=None break
3,367
def domainSpecValidate(spec):
def domainSpecValidate(spec):
3,368
def sort(sequence, sort=(), _=None, mapping=0): """ - sequence is a sequence of objects to be sorted - sort is a sequence of tuples (key,func,direction) that define the sort order: - key is the name of an attribute to sort the objects by - func is the name of a comparison function. This parameter is optional allowed values: - "cmp" -- the standard comparison function (default) - "nocase" -- case-insensitive comparison - "strcoll" or "locale" -- locale-aware string comparison - "strcoll_nocase" or "locale_nocase" -- locale-aware case-insensitive string comparison - "xxx" -- a user-defined comparison function - direction -- defines the sort direction for the key (optional). (allowed values: "asc" (default) , "desc") """ need_sortfunc = 0 if sort: for s in sort: if len(s) > 1: # extended sort if there is reference to... # ...comparison function or sort order, even if they are "cmp" and "asc" need_sortfunc = 1 break sortfields = sort # multi sort = key1,key2 multsort = len(sortfields) > 1 # flag: is multiple sort if need_sortfunc: # prepare the list of functions and sort order multipliers sf_list = make_sortfunctions(sortfields, _) # clean the mess a bit if multsort: # More than one sort key. sortfields = map(lambda x: x[0], sf_list) else: sort = sf_list[0][0] elif sort: if multsort: # More than one sort key. sortfields = map(lambda x: x[0], sort) else: sort = sort[0][0] isort=not sort s=[] for client in sequence: k = None if type(client)==TupleType and len(client)==2: if isort: k=client[0] v=client[1] else: if isort: k=client v=client if sort: if multsort: # More than one sort key. k = [] for sk in sortfields: try: if mapping: akey = v[sk] else: akey = getattr(v, sk) except (AttributeError, KeyError): akey = None if not basic_type(akey): try: akey = akey() except: pass k.append(akey) else: # One sort key. try: if mapping: k = v[sort] else: k = getattr(v, sort) except (AttributeError, KeyError): k = None if not basic_type(type(k)): try: k = k() except: pass s.append((k,client)) if need_sortfunc: by = SortBy(multsort, sf_list) s.sort(by) else: s.sort() sequence=[] for k, client in s: sequence.append(client) return sequence
def sort(sequence, sort=(), _=None, mapping=0): """ - sequence is a sequence of objects to be sorted - sort is a sequence of tuples (key,func,direction) that define the sort order: - key is the name of an attribute to sort the objects by - func is the name of a comparison function. This parameter is optional allowed values: - "cmp" -- the standard comparison function (default) - "nocase" -- case-insensitive comparison - "strcoll" or "locale" -- locale-aware string comparison - "strcoll_nocase" or "locale_nocase" -- locale-aware case-insensitive string comparison - "xxx" -- a user-defined comparison function - direction -- defines the sort direction for the key (optional). (allowed values: "asc" (default) , "desc") """ need_sortfunc = 0 if sort: for s in sort: if len(s) > 1: # extended sort if there is reference to... # ...comparison function or sort order, even if they are "cmp" and "asc" need_sortfunc = 1 break sortfields = sort # multi sort = key1,key2 multsort = len(sortfields) > 1 # flag: is multiple sort if need_sortfunc: # prepare the list of functions and sort order multipliers sf_list = make_sortfunctions(sortfields, _) # clean the mess a bit if multsort: # More than one sort key. sortfields = map(lambda x: x[0], sf_list) else: sort = sf_list[0][0] elif sort: if multsort: # More than one sort key. sortfields = map(lambda x: x[0], sort) else: sort = sort[0][0] isort=not sort s=[] for client in sequence: k = None if type(client)==TupleType and len(client)==2: if isort: k=client[0] v=client[1] else: if isort: k=client v=client if sort: if multsort: # More than one sort key. k = [] for sk in sortfields: try: if mapping: akey = v[sk] else: akey = getattr(v, sk) except (AttributeError, KeyError): akey = None if not basic_type(type(akey)): try: akey = akey() except: pass k.append(akey) else: # One sort key. try: if mapping: k = v[sort] else: k = getattr(v, sort) except (AttributeError, KeyError): k = None if not basic_type(type(k)): try: k = k() except: pass s.append((k,client)) if need_sortfunc: by = SortBy(multsort, sf_list) s.sort(by) else: s.sort() sequence=[] for k, client in s: sequence.append(client) return sequence
3,369
def wl_clearLocks(self): # Called by lock management machinery to quickly and effectively # destroy all locks. locks = self.wl_lockmapping() locks.clear() if hasattr(Acquisition.aq_base(self), '__no_valid_write_locks__'): self.__no_valid_write_locks__()
def wl_clearLocks(self): # Called by lock management machinery to quickly and effectively # destroy all locks. try: locks = self.wl_lockmapping() locks.clear() except: if hasattr(self, '_dav_writelocks'): del self._dav_writelocks if WriteLockInterface.isImplementedBy(self): self._dav_writelocks = PersistentMapping() if hasattr(Acquisition.aq_base(self), '__no_valid_write_locks__'): self.__no_valid_write_locks__()
3,370
def render(self, md):
def render(self, md):
3,371
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
3,372
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
3,373
def __init__(self,
def __init__(self,
3,374
def __init__(self,
def if environ.has_key('HTTP_COOKIE'): d=parse_cookie(self.environ['HTTP_COOKIE']) for k in d.keys(): if not form.has_key(k): form[k]=d[k] __init__(self,
3,375
def guarded_getitem(object, index): if type(index) is SliceType: if index.step is not None: v = object[index] else: start = index.start stop = index.stop if start is None: start = 0 if stop is None: v = object[start:] else: v = object[start:stop] # We don't guard slices. return v v = object[index] if Containers(type(object)): # Simple type. Short circuit. return v if getSecurityManager().validate(object, object, index, v): return v raise Unauthorized, 'unauthorized access to element %s' % `i`
def guarded_getitem(object, index): if type(index) is SliceType: if index.step is not None: v = object[index] else: start = index.start stop = index.stop if start is None: start = 0 if stop is None: v = object[start:] else: v = object[start:stop] # We don't guard slices. return v v = object[index] if Containers(type(object)) and Containers(type(v)): # Simple type. Short circuit. return v if getSecurityManager().validate(object, object, index, v): return v raise Unauthorized, 'unauthorized access to element %s' % `i`
3,376
def delPropertySheet(self, name): result=[] for propset in self.aq_parent.__propsets__: if propset.getId() != name and propset.xml_namespace() != name: result.append(propset) self.parent.__propsets__=tuple(result)
def delPropertySheet(self, name): result=[] for propset in self.aq_parent.__propsets__: if propset.getId() != name and propset.xml_namespace() != name: result.append(propset) self.parent.__propsets__=tuple(result)
3,377
def __init__(self, stdin, environ, response, clean=0, # "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_]+$' ).search, rfind=string.rfind, ): # 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.
def __init__(self, stdin, environ, response, clean=0, # "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_]+$' ).search, rfind=string.rfind, ): # 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.
3,378
def __init__(self, stdin, environ, response, clean=0, # "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_]+$' ).search, rfind=string.rfind, ): # 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.
def __init__(self, stdin, environ, response, clean=0, # "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_]+$' ).search, rfind=string.rfind, ): # 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.
3,379
def __init__(self, stdin, environ, response, clean=0, # "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_]+$' ).search, rfind=string.rfind, ): # 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.
def __init__(self, stdin, environ, response, clean=0, # "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_]+$' ).search, rfind=string.rfind, ): # 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.
3,380
def __init__(self, stdin, environ, response, clean=0, # "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_]+$' ).search, rfind=string.rfind, ): # 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.
def __init__(self, stdin, environ, response, clean=0, # "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_]+$' ).search, rfind=string.rfind, ): # 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.
3,381
def __init__(self, id, title): self.id=id self.title=title self._setObject('Help', ProductHelp('Help', '%s Help' % id))
def __init__(self, id, title): self.id=id self.title=title self._setObject('Help', ProductHelp('Help', id))
3,382
def getProductHelp(self): """ Returns the ProductHelp object associated with the Product. """ if not hasattr(self, 'Help'): self._setObject('Help', ProductHelp('Help', '%s Help' % self.id)) return self.Help
def getProductHelp(self): """ Returns the ProductHelp object associated with the Product. """ if not hasattr(self, 'Help'): self._setObject('Help', ProductHelp('Help', self.id)) return self.Help
3,383
def initializeProduct(productp, name, home, app): # Initialize a levered product products=app.Control_Panel.Products if hasattr(productp, '__import_error__'): ie=productp.__import_error__ else: ie=None try: fver=strip(open(home+'/version.txt').read()) except: fver='' old=None try: if ihasattr(products,name): old=getattr(products, name) if (ihasattr(old,'version') and old.version==fver and hasattr(old, 'import_error_') and old.import_error_==ie): return old except: pass try: f=CompressedInputFile(open(home+'/product.dat','rb'),name+' shshsh') except: f=fver and (" (%s)" % fver) product=Product(name, 'Installed product %s%s' % (name,f)) else: meta=cPickle.Unpickler(f).load() product=app._p_jar.importFile(f) product._objects=meta['_objects'] if old is not None: app._manage_remove_product_meta_type(product) products._delObject(name) for id, v in old.objectValues(): try: product._setObject(id, v) except: pass products._setObject(name, product) #product.__of__(products)._postCopy(products) product.manage_options=Folder.manage_options product.icon='p_/InstalledProduct_icon' product.version=fver product._distribution=None product.manage_distribution=None product.thisIsAnInstalledProduct=1 if ie: product.import_error_=ie product.title='Broken product %s' % name product.icon='p_/BrokenProduct_icon' product.manage_options=( {'label':'Traceback', 'action':'manage_traceback'}, ) if os.path.exists(os.path.join(home, 'README.txt')): product.manage_options=product.manage_options+( {'label':'README', 'action':'manage_readme'}, ) return product
def initializeProduct(productp, name, home, app): # Initialize a levered product products=app.Control_Panel.Products if hasattr(productp, '__import_error__'): ie=productp.__import_error__ else: ie=None try: fver=strip(open(home+'/version.txt').read()) except: fver='' old=None try: if ihasattr(products,name): old=getattr(products, name) if (ihasattr(old,'version') and old.version==fver and hasattr(old, 'import_error_') and old.import_error_==ie): return old except: pass try: f=CompressedInputFile(open(home+'/product.dat','rb'),name+' shshsh') except: f=fver and (" (%s)" % fver) product=Product(name, 'Installed product %s%s' % (name,f)) else: meta=cPickle.Unpickler(f).load() product=app._p_jar.importFile(f) product._objects=meta['_objects'] if old is not None: app._manage_remove_product_meta_type(product) products._delObject(name) for id, v in old.objectItems(): try: product._setObject(id, v) except: pass products._setObject(name, product) #product.__of__(products)._postCopy(products) product.manage_options=Folder.manage_options product.icon='p_/InstalledProduct_icon' product.version=fver product._distribution=None product.manage_distribution=None product.thisIsAnInstalledProduct=1 if ie: product.import_error_=ie product.title='Broken product %s' % name product.icon='p_/BrokenProduct_icon' product.manage_options=( {'label':'Traceback', 'action':'manage_traceback'}, ) if os.path.exists(os.path.join(home, 'README.txt')): product.manage_options=product.manage_options+( {'label':'README', 'action':'manage_readme'}, ) return product
3,384
def meta_type(self): try: return self.aq_parent.aq_parent.meta_type except: return ''
def meta_type(self): try: return self.aq_parent.aq_parent.meta_type except: return ''
3,385
def index_html(self, REQUEST=None): ''' Getting the formatted text ''' REQUEST.RESPONSE.setHeader('content-type', 'text/html; charset: %s' % self.output_encoding) return self.formatted
def index_html(self, REQUEST=None): ''' Getting the formatted text ''' REQUEST.RESPONSE.setHeader('content-type', 'text/html; charset=%s' % self.output_encoding) return self.formatted
3,386
def source_txt(self, REQUEST=None): ''' Getting the source text ''' REQUEST.RESPONSE.setHeader('content-type', 'text/plain; charset: %s' % self.input_encoding) return self.source
def source_txt(self, REQUEST=None): ''' Getting the source text ''' REQUEST.RESPONSE.setHeader('content-type', 'text/plain; charset=%s' % self.input_encoding) return self.source
3,387
def _construct(self, context, id, final): """Creates and returns the named folder.""" dispatcher = guarded_getattr(context, 'manage_addProduct')['OFSP'] factory = guarded_getattr(dispatcher, 'manage_addFolder') factory(id) o = context.restrictedTraverse(id) # Commit a subtransaction to assign the new object to # the correct database. transaction.commit(1) return o
def _construct(self, context, id): """Creates and returns the named folder.""" dispatcher = guarded_getattr(context, 'manage_addProduct')['OFSP'] factory = guarded_getattr(dispatcher, 'manage_addFolder') factory(id) o = context.restrictedTraverse(id) # Commit a subtransaction to assign the new object to # the correct database. transaction.commit(1) return o
3,388
def ZCacheable_get(self, view_name='', keywords=None, mtime_func=None, default=None): '''Retrieves the cached view for the object under the conditions specified by keywords. If the value is not yet cached, returns the default. ''' c = self.ZCacheable_getCache() if c is not None and self.__enabled: ob, view_name = self.ZCacheable_getObAndView(view_name) try: val = c.ZCache_get(ob, view_name, keywords, mtime_func, default) return val except: logger.warn('ZCache_get() exception', exc_info=sys.exc_info()) return default return default
def ZCacheable_get(self, view_name='', keywords=None, mtime_func=None, default=None): '''Retrieves the cached view for the object under the conditions specified by keywords. If the value is not yet cached, returns the default. ''' c = self.ZCacheable_getCache() if c is not None and self.__enabled: ob, view_name = self.ZCacheable_getObAndView(view_name) try: val = c.ZCache_get(ob, view_name, keywords, mtime_func, default) return val except: logger.warn('ZCache_get() exception', exc_info=True) return default return default
3,389
def ZCacheable_set(self, data, view_name='', keywords=None, mtime_func=None): '''Cacheable views should call this method after generating cacheable results. The data argument can be of any Python type. ''' c = self.ZCacheable_getCache() if c is not None and self.__enabled: ob, view_name = self.ZCacheable_getObAndView(view_name) try: c.ZCache_set(ob, data, view_name, keywords, mtime_func) except: logger.warn('ZCache_set() exception', exc_info=sys.exc_info())
def ZCacheable_set(self, data, view_name='', keywords=None, mtime_func=None): '''Cacheable views should call this method after generating cacheable results. The data argument can be of any Python type. ''' c = self.ZCacheable_getCache() if c is not None and self.__enabled: ob, view_name = self.ZCacheable_getObAndView(view_name) try: c.ZCache_set(ob, data, view_name, keywords, mtime_func) except: logger.warn('ZCache_set() exception', exc_info=sys.exc_info())
3,390
def ZCacheable_invalidate(self, view_name='', REQUEST=None): '''Called after a cacheable object is edited. Causes all cache entries that apply to the view_name to be removed. Returns a status message. ''' c = self.ZCacheable_getCache() if c is not None: ob, view_name = self.ZCacheable_getObAndView(view_name) try: message = c.ZCache_invalidate(ob) if not message: message = 'Invalidated.' except: exc = sys.exc_info() try: logger.warn('ZCache_invalidate() exception', exc_info=exc) message = 'An exception occurred: %s: %s' % exc[:2] finally: exc = None else: message = 'This object is not associated with a cache manager.' if REQUEST is not None: return self.ZCacheable_manage( self, REQUEST, management_view='Cache', manage_tabs_message=message) else: return message
def ZCacheable_invalidate(self, view_name='', REQUEST=None): '''Called after a cacheable object is edited. Causes all cache entries that apply to the view_name to be removed. Returns a status message. ''' c = self.ZCacheable_getCache() if c is not None: ob, view_name = self.ZCacheable_getObAndView(view_name) try: message = c.ZCache_invalidate(ob) if not message: message = 'Invalidated.' except: exc = sys.exc_info() try: logger.warn('ZCache_invalidate() exception', exc_info=True) message = 'An exception occurred: %s: %s' % exc[:2] finally: exc = None else: message = 'This object is not associated with a cache manager.' if REQUEST is not None: return self.ZCacheable_manage( self, REQUEST, management_view='Cache', manage_tabs_message=message) else: return message
3,391
def __init__(self): # Initialize users self.__allow_groups__=UserFolder() self._setObject('acl_users', self.__allow_groups__)
def __init__(self): # Initialize users self.__allow_groups__=UserFolder() self._setObject('acl_users', self.__allow_groups__)
3,392
def domainSpecMatch(spec, request): if request.has_key('REMOTE_HOST'): host=request['REMOTE_HOST'] else: host='' if request.has_key('REMOTE_ADDR'): addr=request['REMOTE_ADDR'] else: addr='' if not host and not addr: return 0 if not host: host=socket.gethostbyaddr(addr)[0] if not addr: addr=socket.gethostbyname(host) _host=split(host, '.') _addr=split(addr, '.') _hlen=len(_host) _alen=len(_addr) for ob in spec: sz=len(ob) _ob=split(ob, '.') _sz=len(_ob) if addr_match(ob)==sz: if _sz != _alen: continue fail=0 for i in range(_sz): a=_addr[i] o=_ob[i] if (o != a) and (o != '*'): fail=1 break if fail: continue return 1 if host_match(ob)==sz: if _hlen < _sz: continue elif _hlen > _sz: _item=_host[-_sz:] else: _item=_host fail=0 for i in range(_sz): h=_item[i] o=_ob[i] if (o != h) and (o != '*'): fail=1 break if fail: continue return 1 return 0
def domainSpecMatch(spec, request): if request.has_key('REMOTE_HOST'): host=request['REMOTE_HOST'] else: host='' if request.has_key('REMOTE_ADDR'): addr=request['REMOTE_ADDR'] else: addr='' if not host and not addr: return 0 if not host: try: host=socket.gethostbyaddr(addr)[0] except: pass if not addr: addr=socket.gethostbyname(host) _host=split(host, '.') _addr=split(addr, '.') _hlen=len(_host) _alen=len(_addr) for ob in spec: sz=len(ob) _ob=split(ob, '.') _sz=len(_ob) if addr_match(ob)==sz: if _sz != _alen: continue fail=0 for i in range(_sz): a=_addr[i] o=_ob[i] if (o != a) and (o != '*'): fail=1 break if fail: continue return 1 if host_match(ob)==sz: if _hlen < _sz: continue elif _hlen > _sz: _item=_host[-_sz:] else: _item=_host fail=0 for i in range(_sz): h=_item[i] o=_ob[i] if (o != h) and (o != '*'): fail=1 break if fail: continue return 1 return 0
3,393
def domainSpecMatch(spec, request): if request.has_key('REMOTE_HOST'): host=request['REMOTE_HOST'] else: host='' if request.has_key('REMOTE_ADDR'): addr=request['REMOTE_ADDR'] else: addr='' if not host and not addr: return 0 if not host: host=socket.gethostbyaddr(addr)[0] if not addr: addr=socket.gethostbyname(host) _host=split(host, '.') _addr=split(addr, '.') _hlen=len(_host) _alen=len(_addr) for ob in spec: sz=len(ob) _ob=split(ob, '.') _sz=len(_ob) if addr_match(ob)==sz: if _sz != _alen: continue fail=0 for i in range(_sz): a=_addr[i] o=_ob[i] if (o != a) and (o != '*'): fail=1 break if fail: continue return 1 if host_match(ob)==sz: if _hlen < _sz: continue elif _hlen > _sz: _item=_host[-_sz:] else: _item=_host fail=0 for i in range(_sz): h=_item[i] o=_ob[i] if (o != h) and (o != '*'): fail=1 break if fail: continue return 1 return 0
def domainSpecMatch(spec, request): if request.has_key('REMOTE_HOST'): host=request['REMOTE_HOST'] else: host='' if request.has_key('REMOTE_ADDR'): addr=request['REMOTE_ADDR'] else: addr='' if not host and not addr: return 0 if not host: host=socket.gethostbyaddr(addr)[0] if not addr: try: addr=socket.gethostbyname(host) except: pass _host=split(host, '.') _addr=split(addr, '.') _hlen=len(_host) _alen=len(_addr) for ob in spec: sz=len(ob) _ob=split(ob, '.') _sz=len(_ob) if addr_match(ob)==sz: if _sz != _alen: continue fail=0 for i in range(_sz): a=_addr[i] o=_ob[i] if (o != a) and (o != '*'): fail=1 break if fail: continue return 1 if host_match(ob)==sz: if _hlen < _sz: continue elif _hlen > _sz: _item=_host[-_sz:] else: _item=_host fail=0 for i in range(_sz): h=_item[i] o=_ob[i] if (o != h) and (o != '*'): fail=1 break if fail: continue return 1 return 0
3,394
def render(self, md):
def render(self, md):
3,395
def manage_test(self, REQUEST): """Test an SQL method.""" # Try to render the query template first so that the rendered # source will be available for the error message in case some # error occurs... try: src=self(REQUEST, src__=1) except: src="Could not render the query template!" result=() t=v=tb=None try: try: src, result=self(REQUEST, test__=1) if find(src,'\0'): src=join(split(src,'\0'),'\n'+'-'*60+'\n') if result._searchable_result_columns(): r=custom_default_report(self.id, result) else: r='This statement returned no results.' except: t, v, tb = sys.exc_info() r='<strong>Error, <em>%s</em>:</strong> %s' % (t, v)
def manage_test(self, REQUEST): """Test an SQL method.""" # Try to render the query template first so that the rendered # source will be available for the error message in case some # error occurs... try: src=self(REQUEST, src__=1) except: src="Could not render the query template!" result=() t=v=tb=None try: try: src, result=self(REQUEST, test__=1) if find(src,'\0'): src=join(split(src,'\0'),'\n'+'-'*60+'\n') if result._searchable_result_columns(): r=custom_default_report(self.id, result) else: r='This statement returned no results.' except: t, v, tb = sys.exc_info() r='<strong>Error, <em>%s</em>:</strong> %s' % (t, v)
3,396
def setupPublisher(self): import Globals import ZPublisher.Publish Globals.DevelopmentMode = self.cfg.debug_mode ZPublisher.Publish.set_default_debug_mode(self.cfg.debug_mode) ZPublisher.Publish.set_default_realm(self.cfg.http_realm)
def setupPublisher(self): import Globals import ZPublisher.Publish Globals.DevelopmentMode = self.cfg.debug_mode ZPublisher.Publish.set_default_debug_mode(self.cfg.debug_mode) ZPublisher.Publish.set_default_realm(self.cfg.http_realm)
3,397
def main(): import sys, os, getopt, string global repeat_count try: optlist,args=getopt.getopt(sys.argv[1:], 'dtu:p:r:e:s') if len(args) < 1 or len(args) > 2: raise TypeError, None elif len(args)==1: args=args[0],'/' path_info=args[1] except: sys.stderr.write(__doc__) sys.exit(-1) silent=profile=u=debug=timeit=None env={} for opt,val in optlist: if opt=='-d': debug=1 if opt=='-s': silent=1 if opt=='-t': timeit=1 if opt=='-u': u=val elif opt=='-p': profile=val elif opt=='-r': repeat_count=string.atoi(val) elif opt=='-e': opt=string.find(val,'=') if opt <= 0: raise 'Invalid argument to -e', val env[val[:opt]]=val[opt+1:] if (debug or 0)+(timeit or 0)+(profile and 1 or 0) > 1: raise 'Invalid options', 'only one of -p, -t, and -d are allowed' module=args[0] publish(module,path_info,u=u,p=profile,d=debug,t=timeit,e=env,s=silent)
def main(): import sys, os, getopt, string global repeat_count try: optlist,args=getopt.getopt(sys.argv[1:], 'dtu:p:r:e:s') if len(args) < 1 or len(args) > 2: raise TypeError, None elif len(args)==1: args=args[0],'/' path_info=args[1] except: sys.stderr.write(__doc__) sys.exit(-1) silent=profile=u=debug=timeit=None env={} for opt,val in optlist: if opt=='-d': debug=1 if opt=='-s': silent=1 if opt=='-t': timeit=1 if opt=='-u': u=val elif opt=='-p': profile=val elif opt=='-r': repeat_count=string.atoi(val) elif opt=='-e': opt=string.find(val,'=') if opt <= 0: raise 'Invalid argument to -e', val env[val[:opt]]=val[opt+1:] if (debug or 0)+(timeit or 0)+(profile and 1 or 0) > 1: raise 'Invalid options', 'only one of -p, -t, and -d are allowed' module=args[0] publish(module,path_info,u=u,p=profile,d=debug,t=timeit,e=env, s=silent)
3,398
def tag(self, height=None, width=None, alt=None, **args): """ Generate an HTML IMG tag for this image, with customization. Arguments to self.tag() can be any valid attributes of an IMG tag. 'src' will always be an absolute pathname, to prevent redundant downloading of images. Defaults are applied intelligently for 'height', 'width', and 'alt'. """ if not alt: alt=self.title_or_id()
def tag(self, height=None, width=None, alt=None, **args): """ Generate an HTML IMG tag for this image, with customization. Arguments to self.tag() can be any valid attributes of an IMG tag. 'src' will always be an absolute pathname, to prevent redundant downloading of images. Defaults are applied intelligently for 'height', 'width', and 'alt'. """ string='<img src="%s"' % (self.absolute_url()) if alt==None: alt=self.title_or_id()
3,399