bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def setCookie(self,name,value,**kw):
defsetCookie(self,name,value,**kw):
3,000
def _cookie_list(self):
def _cookie_list(self):
3,001
def _cookie_list(self):
def _cookie_list(self):
3,002
def _cookie_list(self):
def _cookie_list(self):
3,003
def _cookie_list(self):
def _cookie_list(self):
3,004
def doc_strong(self, s, expr = re.compile(r'\s*\*\*([ \na-zA-Z0-9.:/;\-,!\?\'\"]+)\*\*').search ):
def doc_strong(self, s, expr = re.compile(r'\s*\*\*([ \na-zA-Z0-9.:/;\-,!\?\'\"]+)\*\*').search ):
3,005
def render(ob): """ Calls the object, possibly a document template, or just returns it if not callable. (From DT_Util.py) """ base = aq_base(ob) if callable(base): try: if getattr(base, 'isDocTemp', 0): ob = ob(ob, ob.REQUEST) else: ob = ob() except AttributeError, n: if n != '__call__': raise return ob
def render(ob): """ Calls the object, possibly a document template, or just returns it if not callable. (From DT_Util.py) """ base = aq_base(ob) if callable(base): try: if getattr(base, 'isDocTemp', 0): ob = ob(ob, ob.REQUEST) else: ob = ob() except AttributeError, n: if str(n) != '__call__': raise return ob
3,006
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,007
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,008
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" 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=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,009
def get_earliest_file_data(files): temp = {} earliest_fromepoch = 0 earliest = None retn = None for file in files: line = file.readline() if not line: continue linelen = len(line) line = string.strip(line) tup = parsebigmlogline(line) if tup is None: print "Could not interpret line: %s" % line continue code, id, timestr, desc = tup timestr = string.strip(timestr) fromepoch = getdate(timestr) temp[file] = linelen if earliest_fromepoch == 0 or fromepoch < earliest_fromepoch: earliest_fromepoch = fromepoch earliest = file retn = [code, id, fromepoch, desc] for file, linelen in temp.items(): if file is not earliest: file.seek(file.tell() - linelen) return retn
def get_earliest_file_data(files): temp = {} earliest_fromepoch = 0 earliest = None retn = None for file in files: line = file.readline() if not line: continue linelen = len(line) line = string.strip(line) tup = parsebigmlogline(line) if tup is None: print "Could not interpret line: %s" % line continue code, id, timestr, desc = tup timestr = string.strip(timestr) fromepoch = getdate(timestr) temp[file] = linelen if earliest_fromepoch == 0 or fromepoch < earliest_fromepoch: earliest_fromepoch = fromepoch earliest = file retn = [code, id, fromepoch, desc] for file, linelen in temp.items(): if file is not earliest: file.seek(file.tell() - linelen) return retn
3,010
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) cumulative = cumulative.values() if mode == 'cumulative': dict = cumulative elif mode == 'detailed': dict = requests elif mode == 'timed': dict = requests else: raise "Invalid mode." if mode=='timed': if start and end: timewrite(requests,start,end,resolution) if start and not end: timewrite(requests,start,computed_end,resolution) if end and not start: timewrite(requests,computed_start,end,resolution) if not end and not start: timewrite(requests,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) cumulative = cumulative.values() if mode == 'cumulative': dict = cumulative elif mode == 'detailed': dict = requests elif mode == 'timed': dict = requests else: raise "Invalid mode." if mode=='timed': if start and end: timewrite(requests,start,end,resolution) if start and not end: timewrite(requests,start,computed_end,resolution) if end and not start: timewrite(requests,computed_start,end,resolution) if not end and not start: timewrite(requests,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
3,011
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) cumulative = cumulative.values() if mode == 'cumulative': dict = cumulative elif mode == 'detailed': dict = requests elif mode == 'timed': dict = requests else: raise "Invalid mode." if mode=='timed': if start and end: timewrite(requests,start,end,resolution) if start and not end: timewrite(requests,start,computed_end,resolution) if end and not start: timewrite(requests,computed_start,end,resolution) if not end and not start: timewrite(requests,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) requests = cumulative.values() requests.sort(sortf) write(requests, top) elif mode=='timed': computed_start = requests[0].start computed_end = requests[-1].t_end if start and end: timewrite(requests,start,end,resolution) if start and not end: timewrite(requests,start,computed_end,resolution) if end and not start: timewrite(requests,computed_start,end,resolution) if not end and not start: timewrite(requests,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
3,012
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) cumulative = cumulative.values() if mode == 'cumulative': dict = cumulative elif mode == 'detailed': dict = requests elif mode == 'timed': dict = requests else: raise "Invalid mode." if mode=='timed': if start and end: timewrite(requests,start,end,resolution) if start and not end: timewrite(requests,start,computed_end,resolution) if end and not start: timewrite(requests,computed_start,end,resolution) if not end and not start: timewrite(requests,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) cumulative = cumulative.values() if mode == 'cumulative': dict = cumulative elif mode == 'detailed': dict = requests elif mode == 'timed': dict = requests else: raise "Invalid mode." if mode=='timed': if start and end: timewrite(requests,start,end,resolution) if start and not end: timewrite(requests,start,computed_end,resolution) if end and not start: timewrite(requests,computed_start,end,resolution) if not end and not start: timewrite(requests,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
3,013
def timewrite(requests, start, end, resolution): max_requests = 0 print "Start: %s End: %s Resolution: %d secs" % \ (tick2str(start), tick2str(end), resolution) print "-" * 78 print print "Date/Time #requests requests/second" d = {} for r in requests: t = r.start slice = getTimeslice(resolution,t) if d.has_key(slice): d[slice] = d[slice] + 1 else: d[slice] = 1 num = 0 hits = 0 avg_requests = None slices = d.keys() slices.sort() for slice in slices: num = d[slice] if num>max_requests: max_requests = num hits = hits + num if avg_requests is None: avg_requests = num else: avg_requests = (avg_requests + num) / 2 s = tick2str(slice) s = s + " %6d %4.2lf" % (num,num*1.0/resolution) print s print '='*78 print " Peak: %6d %4.2lf" % \ (max_requests,max_requests*1.0/resolution) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits)
def timewrite(requests, start, end, resolution): print "Start: %s End: %s Resolution: %d secs" % \ (tick2str(start), tick2str(end), resolution) print "-" * 78 print print "Date/Time #requests requests/second" d = {} for r in requests: t = r.start slice = getTimeslice(resolution,t) if d.has_key(slice): d[slice] = d[slice] + 1 else: d[slice] = 1 num = 0 hits = 0 avg_requests = None slices = d.keys() slices.sort() for slice in slices: num = d[slice] if num>max_requests: max_requests = num hits = hits + num if avg_requests is None: avg_requests = num else: avg_requests = (avg_requests + num) / 2 s = tick2str(slice) s = s + " %6d %4.2lf" % (num,num*1.0/resolution) print s print '='*78 print " Peak: %6d %4.2lf" % \ (max_requests,max_requests*1.0/resolution) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits)
3,014
def timewrite(requests, start, end, resolution): max_requests = 0 print "Start: %s End: %s Resolution: %d secs" % \ (tick2str(start), tick2str(end), resolution) print "-" * 78 print print "Date/Time #requests requests/second" d = {} for r in requests: t = r.start slice = getTimeslice(resolution,t) if d.has_key(slice): d[slice] = d[slice] + 1 else: d[slice] = 1 num = 0 hits = 0 avg_requests = None slices = d.keys() slices.sort() for slice in slices: num = d[slice] if num>max_requests: max_requests = num hits = hits + num if avg_requests is None: avg_requests = num else: avg_requests = (avg_requests + num) / 2 s = tick2str(slice) s = s + " %6d %4.2lf" % (num,num*1.0/resolution) print s print '='*78 print " Peak: %6d %4.2lf" % \ (max_requests,max_requests*1.0/resolution) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits)
def timewrite(requests, start, end, resolution): max_requests = 0 print "Start: %s End: %s Resolution: %d secs" % \ (tick2str(start), tick2str(end), resolution) print "-" * 78 print print "Date/Time #requests requests/second" d = {} for r in requests: t = r.start slice = getTimeslice(resolution,t) if d.has_key(slice): d[slice] = d[slice] + 1 else: d[slice] = 1 num = 0 hits = 0 avg_requests = None max_requests = 0 for slice in range(min, max, resolution): num = d.get(slice, 0) if num>max_requests: max_requests = num hits = hits + num if avg_requests is None: avg_requests = num else: avg_requests = (avg_requests + num) / 2 s = tick2str(slice) s = s + " %6d %4.2lf" % (num,num*1.0/resolution) print s print '='*78 print " Peak: %6d %4.2lf" % \ (max_requests,max_requests*1.0/resolution) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits)
3,015
def detailedusage(): details = usage(0) pname = sys.argv[0] details = details + """
def detailedusage(): details = usage(0) pname = sys.argv[0] details = details + """
3,016
def detailedusage(): details = usage(0) pname = sys.argv[0] details = details + """
def detailedusage(): details = usage(0) pname = sys.argv[0] details = details + """
3,017
def detailedusage(): details = usage(0) pname = sys.argv[0] details = details + """
def detailedusage(): details = usage(0) pname = sys.argv[0] details = details + """
3,018
def usage(basic=1): usage = ( """
def usage(basic=1): usage = ( """
3,019
def usage(basic=1): usage = ( """
def usage(basic=1): usage = ( """
3,020
def usage(basic=1): usage = ( """
def usage(basic=1): usage = ( """
3,021
def usage(basic=1): usage = ( """
def usage(basic=1): usage = ( """
3,022
def usage(basic=1): usage = ( """
def usage(basic=1): usage = ( """
3,023
def usage(basic=1): usage = ( """
defusage(basic=1):usage=("""
3,024
def usage(basic=1): usage = ( """
defif opt=='--urlfocus': mode='urlfocus' urlfocusurl = val if opt=='--urlfocustime': urlfocustime=int(val) usage(basic=1):if opt=='--urlfocus': mode='urlfocus' urlfocusurl = val if opt=='--urlfocustime': urlfocustime=int(val) usageif opt=='--urlfocus': mode='urlfocus' urlfocusurl = val if opt=='--urlfocustime': urlfocustime=int(val) =if opt=='--urlfocus': mode='urlfocus' urlfocusurl = val if opt=='--urlfocustime': urlfocustime=int(val) (if opt=='--urlfocus': mode='urlfocus' urlfocusurl = val if opt=='--urlfocustime': urlfocustime=int(val) """
3,025
def usage(basic=1): usage = ( """
def usage(basic=1): usage = ( """
3,026
def usage(basic=1): usage = ( """
def usage(basic=1): usage = ( """
3,027
def _apply_index(self, request, cid=''):
def _apply_index(self, request, cid=''):
3,028
def __getitem__(self, key): # Hm, getattr didn't work, maybe this is a put: if key[:19]=='manage_draftFolder-': id=key[19:] if hasattr(self, id): return getattr(self, id).manage_supervisor() raise KeyError, key try: if self.REQUEST['REQUEST_METHOD']=='PUT': return PUTer(self,key) except: pass raise KeyError, key
def __getitem__(self, key): # Hm, getattr didn't work, maybe this is a put: if key[:19]=='manage_draftFolder-': id=key[19:] if hasattr(self, id): return getattr(self, id).manage_supervisor() raise KeyError, key try: if self.REQUEST['REQUEST_METHOD']=='PUT': return PUTer(self,key).__of__(self) except: pass raise KeyError, key
3,029
def manage_importHack(self, REQUEST=None): "Imports a previously exported object from /var/export.bbe" f=Globals.data_dir+'/export.bbe' o=self._p_jar.import_file(f) id=o.id if hasattr(id,'im_func'): id=id() self._setObject(id,o) return 'OK, I imported %s' % id
def manage_importHack(self, REQUEST=None): "Imports a previously exported object from /var/export.bbe" f=Globals.data_dir+'/export.bbe' o=self._p_jar.import_file(f) id=o.id if hasattr(id,'im_func'): id=id() self._setObject(id,o) return 'OK, I imported %s' % id
3,030
def PUT(self, REQUEST, BODY): """Adds a document, image or file to the folder when a PUT request is received.""" name=self._key try: type=REQUEST['CONTENT_TYPE'] except KeyError: type='' if not type: dot=rfind(name, '.') suf=dot > 0 and lower(name[dot+1:]) or '' if suf: try: type=content_type[suf] except KeyError: if find_binary(BODY) >= 0: type='application/x-%s' % suf else: type=text_type(BODY) else: if find_binary(BODY) >= 0: raise 'Bad Request', 'Could not determine file type' else: type=text_type(BODY) __traceback_info__=suf, dot, name, type if lower(type)=='text/html': return self._parent.manage_addDocument(name,'',BODY, REQUEST=REQUEST) if lower(type)[:6]=='image/': self._parent._setObject(name, Image(name, '', BODY, type)) else: self._parent._setObject(name, File(name, '', BODY, type)) return 'OK'
def PUT(self, REQUEST, BODY): """Adds a document, image or file to the folder when a PUT request is received.""" name=self._key try: type=REQUEST['CONTENT_TYPE'] except KeyError: type='' if not type: dot=rfind(name, '.') suf=dot > 0 and lower(name[dot+1:]) or '' if suf: try: type=content_type[suf] except KeyError: if find_binary(BODY) >= 0: type='application/x-%s' % suf else: type=text_type(BODY) else: if find_binary(BODY) >= 0: raise 'Bad Request', 'Could not determine file type' else: type=text_type(BODY) __traceback_info__=suf, dot, name, type if lower(type)[:5]=='text/': return self._parent.manage_addDocument(name,'',BODY, REQUEST=REQUEST) if lower(type)[:6]=='image/': self._parent._setObject(name, Image(name, '', BODY, type)) else: self._parent._setObject(name, File(name, '', BODY, type)) return 'OK'
3,031
def PUT(self, REQUEST, BODY): """Adds a document, image or file to the folder when a PUT request is received.""" name=self._key try: type=REQUEST['CONTENT_TYPE'] except KeyError: type='' if not type: dot=rfind(name, '.') suf=dot > 0 and lower(name[dot+1:]) or '' if suf: try: type=content_type[suf] except KeyError: if find_binary(BODY) >= 0: type='application/x-%s' % suf else: type=text_type(BODY) else: if find_binary(BODY) >= 0: raise 'Bad Request', 'Could not determine file type' else: type=text_type(BODY) __traceback_info__=suf, dot, name, type if lower(type)=='text/html': return self._parent.manage_addDocument(name,'',BODY, REQUEST=REQUEST) if lower(type)[:6]=='image/': self._parent._setObject(name, Image(name, '', BODY, type)) else: self._parent._setObject(name, File(name, '', BODY, type)) return 'OK'
def PUT(self, REQUEST, BODY): """Adds a document, image or file to the folder when a PUT request is received.""" name=self._key try: type=REQUEST['CONTENT_TYPE'] except KeyError: type='' if not type: dot=rfind(name, '.') suf=dot > 0 and lower(name[dot+1:]) or '' if suf: try: type=content_type[suf] except KeyError: if find_binary(BODY) >= 0: type='application/x-%s' % suf else: type=text_type(BODY) else: if find_binary(BODY) >= 0: raise 'Bad Request', 'Could not determine file type' else: type=text_type(BODY) __traceback_info__=suf, dot, name, type if lower(type)=='text/html': return self._parent.manage_addDocument(name,'',BODY, REQUEST=REQUEST) if lower(type)[:6]=='image/': self._parent._setObject(name, Image(name, '', BODY, content_type=type)) else: self._parent._setObject(name, File(name, '', BODY, type)) return 'OK'
3,032
def PUT(self, REQUEST, BODY): """Adds a document, image or file to the folder when a PUT request is received.""" name=self._key try: type=REQUEST['CONTENT_TYPE'] except KeyError: type='' if not type: dot=rfind(name, '.') suf=dot > 0 and lower(name[dot+1:]) or '' if suf: try: type=content_type[suf] except KeyError: if find_binary(BODY) >= 0: type='application/x-%s' % suf else: type=text_type(BODY) else: if find_binary(BODY) >= 0: raise 'Bad Request', 'Could not determine file type' else: type=text_type(BODY) __traceback_info__=suf, dot, name, type if lower(type)=='text/html': return self._parent.manage_addDocument(name,'',BODY, REQUEST=REQUEST) if lower(type)[:6]=='image/': self._parent._setObject(name, Image(name, '', BODY, type)) else: self._parent._setObject(name, File(name, '', BODY, type)) return 'OK'
def PUT(self, REQUEST, BODY): """Adds a document, image or file to the folder when a PUT request is received.""" name=self._key try: type=REQUEST['CONTENT_TYPE'] except KeyError: type='' if not type: dot=rfind(name, '.') suf=dot > 0 and lower(name[dot+1:]) or '' if suf: try: type=content_type[suf] except KeyError: if find_binary(BODY) >= 0: type='application/x-%s' % suf else: type=text_type(BODY) else: if find_binary(BODY) >= 0: raise 'Bad Request', 'Could not determine file type' else: type=text_type(BODY) __traceback_info__=suf, dot, name, type if lower(type)=='text/html': return self._parent.manage_addDocument(name,'',BODY, REQUEST=REQUEST) if lower(type)[:6]=='image/': self._parent._setObject(name, Image(name, '', BODY, type)) else: self._parent._setObject(name, File(name, '', BODY, content_type=type)) return 'OK'
3,033
def manage_editProperties(self, REQUEST): """Edit object properties via the web.""" for prop in self._properties: name=prop['id'] if REQUEST.has_key(name): if 'w' in prop.get('mode', 'wd'): value=REQUEST.get(name) self._setPropValue(name, value) return MessageDialog( title ='Success!', message='Your changes have been saved', action ='manage_propertiesForm')
def manage_editProperties(self, REQUEST): """Edit object properties via the web. The purpose of this method is to change all property values, even those not listed in REQUEST; otherwise checkboxes that get turned off will be ignored. Use manage_changeProperties() instead for most situations. """ for prop in self._properties: name=prop['id'] if REQUEST.has_key(name): if 'w' in prop.get('mode', 'wd'): value=REQUEST.get(name) self._setPropValue(name, value) return MessageDialog( title ='Success!', message='Your changes have been saved', action ='manage_propertiesForm')
3,034
def manage_editProperties(self, REQUEST): """Edit object properties via the web.""" for prop in self._properties: name=prop['id'] if REQUEST.has_key(name): if 'w' in prop.get('mode', 'wd'): value=REQUEST.get(name) self._setPropValue(name, value) return MessageDialog( title ='Success!', message='Your changes have been saved', action ='manage_propertiesForm')
def manage_editProperties(self, REQUEST): """Edit object properties via the web.""" for prop in self._properties: name=prop['id'] if 'w' in prop.get('mode', 'wd'): value=REQUEST.get(name, '') self._setPropValue(name, value) return MessageDialog( title ='Success!', message='Your changes have been saved', action ='manage_propertiesForm')
3,035
def __call__(self,*args,**kw): method=self.method if method=='PUT' and len(args)==1 and not kw: query=[args[0]] args=() else: query=[] for i in range(len(args)): try: k=self.args[i] if kw.has_key(k): raise TypeError, 'Keyword arg redefined' kw[k]=args[i] except IndexError: raise TypeError, 'Too many arguments'
def __call__(self,*args,**kw): method=self.method if method=='PUT' and len(args)==1 and not kw: query=[args[0]] args=() else: query=[] for i in range(len(args)): try: k=self.args[i] if kw.has_key(k): raise TypeError, 'Keyword arg redefined' kw[k]=args[i] except IndexError: raise TypeError, 'Too many arguments'
3,036
def _exec(cmd): '''Prints the time it takes to execute 'cmd'.''' if os.environ.get('X', None): start = time.time() exec cmd _print('(%.3fs)' % (time.time() - start))
def _exec(cmd): '''Prints the time it takes to execute 'cmd'.''' if os.environ.get('X', None): start = time.time() exec cmd _print('(%.3fs)' % (time.time() - start))
3,037
def _exec(cmd): '''Prints the time it takes to execute 'cmd'.''' if os.environ.get('X', None): start = time.time() exec cmd _print('(%.3fs)' % (time.time() - start))
def _exec(cmd): '''Prints the time it takes to execute 'cmd'.''' if os.environ.get('X', None): start = time.time() exec cmd _print('(%.3fs)' % (time.time() - start))
3,038
def _exec(cmd): '''Prints the time it takes to execute 'cmd'.''' if os.environ.get('X', None): start = time.time() exec cmd _print('(%.3fs)' % (time.time() - start))
def _exec(cmd): '''Prints the time it takes to execute 'cmd'.''' if os.environ.get('X', None): start = time.time() exec cmd _print('(%.3fs)' % (time.time() - start))
3,039
def _exec(cmd): '''Prints the time it takes to execute 'cmd'.''' if os.environ.get('X', None): start = time.time() exec cmd _print('(%.3fs)' % (time.time() - start))
def _exec(cmd): '''Prints the time it takes to execute 'cmd'.''' if os.environ.get('X', None): start = time.time() exec cmd _print('(%.3fs)' % (time.time() - start))
3,040
def _null_import_products(): pass
def _null_import_products(): pass
3,041
def _null_initialize(app): pass
def _null_initialize(app): pass
3,042
def _null_register_help(self,directory='',clear=1,title_re=None): pass
def _null_register_help(self,directory='',clear=1,title_re=None): pass
3,043
def hasProduct(name): '''Tests if a product can be found along Products.__path__''' return name in [n[1] for n in get_products()]
def hasProduct(name): '''Checks if a product can be found along Products.__path__''' return name in [n[1] for n in get_products()]
3,044
def installProduct(name, quiet=0): '''Installs a Zope product.''' start = time.time() app = _theApp meta_types = [] if not _installedProducts.has_key(name): for priority, product_name, index, product_dir in get_products(): if product_name == name: if not quiet: _print('Installing %s ... ' % product_name) # We want to fail immediately if a product throws an exception # during install, so we set the raise_exc flag. install_product(app, product_dir, product_name, meta_types, get_folder_permissions(), raise_exc=1) _installedProducts[product_name] = 1 Products.meta_types = Products.meta_types + tuple(meta_types) Globals.default__class_init__(Folder) if not quiet: _print('done (%.3fs)\n' % (time.time() - start)) break else: if name != 'SomeProduct': # Ignore the skeleton tests :-P if not quiet: _print('Installing %s ... NOT FOUND\n' % name)
def installProduct(name, quiet=0): '''Installs a Zope product.''' start = time.time() meta_types = [] if not _installedProducts.has_key(name): for priority, product_name, index, product_dir in get_products(): if product_name == name: if not quiet: _print('Installing %s ... ' % product_name) # We want to fail immediately if a product throws an exception # during install, so we set the raise_exc flag. install_product(app, product_dir, product_name, meta_types, get_folder_permissions(), raise_exc=1) _installedProducts[product_name] = 1 Products.meta_types = Products.meta_types + tuple(meta_types) Globals.default__class_init__(Folder) if not quiet: _print('done (%.3fs)\n' % (time.time() - start)) break else: if name != 'SomeProduct': # Ignore the skeleton tests :-P if not quiet: _print('Installing %s ... NOT FOUND\n' % name)
3,045
def installProduct(name, quiet=0): '''Installs a Zope product.''' start = time.time() app = _theApp meta_types = [] if not _installedProducts.has_key(name): for priority, product_name, index, product_dir in get_products(): if product_name == name: if not quiet: _print('Installing %s ... ' % product_name) # We want to fail immediately if a product throws an exception # during install, so we set the raise_exc flag. install_product(app, product_dir, product_name, meta_types, get_folder_permissions(), raise_exc=1) _installedProducts[product_name] = 1 Products.meta_types = Products.meta_types + tuple(meta_types) Globals.default__class_init__(Folder) if not quiet: _print('done (%.3fs)\n' % (time.time() - start)) break else: if name != 'SomeProduct': # Ignore the skeleton tests :-P if not quiet: _print('Installing %s ... NOT FOUND\n' % name)
def installProduct(name, quiet=0): '''Installs a Zope product.''' start = time.time() app = _theApp meta_types = [] if not _installedProducts.has_key(name): for priority, product_name, index, product_dir in get_products(): if product_name == name: if not quiet: _print('Installing %s ... ' % product_name) # We want to fail immediately if a product throws an exception # during install, so we set the raise_exc flag. install_product(_theApp, product_dir, product_name, meta_types, get_folder_permissions(), raise_exc=1) _installedProducts[product_name] = 1 Products.meta_types = Products.meta_types + tuple(meta_types) Globals.default__class_init__(Folder) if not quiet: _print('done (%.3fs)\n' % (time.time() - start)) break else: if name != 'SomeProduct': # Ignore the skeleton tests :-P if not quiet: _print('Installing %s ... NOT FOUND\n' % name)
3,046
def installProduct(name, quiet=0): '''Installs a Zope product.''' start = time.time() app = _theApp meta_types = [] if not _installedProducts.has_key(name): for priority, product_name, index, product_dir in get_products(): if product_name == name: if not quiet: _print('Installing %s ... ' % product_name) # We want to fail immediately if a product throws an exception # during install, so we set the raise_exc flag. install_product(app, product_dir, product_name, meta_types, get_folder_permissions(), raise_exc=1) _installedProducts[product_name] = 1 Products.meta_types = Products.meta_types + tuple(meta_types) Globals.default__class_init__(Folder) if not quiet: _print('done (%.3fs)\n' % (time.time() - start)) break else: if name != 'SomeProduct': # Ignore the skeleton tests :-P if not quiet: _print('Installing %s ... NOT FOUND\n' % name)
def installProduct(name, quiet=0): '''Installs a Zope product.''' start = time.time() app = _theApp meta_types = [] if not _installedProducts.has_key(name): for priority, product_name, index, product_dir in get_products(): if product_name == name: if not quiet: _print('Installing %s ... ' % product_name) # We want to fail immediately if a product throws an exception # during install, so we set the raise_exc flag. install_product(app, product_dir, product_name, meta_types, get_folder_permissions(), raise_exc=1) _installedProducts[product_name] = 1 Products.meta_types = Products.meta_types + tuple(meta_types) Globals.default__class_init__(Folder) if not quiet: _print('done (%.3fs)\n' % (time.time() - start)) break else: if name != 'SomeProduct': # Ignore the skeleton tests :-P if not quiet: _print('Installing %s ... NOT FOUND\n' % name)
3,047
def installProduct(name, quiet=0): '''Installs a Zope product.''' start = time.time() app = _theApp meta_types = [] if not _installedProducts.has_key(name): for priority, product_name, index, product_dir in get_products(): if product_name == name: if not quiet: _print('Installing %s ... ' % product_name) # We want to fail immediately if a product throws an exception # during install, so we set the raise_exc flag. install_product(app, product_dir, product_name, meta_types, get_folder_permissions(), raise_exc=1) _installedProducts[product_name] = 1 Products.meta_types = Products.meta_types + tuple(meta_types) Globals.default__class_init__(Folder) if not quiet: _print('done (%.3fs)\n' % (time.time() - start)) break else: if name != 'SomeProduct': # Ignore the skeleton tests :-P if not quiet: _print('Installing %s ... NOT FOUND\n' % name)
def installProduct(name, quiet=0): '''Installs a Zope product.''' start = time.time() app = _theApp meta_types = [] if not _installedProducts.has_key(name): for priority, product_name, index, product_dir in get_products(): if product_name == name: if not quiet: _print('Installing %s ... ' % product_name) # We want to fail immediately if a product throws an exception # during install, so we set the raise_exc flag. install_product(app, product_dir, product_name, meta_types, get_folder_permissions(), raise_exc=1) _installedProducts[product_name] = 1 Products.meta_types = Products.meta_types + tuple(meta_types) Globals.default__class_init__(Folder) if not quiet: _print('done (%.3fs)\n' % (time.time() - start)) break else: if name != 'SomeProduct': # Ignore the skeleton tests :-P if not quiet: _print('Installing %s ... NOT FOUND\n' % name)
3,048
def installProduct(name, quiet=0): '''Installs a Zope product.''' start = time.time() app = _theApp meta_types = [] if not _installedProducts.has_key(name): for priority, product_name, index, product_dir in get_products(): if product_name == name: if not quiet: _print('Installing %s ... ' % product_name) # We want to fail immediately if a product throws an exception # during install, so we set the raise_exc flag. install_product(app, product_dir, product_name, meta_types, get_folder_permissions(), raise_exc=1) _installedProducts[product_name] = 1 Products.meta_types = Products.meta_types + tuple(meta_types) Globals.default__class_init__(Folder) if not quiet: _print('done (%.3fs)\n' % (time.time() - start)) break else: if name != 'SomeProduct': # Ignore the skeleton tests :-P if not quiet: _print('Installing %s ... NOT FOUND\n' % name)
def installProduct(name, quiet=0): '''Installs a Zope product.''' start = time.time() app = _theApp meta_types = [] if not _installedProducts.has_key(name): for priority, product_name, index, product_dir in get_products(): if product_name == name: if not quiet: _print('Installing %s ... ' % product_name) # We want to fail immediately if a product throws an exception # during install, so we set the raise_exc flag. install_product(app, product_dir, product_name, meta_types, get_folder_permissions(), raise_exc=1) _installedProducts[product_name] = 1 Products.meta_types = Products.meta_types + tuple(meta_types) Globals.default__class_init__(Folder) if not quiet: _print('done (%.3fs)\n' % (time.time() - start)) break else: if name != 'SomeProduct': # Ignore the skeleton tests :-P if not quiet: _print('Installing %s ... NOT FOUND\n' % name)
3,049
def sandbox(base=None): '''Returns what amounts to a sandbox copy of the base ZODB.''' if base is None: base = Zope2.DB base_storage = base._storage quota = getattr(base_storage, '_quota', None) storage = DemoStorage(base=base_storage, quota=quota) return ZODB.DB(storage)
def sandbox(base=None): '''Returns a sandbox copy of the base ZODB.''' if base is None: base = Zope2.DB base_storage = base._storage quota = getattr(base_storage, '_quota', None) storage = DemoStorage(base=base_storage, quota=quota) return ZODB.DB(storage)
3,050
def sane_environment(env): # return an environment mapping which has been cleaned of # funny business such as REDIRECT_ prefixes added by Apache # or HTTP_CGI_AUTHORIZATION hacks. dict={} for key, val in env.items(): while key[:9]=='REDIRECT_': key=key[9:] dict[key]=val if env.has_key('HTTP_CGI_AUTHORIZATION'): dict['HTTP_AUTHORIZATION']=env['HTTP_CGI_AUTHORIZATION'] try: del env['HTTP_CGI_AUTHORIZATION'] except: pass return dict
def sane_environment(env): # return an environment mapping which has been cleaned of # funny business such as REDIRECT_ prefixes added by Apache # or HTTP_CGI_AUTHORIZATION hacks. dict={} for key, val in env.items(): while key[:9]=='REDIRECT_': key=key[9:] dict[key]=val if dict.has_key('HTTP_CGI_AUTHORIZATION'): dict['HTTP_AUTHORIZATION']=dict['HTTP_CGI_AUTHORIZATION'] try: del dict['HTTP_CGI_AUTHORIZATION'] except: pass return dict
3,051
def testNotValidateWithoutRoles(self): user = self.uf.validate(self.app.REQUEST, self.basic) self.assertEqual(user, None)
def testValidateWithoutRoles(self): user = self.uf.validate(self.app.REQUEST, self.basic) self.assertEqual(user, None)
3,052
def testNotValidateWithoutRoles(self): user = self.uf.validate(self.app.REQUEST, self.basic) self.assertEqual(user, None)
def testNotValidateWithoutRoles(self): user = self.uf.validate(self.app.REQUEST, self.basic) self.assertEqual(user, None)
3,053
def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(UserFolderTests)) suite.addTest(unittest.makeSuite(UserTests)) return suite
deftest_suite():suite=unittest.TestSuite()suite.addTest(unittest.makeSuite(UserFolderTests))suite.addTest(unittest.makeSuite(UserTests))returnsuite
3,054
def _cached_result(self, DB__, query, compressed=0):
def _cached_result(self, DB__, query, compressed=0):
3,055
def _findLocalTimeZoneName(isDST): if not daylight: # Daylight savings does not occur in this time zone. isDST = 0 try: # Get the name of the current time zone depending # on DST. _localzone = _cache._zmap[tzname[isDST].lower()] except: try: # Generate a GMT-offset zone name. if isDST: localzone = altzone else: localzone = timezone offset=(-localzone/(60*60)) majorOffset=int(offset) if majorOffset != 0 : minorOffset=abs(int((offset % majorOffset) * 60.0)) else: minorOffset = 0 m=majorOffset >= 0 and '+' or '' lz='%s%0.02d%0.02d' % (m, majorOffset, minorOffset) _localzone = _cache._zmap[('GMT%s' % lz).lower()] except: _localzone = '' return _localzone
def _findLocalTimeZoneName(isDST): if not daylight: # Daylight savings does not occur in this time zone. isDST = 0 try: # Get the name of the current time zone depending # on DST. _localzone = _cache._zmap[tzname[isDST].lower()] except: try: # Generate a GMT-offset zone name. if isDST: localzone = altzone else: localzone = timezone offset=(-localzone/(60*60.0)) majorOffset=int(offset) if majorOffset != 0 : minorOffset=abs(int((offset % majorOffset) * 60.0)) else: minorOffset = 0 m=majorOffset >= 0 and '+' or '' lz='%s%0.02d%0.02d' % (m, majorOffset, minorOffset) _localzone = _cache._zmap[('GMT%s' % lz).lower()] except: _localzone = '' return _localzone
3,056
def manage_addFolder(self,id,title='',createPublic=0,createUserF=0, REQUEST=None): """Add a new Folder object with id *id*. If the 'createPublic' and 'createUserF' parameters are set to any true value, an 'index_html' and a 'UserFolder' objects are created respectively in the new folder. """ i=Folder() i.id=id i.title=title self._setObject(id,i) if createUserF: i.manage_addUserFolder() if createPublic: i.manage_addDTMLDocument(id='index_html',title='') if REQUEST is not None: return self.manage_main(self,REQUEST,update_menu=1)
def manage_addFolder(self, id, title='', createPublic=0, createUserF=0, REQUEST=None): """Add a new Folder object with id *id*. If the 'createPublic' and 'createUserF' parameters are set to any true value, an 'index_html' and a 'UserFolder' objects are created respectively in the new folder. """ i=Folder() i.id=id i.title=title self._setObject(id,i) if createUserF: i.manage_addUserFolder() if createPublic: i.manage_addDTMLDocument(id='index_html',title='') if REQUEST is not None: return self.manage_main(self,REQUEST,update_menu=1)
3,057
def manage_addFolder(self,id,title='',createPublic=0,createUserF=0, REQUEST=None): """Add a new Folder object with id *id*. If the 'createPublic' and 'createUserF' parameters are set to any true value, an 'index_html' and a 'UserFolder' objects are created respectively in the new folder. """ i=Folder() i.id=id i.title=title self._setObject(id,i) if createUserF: i.manage_addUserFolder() if createPublic: i.manage_addDTMLDocument(id='index_html',title='') if REQUEST is not None: return self.manage_main(self,REQUEST,update_menu=1)
def manage_addFolder(self,id,title='',createPublic=0,createUserF=0, REQUEST=None): """Add a new Folder object with id *id*. If the 'createPublic' and 'createUserF' parameters are set to any true value, an 'index_html' and a 'UserFolder' objects are created respectively in the new folder. """ ob=Folder() ob.id=id ob.title=title self._setObject(id, ob) try: user=REQUEST['AUTHENTICATED_USER'] except: user=None if createUserF: if (user is not None) and not ( user.has_permission('Add User Folders', self)): raise 'Unauthorized', ( 'You are not authorized to add User Folders.' ) ob.manage_addUserFolder() if createPublic: if (user is not None) and not ( user.has_permission('Add Documents, Images, and Files', self)): raise 'Unauthorized', ( 'You are not authorized to add DTML Documents.' ) ob.manage_addDTMLDocument(id='index_html', title='') if REQUEST is not None: return self.manage_workspace(self, REQUEST, update_menu=1)
3,058
def __call__(self, *args, **kw): """Call an ExternalMethod
def __call__(self, *args, **kw): """Call an ExternalMethod
3,059
def valid_roles(self): "Return list of valid roles" obj=self dict={} dup =dict.has_key x=0 while x < 100: if hasattr(obj, '__ac_roles__'): roles=obj.__ac_roles__ for role in roles: if not dup(role): dict[role]=1 if not hasattr(obj, 'aq_parent'): break obj=obj.aq_parent x=x+1 roles=dict.keys() roles.sort() return roles
def valid_roles(self): "Return list of valid roles" obj=self dict={} dup =dict.has_key x=0 while x < 100: if hasattr(obj, '__ac_roles__'): roles=obj.__ac_roles__ for role in roles: if not dup(role): dict[role]=1 if not hasattr(obj, 'aq_parent'): break obj=obj.aq_parent x=x+1 roles=dict.keys() roles.sort() return roles
3,060
def resolve_url(self, path, REQUEST): """ Attempt to resolve a url into an object in the Zope namespace. The url may be absolute or a catalog path style url. If no object is found, None is returned. No exceptions are raised. """ script=REQUEST.script if string.find(path, script) != 0: path='%s/%s' % (script, path) print "resolving", path try: return REQUEST.resolve_url(path) except: print "not found" return None
def resolve_url(self, path, REQUEST): """ """ while path and path[0]=='/': path=path[1:] while path and path[-1]=='/': path=path[:-1] req=REQUEST.clone() rsp=req.response req['PATH_INFO']=path object=None try: object=req.traverse(path) except: pass if object is not None: if hasattr(object, 'id'): if callable(object.id): name=object.id() else: name=object.id elif hasattr(object, '__name__'): name=object.__name__ else: name='' if name != os.path.split(path)[-1]: result = req.PARENTS[0] req.close() return result req.close() return object req.close() raise rsp.errmsg, sys.exc_value print "resolving", path try: return REQUEST.resolve_url(path) except: print "not found" return None
3,061
def resolve_url(self, path, REQUEST): """ Attempt to resolve a url into an object in the Zope namespace. The url may be absolute or a catalog path style url. If no object is found, None is returned. No exceptions are raised. """ script=REQUEST.script if string.find(path, script) != 0: path='%s/%s' % (script, path) print "resolving", path try: return REQUEST.resolve_url(path) except: print "not found" return None
def resolve_url(self, path, REQUEST): """ Attempt to resolve a url into an object in the Zope namespace. The url may be absolute or a catalog path style url. If no object is found, None is returned. No exceptions are raised. """ script=REQUEST.script if string.find(path, script) != 0: path='%s/%s' % (script, path) print "resolving", path try: return REQUEST.resolve_url(path) except: print "not found" return None
3,062
def __init__(self, id, text=None, content_type=None, encoding='utf-8', strict=True, output_encoding='utf-8'): self.id = id self.expand = 0 self.ZBindings_edit(self._default_bindings) self.output_encoding = output_encoding
def __init__(self, id, text=None, content_type=None, strict=True, output_encoding='utf-8'): self.id = id self.expand = 0 self.ZBindings_edit(self._default_bindings) self.output_encoding = output_encoding
3,063
def __init__(self, id, text=None, content_type=None, encoding='utf-8', strict=True, output_encoding='utf-8'): self.id = id self.expand = 0 self.ZBindings_edit(self._default_bindings) self.output_encoding = output_encoding
def __init__(self, id, text=None, content_type=None, encoding='utf-8', strict=True, output_encoding='utf-8'): self.id = id self.expand = 0 self.ZBindings_edit(self._default_bindings) self.output_encoding = output_encoding
3,064
def pt_edit(self, text, content_type, keep_output_encoding=False):
def pt_edit(self, text, content_type, keep_output_encoding=False):
3,065
def pt_edit(self, text, content_type, keep_output_encoding=False):
def pt_edit(self, text, content_type, keep_output_encoding=False):
3,066
def pt_edit(self, text, content_type, keep_output_encoding=False):
defpt_edit(self,text,content_type,keep_output_encoding=False):
3,067
def pt_edit(self, text, content_type, keep_output_encoding=False):
def pt_edit(self, text, content_type, keep_output_encoding=False):
3,068
def _exec(self, bound_names, args, kw): """Call a Page Template""" if not kw.has_key('args'): kw['args'] = args bound_names['options'] = kw
def _exec(self, bound_names, args, kw): """Call a Page Template""" if not kw.has_key('args'): kw['args'] = args bound_names['options'] = kw
3,069
def manage_addPageTemplate(self, id, title='', text='', encoding='utf-8', submit=None, REQUEST=None, RESPONSE=None): "Add a Page Template with optional file content." filename = '' content_type = 'text/html' if REQUEST and REQUEST.has_key('file'): file = REQUEST['file'] filename = file.filename text = file.read() headers = getattr(file, 'headers', None) if headers and headers.has_key('content_type'): content_type = headers['content_type'] else: content_type = guess_type(filename, text) encoding = sniffEncoding(text) else: if hasattr(text, 'read'): filename = getattr(text, 'filename', '') headers = getattr(text, 'headers', None) text = text.read() if headers and headers.has_key('content_type'): content_type = headers['content_type'] else: content_type = guess_type(filename, text) encoding = sniffEncoding(text) zpt = ZopePageTemplate(id, text, content_type, encoding, True) zpt.pt_setTitle(title, encoding) self._setObject(id, zpt) zpt = getattr(self, id) if RESPONSE: if submit == " Add and Edit ": RESPONSE.redirect(zpt.absolute_url() + '/pt_editForm') else: RESPONSE.redirect(self.absolute_url() + '/manage_main') else: return zpt
def manage_addPageTemplate(self, id, title='', text='', encoding='utf-8', submit=None, REQUEST=None, RESPONSE=None): "Add a Page Template with optional file content." filename = '' content_type = 'text/html' if REQUEST and REQUEST.has_key('file'): file = REQUEST['file'] filename = file.filename text = file.read() headers = getattr(file, 'headers', None) if headers and headers.has_key('content_type'): content_type = headers['content_type'] else: content_type = guess_type(filename, text) else: if hasattr(text, 'read'): filename = getattr(text, 'filename', '') headers = getattr(text, 'headers', None) text = text.read() if headers and headers.has_key('content_type'): content_type = headers['content_type'] else: content_type = guess_type(filename, text) zpt = ZopePageTemplate(id, text, content_type, encoding, True) zpt.pt_setTitle(title, encoding) self._setObject(id, zpt) zpt = getattr(self, id) if RESPONSE: if submit == " Add and Edit ": RESPONSE.redirect(zpt.absolute_url() + '/pt_editForm') else: RESPONSE.redirect(self.absolute_url() + '/manage_main') else: return zpt
3,070
def manage_addPageTemplate(self, id, title='', text='', encoding='utf-8', submit=None, REQUEST=None, RESPONSE=None): "Add a Page Template with optional file content." filename = '' content_type = 'text/html' if REQUEST and REQUEST.has_key('file'): file = REQUEST['file'] filename = file.filename text = file.read() headers = getattr(file, 'headers', None) if headers and headers.has_key('content_type'): content_type = headers['content_type'] else: content_type = guess_type(filename, text) encoding = sniffEncoding(text) else: if hasattr(text, 'read'): filename = getattr(text, 'filename', '') headers = getattr(text, 'headers', None) text = text.read() if headers and headers.has_key('content_type'): content_type = headers['content_type'] else: content_type = guess_type(filename, text) encoding = sniffEncoding(text) zpt = ZopePageTemplate(id, text, content_type, encoding, True) zpt.pt_setTitle(title, encoding) self._setObject(id, zpt) zpt = getattr(self, id) if RESPONSE: if submit == " Add and Edit ": RESPONSE.redirect(zpt.absolute_url() + '/pt_editForm') else: RESPONSE.redirect(self.absolute_url() + '/manage_main') else: return zpt
def manage_addPageTemplate(self, id, title='', text='', encoding='utf-8', submit=None, REQUEST=None, RESPONSE=None): "Add a Page Template with optional file content." filename = '' content_type = 'text/html' if REQUEST and REQUEST.has_key('file'): file = REQUEST['file'] filename = file.filename text = file.read() headers = getattr(file, 'headers', None) if headers and headers.has_key('content_type'): content_type = headers['content_type'] else: content_type = guess_type(filename, text) encoding = sniffEncoding(text) else: if hasattr(text, 'read'): filename = getattr(text, 'filename', '') headers = getattr(text, 'headers', None) text = text.read() if headers and headers.has_key('content_type'): content_type = headers['content_type'] else: content_type = guess_type(filename, text) if not isinstance(text, unicode): text = unicode(text, encoding) zpt = ZopePageTemplate(id, text, content_type, output_encoding=encoding) zpt.pt_setTitle(title, encoding) self._setObject(id, zpt) zpt = getattr(self, id) if RESPONSE: if submit == " Add and Edit ": RESPONSE.redirect(zpt.absolute_url() + '/pt_editForm') else: RESPONSE.redirect(self.absolute_url() + '/manage_main') else: return zpt
3,071
def url_quote(s): """ Convert characters that have special meaning in URLS to HTML character entities using decimal values. See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'url_quote' function. """
def url_quote(s): """ Convert characters that have special meaning in URLS to HTML character entities using decimal values. See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'quote' function. """
3,072
def url_quote_plus(s): """ Like url_quote but also replace blank space characters with '+'. This is needed for building query strings in some cases. See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'url_quote_plus' function. """
def url_quote_plus(s): """ Like url_quote but also replace blank space characters with '+'. This is needed for building query strings in some cases. See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'quote_plus' function. """
3,073
def url_unquote(s): """ Convert HTML character entities in strings back to their real values. See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'url_unquote' function. """
def url_unquote(s): """ Convert HTML %xx character entities into the characters they represent. (Undoes the affects of url_quote). See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'unquote' function. """ def url_unquote_plus(s): """ Like url_unquote but also replace '+' characters with blank spaces. See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'url_unquote' function. """
3,074
def url_unquote(s): """ Convert HTML character entities in strings back to their real values. See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'url_unquote' function. """
def url_unquote(s): """ Convert HTML character entities in strings back to their real values. See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'url_unquote' function. """
3,075
def url_unquote(s): """ Like url_unquote, but also replace '+' characters with spaces. See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'url_unquote_plus' function. """
def url_unquote(s): """ Like url_unquote, but also replace '+' characters with spaces. """
3,076
def __init__(self, subs, **kw): t=[]; a=t.append for s in subs: a(s.getNodeValue()) apply(ST.StructuredTextParagraph.__init__, (self, join(t,'\n\n'), ()), kw)
def __init__(self, subs, **kw): t=[]; a=t.append for s in subs: a(s.getNodeValue()) apply(ST.StructuredTextParagraph.__init__, (self, join(t,'\n\n'), ()), kw)
3,077
def manage_addFile(self,id,file='',title='',precondition='', content_type='', REQUEST=None): """Add a new File object. Creates a new File object 'id' with the contents of 'file'""" id=str(id) title=str(title) content_type=str(content_type) precondition=str(precondition) id, title = cookId(id, title, file) self=self.this() # First, we create the file without data: self._setObject(id, File(id,title,'',content_type, precondition)) # Now we "upload" the data. By doing this in two steps, we # can use a database trick to make the upload more efficient. self._getOb(id).manage_upload(file) if REQUEST is not None: REQUEST['RESPONSE'].redirect(self.absolute_url()+'/manage_main')
def manage_addFile(self,id,file='',title='',precondition='', content_type='', REQUEST=None): """Add a new File object. Creates a new File object 'id' with the contents of 'file'""" id=str(id) title=str(title) content_type=str(content_type) precondition=str(precondition) id, title = cookId(id, title, file) self=self.this() # First, we create the file without data: self._setObject(id, File(id,title,'',content_type, precondition)) # Now we "upload" the data. By doing this in two steps, we # can use a database trick to make the upload more efficient. self._getOb(id).manage_upload(file) if REQUEST is not None: REQUEST['RESPONSE'].redirect(self.absolute_url()+'/manage_main')
3,078
def manage_addImage(self, id, file, title='', precondition='', content_type='', REQUEST=None): """ Add a new Image object. Creates a new Image object 'id' with the contents of 'file'. """ id=str(id) title=str(title) content_type=str(content_type) precondition=str(precondition) id, title = cookId(id, title, file) self=self.this() # First, we create the image without data: self._setObject(id, Image(id,title,'',content_type, precondition)) # Now we "upload" the data. By doing this in two steps, we # can use a database trick to make the upload more efficient. self._getOb(id).manage_upload(file) if REQUEST is not None: try: url=self.DestinationURL() except: url=REQUEST['URL1'] REQUEST.RESPONSE.redirect('%s/manage_main' % url) return id
def manage_addImage(self, id, file, title='', precondition='', content_type='', REQUEST=None): """ Add a new Image object. Creates a new Image object 'id' with the contents of 'file'. """ id=str(id) title=str(title) content_type=str(content_type) precondition=str(precondition) id, title = cookId(id, title, file) self=self.this() # First, we create the image without data: self._setObject(id, Image(id,title,'',content_type, precondition)) # Now we "upload" the data. By doing this in two steps, we # can use a database trick to make the upload more efficient. self._getOb(id).manage_upload(file) if REQUEST is not None: try: url=self.DestinationURL() except: url=REQUEST['URL1'] REQUEST.RESPONSE.redirect('%s/manage_main' % url) return id
3,079
def test_suite(): return unittest.makeSuite(HTMLTests, 'check')
def test_suite(): return unittest.makeSuite(HTMLTests, 'check')
3,080
def manage_main(trueself, self, REQUEST, update_menu=0): """IMplement a contents view by redirecting to the true view """ d = update_menu and '/manage_main?update_menu=1' or '/manage_main' REQUEST['RESPONSE'].redirect(self.DestinationURL()+d)
def manage_main(trueself, self, REQUEST, update_menu=0): """Implement a contents view by redirecting to the true view """ d = update_menu and '/manage_main?update_menu=1' or '/manage_main' REQUEST['RESPONSE'].redirect(self.DestinationURL()+d)
3,081
def __call__(self, econtext): base = self._base path = list(self._path) # Copy! contexts = econtext.contexts var = contexts['var'] # Expand dynamic path parts from right to left. for i, varname in self._dynparts: val = var[varname] if type(val) is type(''): path[i] = val else: # If the value isn't a string, assume it's a sequence # of path names. path[i:i+1] = list(val) try: if var.has_key(base): ob = var[base] else: ob = contexts[base] ob = restrictedTraverse(ob, path) except (AttributeError, KeyError): if self._name == 'exists': return 0 raise else: if self._name == 'exists': return 1 if self._name == 'nocall': return ob mm = TemplateDict() mm._push(var) mm._push({'_ob': ob}) return mm['_ob']
def __call__(self, econtext): base = self._base path = list(self._path) # Copy! contexts = econtext.contexts var = contexts['var'] # Expand dynamic path parts from right to left. for i, varname in self._dynparts: val = var[varname] if type(val) is type(''): path[i] = val else: # If the value isn't a string, assume it's a sequence # of path names. path[i:i+1] = list(val) try: if var.has_key(base): ob = var[base] else: ob = contexts[base] ob = restrictedTraverse(ob, path) except (AttributeError, KeyError): if self._name == 'exists': return 0 raise else: if self._name == 'exists': return 1 if self._name == 'nocall': return ob mm = TemplateDict() mm._push(var) mm._push({'_ob': ob}) return mm['_ob']
3,082
def dav__allprop(self, propstat=propstat, join=string.join): # DAV helper method - return one or more propstat elements # indicating property names and values for all properties. result=[] for item in self._propertyMap(): name, type=item['id'], item.get('type','string') value=self.getProperty(name) if type=='tokens': value=join(str(value), ' ') elif type=='lines': value=join(str(value), '\n') # check for xml property attrs=item.get('meta', {}).get('__xml_attrs__', None) if attrs is not None: attrs=map(lambda n: ' %s="%s"' % n, attrs.items()) attrs=join(attrs, '') else: # Quote non-xml items here? attrs=''
def dav__allprop(self, propstat=propstat, join=string.join): # DAV helper method - return one or more propstat elements # indicating property names and values for all properties. result=[] for item in self._propertyMap(): name, type=item['id'], item.get('type','string') value=self.getProperty(name) if type=='tokens': value=join(str(value), ' ') elif type=='lines': value=join(str(value), '\n') # check for xml property attrs=item.get('meta', {}).get('__xml_attrs__', None) if attrs is not None: attrs=map(lambda n: ' %s="%s"' % n, attrs.items()) attrs=join(attrs, '') else: # Quote non-xml items here? attrs=''
3,083
def manage_addImage(self, id, file, title='', precondition='', content_type='', REQUEST=None): """ Add a new Image object. Creates a new Image object 'id' with the contents of 'file'. """ id, title = cookId(id, title, file) self=self.this() self._setObject(id, Image(id,title,'',content_type, precondition)) if Globals.DatabaseVersion=='3': get_transaction().commit(1) self._getOb(id).manage_upload(file) if REQUEST is not None: return self.manage_main(self,REQUEST) return id
def manage_addImage(self, id, file, title='', precondition='', content_type='', REQUEST=None): """ Add a new Image object. Creates a new Image object 'id' with the contents of 'file'. """ id, title = cookId(id, title, file) self=self.this() self._setObject(id, Image(id,title,'',content_type, precondition)) if Globals.DatabaseVersion=='3': get_transaction().commit(1) self._getOb(id).manage_upload(file) if REQUEST is not None: try: url=self.DestinationURL() except: url=REQUEST['URL1'] REQUEST.RESPONSE.redirect('%s/manage_main' % url) return id
3,084
def manage_addImage(self, id, file, title='', precondition='', content_type='', REQUEST=None): """ Add a new Image object. Creates a new Image object 'id' with the contents of 'file'. """ id, title = cookId(id, title, file) self=self.this() self._setObject(id, Image(id,title,'',content_type, precondition)) if Globals.DatabaseVersion=='3': get_transaction().commit(1) self._getOb(id).manage_upload(file) if REQUEST is not None: return self.manage_main(self,REQUEST) return id
def manage_addImage(self, id, file, title='', precondition='', content_type='', REQUEST=None): """ Add a new Image object. Creates a new Image object 'id' with the contents of 'file'. """ id, title = cookId(id, title, file) self=self.this() self._setObject(id, Image(id,title,'',content_type, precondition)) if Globals.DatabaseVersion=='3': get_transaction().commit(1) self._getOb(id).manage_upload(file) if REQUEST is not None: return self.manage_main(self,REQUEST) return id
3,085
def parse_error(self, mess, tag, text, start): raise ParseError, "%s, for tag %s, on line %s of %s<p>" % ( mess, self.errQuote(tag), len(text[:start].split('\n')), self.errQuote(self.__name__))
def parse_error(self, mess, tag, text, start): raise ParseError, "%s, for tag %s, on line %s of %s" % ( mess, self.errQuote(tag), len(text[:start].split('\n')), self.errQuote(self.__name__))
3,086
def __init__(self, id, extra=None, caller=None, index_factory=None, field_name=None, lexicon_id=None): self.id = id
def __init__(self, id, extra=None, caller=None, index_factory=None, field_name=None, lexicon_id=None): self.id = id
3,087
def finish_starttag(self, tag, attrs): self.scan_xmlns(attrs) print tag, self.nsdict if tag not in EMPTY_HTML_TAGS: self.tagstack.append(tag) else: self.pop_xmlns() print "<", tag, self.nsdict self.gen.emitStartTag(tag, attrs)
def finish_starttag(self, tag, attrs): self.scan_xmlns(attrs) if tag not in EMPTY_HTML_TAGS: self.tagstack.append(tag) else: self.pop_xmlns() print "<", tag, self.nsdict self.gen.emitStartTag(tag, attrs)
3,088
def finish_starttag(self, tag, attrs): self.scan_xmlns(attrs) print tag, self.nsdict if tag not in EMPTY_HTML_TAGS: self.tagstack.append(tag) else: self.pop_xmlns() print "<", tag, self.nsdict self.gen.emitStartTag(tag, attrs)
def finish_starttag(self, tag, attrs): self.scan_xmlns(attrs) print tag, self.nsdict if tag not in EMPTY_HTML_TAGS: self.tagstack.append(tag) else: self.pop_xmlns() self.gen.emitStartTag(tag, attrs)
3,089
def finish_endtag(self, tag): if tag not in EMPTY_HTML_TAGS: if not tag: tag = self.tagstack.pop() else: assert tag in self.tagstack while self.tagstack[-1] != tag: self.finish_endtag(None) self.tagstack.pop() self.pop_xmlns() print "<", tag, self.nsdict self.gen.emitEndTag(tag)
def finish_endtag(self, tag): if tag not in EMPTY_HTML_TAGS: if not tag: tag = self.tagstack.pop() else: assert tag in self.tagstack while self.tagstack[-1] != tag: self.finish_endtag(None) self.tagstack.pop() self.pop_xmlns() self.gen.emitEndTag(tag)
3,090
def pasteFromClipboard(self,clip_id='',clip_data='',REQUEST=None): """ """
def pasteFromClipboard(self,clip_id='',clip_data='',REQUEST=None): """ """
3,091
def safe_callable(ob): # Works with ExtensionClasses and Acquisition. if hasattr(ob, '__class__'): if hasattr(ob, '__call__'): return 1 else: return isinstance(ob, types.ClassType) else: return callable(ob)
def safe_callable(ob): # Works with ExtensionClasses and Acquisition. if hasattr(ob, '__class__'): return hasattr(ob, '__call__') or isinstance(ob, types.ClassType) else: return callable(ob)
3,092
def catalogObject(self, object, uid, threshold=None,idxs=[]): """ Adds an object to the Catalog by iteratively applying it all indexes.
def catalogObject(self, object, uid, threshold=None,idxs=[]): """ Adds an object to the Catalog by iteratively applying it all indexes.
3,093
def catalogObject(self, object, uid, threshold=None,idxs=[]): """ Adds an object to the Catalog by iteratively applying it all indexes.
def catalogObject(self, object, uid, threshold=None,idxs=[]): """ Adds an object to the Catalog by iteratively applying it all indexes.
3,094
def catalogObject(self, object, uid, threshold=None,idxs=[]): """ Adds an object to the Catalog by iteratively applying it all indexes.
def catalogObject(self, object, uid, threshold=None,idxs=[]): """ Adds an object to the Catalog by iteratively applying it all indexes.
3,095
def __getitem__(self,index):
def __getitem__(self,index):
3,096
def _delOb(self, id, value): delattr(self, id) pc=self.aq_inner.aq_parent.aq_parent._zclass_propertysheets_class delattr(pc,id) pc.__propset_attrs__=tuple(map(lambda o: o[0], self._objects)) rclass(pc)
def _delOb(self, id): delattr(self, id) pc=self.aq_inner.aq_parent.aq_parent._zclass_propertysheets_class delattr(pc,id) pc.__propset_attrs__=tuple(map(lambda o: o[0], self._objects)) rclass(pc)
3,097
def reindex_all(obj=None): """
def reindex_all(obj=None): """
3,098
def allowed(self, object, object_roles=None): """Check whether the user has access to object, assuming that object.__roles__ is the given roles.""" if object_roles is None or 'Anonymous' in object_roles: return 1 usr_roles=self.getRolesInContext(object) for role in object_roles: if role in usr_roles: # The user apparently has one of the necessary # roles, but first make sure the object exists # in the context of the parent of the acl_users # folder. ufolder = getattr(self, 'aq_parent', None) ucontext = getattr(ufolder, 'aq_parent', None) if ucontext is not None: if object is None: # This is a strange rule, though # it doesn't cause any security holes. SDH return 1 if not hasattr(object, 'aq_inContextOf'): if hasattr(object, 'im_self'): # This is a method. Grab its self. object=object.im_self if not hasattr(object, 'aq_inContextOf'): # object is not wrapped, therefore we # can't determine context. # Fail the access attempt. Otherwise # this would be a security hole. return None if not object.aq_inContextOf(ucontext, 1): if 'Shared' in object_roles: # Damn, old role setting. Waaa object_roles=self._shared_roles(object) if 'Anonymous' in roles: return 1 return None # Note that if self were not wrapped, it would # not be possible to determine the user's context # and this method would return 1. # However, as long as user folders always return # wrapped user objects, this is safe. return 1
def allowed(self, object, object_roles=None): """Check whether the user has access to object, assuming that object.__roles__ is the given roles.""" if object_roles is None or 'Anonymous' in object_roles: return 1 usr_roles=self.getRolesInContext(object) for role in object_roles: if role in usr_roles: # The user apparently has one of the necessary # roles, but first make sure the object exists # in the context of the parent of the acl_users # folder. ufolder = getattr(self, 'aq_parent', None) ucontext = getattr(ufolder, 'aq_parent', None) if ucontext is not None: if object is None: # This is a strange rule, though # it doesn't cause any security holes. SDH return 1 if not hasattr(object, 'aq_inContextOf'): if hasattr(object, 'im_self'): # This is a method. Grab its self. object=object.im_self if not hasattr(object, 'aq_inContextOf'): # object is not wrapped, therefore we # can't determine context. # Fail the access attempt. Otherwise # this would be a security hole. return None if not object.aq_inContextOf(ucontext, 1): if 'Shared' in object_roles: # Damn, old role setting. Waaa object_roles=self._shared_roles(object) if 'Anonymous' in object_roles: return 1 return None # Note that if self were not wrapped, it would # not be possible to determine the user's context # and this method would return 1. # However, as long as user folders always return # wrapped user objects, this is safe. return 1
3,099