rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
def setCookie(self,name,value,**kw):
349fac2452df2de544bd34705932de86103ab82e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/349fac2452df2de544bd34705932de86103ab82e/Response.py
cookie='set-cookie: %s="%s"' % (name,attrs['value'])
cookie='Set-Cookie: %s="%s"' % (name, attrs['value'])
def _cookie_list(self):
349fac2452df2de544bd34705932de86103ab82e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/349fac2452df2de544bd34705932de86103ab82e/Response.py
if name=='expires': cookie = '%s; Expires="%s"' % (cookie,v) elif name=='domain': cookie = '%s; Domain="%s"' % (cookie,v)
name=lower(name) if name=='expires': cookie = '%s; Expires=%s' % (cookie,v) elif name=='domain': cookie = '%s; Domain=%s' % (cookie,v)
def _cookie_list(self):
349fac2452df2de544bd34705932de86103ab82e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/349fac2452df2de544bd34705932de86103ab82e/Response.py
elif name=='max_age': cookie = '%s; Max-Age="%s"' % (cookie,v) elif name=='comment': cookie = '%s; Comment="%s"' % (cookie,v)
elif name=='max_age': cookie = '%s; Max-Age=%s' % (cookie,v) elif name=='comment': cookie = '%s; Comment=%s' % (cookie,v)
def _cookie_list(self):
349fac2452df2de544bd34705932de86103ab82e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/349fac2452df2de544bd34705932de86103ab82e/Response.py
def _cookie_list(self):
349fac2452df2de544bd34705932de86103ab82e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/349fac2452df2de544bd34705932de86103ab82e/Response.py
_DQUOTEDTEXT = r'("[ a-zA-Z0-9\n\-\.\,\;\(\)\/\:\/]+")'
_DQUOTEDTEXT = r'("[ a-zA-Z0-9\n\-\.\,\;\(\)\/\:\/\*\']+")'
def doc_strong(self, s, expr = re.compile(r'\s*\*\*([ \na-zA-Z0-9.:/;\-,!\?\'\"]+)\*\*').search ):
dfbbd4a0ddf65451b22efcf9ca1725ead2a04dae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/dfbbd4a0ddf65451b22efcf9ca1725ead2a04dae/DocumentClass.py
if n != '__call__':
if str(n) != '__call__':
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
ce202f14c8e70b35166bb65fc2b5dc21b8fd55d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/ce202f14c8e70b35166bb65fc2b5dc21b8fd55d7/Expressions.py
$Id: Publish.py,v 1.21 1996/10/15 15:45:35 jim Exp $"""
$Id: Publish.py,v 1.22 1996/10/25 19:34:27 jim Exp $"""
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
f4dfc5f9edd25ea5aba674fd5973977a36fc88ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f4dfc5f9edd25ea5aba674fd5973977a36fc88ec/Publish.py
__version__='$Revision: 1.21 $'[11:-2]
__version__='$Revision: 1.22 $'[11:-2]
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
f4dfc5f9edd25ea5aba674fd5973977a36fc88ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f4dfc5f9edd25ea5aba674fd5973977a36fc88ec/Publish.py
output('<TD%s%s VALIGN="TOP" ALLIGN="LEFT">' %
output('<TD%s%s VALIGN="TOP" ALIGN="LEFT">' %
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
db085b65e7fa2aaf240d0b708a68b5a52095e5b3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/db085b65e7fa2aaf240d0b708a68b5a52095e5b3/TreeTag.py
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {}
def get_requests(files, start=None, end=None, statsfname=None, writestats=None, readstats=None):
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
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
decidelines = {} 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 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 readstats: fp = open(statsfname, 'r') u = cPickle.Unpickler(fp) requests = u.load() fp.close() del u del fp else: while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup 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 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 writestats: fp = open(statsfname, 'w') p = cPickle.Pickler(fp) p.dump(requests) fp.close() del p del fp return requests def analyze(requests, top, sortf, start=None, end=None, mode='cumulative', resolution=60, urlfocusurl=None, urlfocustime=60):
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)
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
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':
requests = cumulative.values() requests.sort(sortf) write(requests, top) elif mode=='timed': computed_start = requests[0].start computed_end = requests[-1].t_end
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)
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
dict.sort(sortf) write(dict, top)
requests.sort(sortf) write(requests, top) def urlfocuswrite(requests, url, t): l = [] i = 0 for request in requests: if request.url == url: l.append(i) i = i + 1 before = {} after = {} x = 0 for n in l: x = x + 1 r = requests[n] start = r.start earliest = start - t latest = start + t print 'URLs invoked %s seconds before and after %s ( (t, url, x, r.shortprettystart()) print '---' i = -1 for request in requests: i = i + 1 if request.start < earliest: continue if request.start > latest: break if n == i: print '%3d' % (request.start - start), print '%s' % (request.shortprettystart()), print request.url continue if request.start <= start: if before.get(i): before[i] = before[i] + 1 else: before[i] = 1 if request.start > start: if after.get(i): after[i] = after[i] + 1 else: after[i] = 1 print '%3d' % (request.start - start), print '%s' % (request.shortprettystart()), print request.url print print ('Summary of URLs invoked before (and at the same time as) %s ' '(times, url)' % url) before = before.items() before.sort() for k,v in before: print v, requests[k].url print print 'Summary of URLs invoked after %s (times, url)' % url after = after.items() after.sort() for k,v in after: print v, requests[k].url
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)
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
max_requests = 0
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)
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
slices = d.keys() slices.sort() for slice in slices: num = d[slice]
max_requests = 0 for slice in range(min, max, resolution): num = d.get(slice, 0)
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)
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
Reports are of three types: cumulative,detailed or timed. The default is cumulative. Data is taken from the one or more Zope detailed request logs (-M logs).
Reports are of four types: cumulative, detailed, timed, or urlfocus. The default is cumulative. Data is taken from one or more Zope detailed request logs (-M logs, aka 'big M' logs) or from a preprocessed statistics file.
def detailedusage(): details = usage(0) pname = sys.argv[0] details = details + """
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
For timed reports there are no sort specs allowed.
For timed and urlfocus reports, there are no sort specs allowed.
def detailedusage(): details = usage(0) pname = sys.argv[0] details = details + """
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
elapsed time.""" % {'pname':pname}
elapsed time. %(pname)s debug.log debug2.log --writestats='requests.stat' Write stats file for debug.log and debug2.log into 'requests.stat' and show default report. %(pname)s --readstats='requests.stat' --detailed Read from 'requests.stat' stats file (instead of actual -M log files) and show detailed report against this data.""" % {'pname':pname}
def detailedusage(): details = usage(0) pname = sys.argv[0] details = details + """
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
Usage: %s filename1 [filename2 ...] [--cumulative|--detailed|--timed]
Usage: %s filename1 [filename2 ...] [--cumulative | --detailed | [--timed --resolution=seconds]]
def usage(basic=1): usage = ( """
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
[--top==n]
[--top=n]
def usage(basic=1): usage = ( """
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
[--resolution=seconds]
[--writestats=filename | --readstats=filename] [--urlfocus=url] [--urlfocustime=seconds]
def usage(basic=1): usage = ( """
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
resolution=10
resolution=60 urlfocustime=10 urlfocusurl=None statsfname = None readstats = 0 writestats = 0
def usage(basic=1): usage = ( """
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
'end=','resolution=']
'end=','resolution=', 'writestats=', 'readstats=','urlfocus=','urlfocustime=']
def usage(basic=1): usage = ( """
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
def usage(basic=1): usage = ( """
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
if opt=='--urlfocus': mode='urlfocus' urlfocusurl = val if opt=='--urlfocustime': urlfocustime=int(val)
def usage(basic=1): usage = ( """
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
analyze(files, top, sortf, start, end, mode, resolution)
req=get_requests(files, start, end, statsfname, writestats, readstats) analyze(req, top, sortf, start, end, mode, resolution, urlfocusurl, urlfocustime)
def usage(basic=1): usage = ( """
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
def usage(basic=1): usage = ( """
76070c7cdc68bf22cdf41234ce64835eb149b1ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/76070c7cdc68bf22cdf41234ce64835eb149b1ae/requestprofiler.py
setlist=index.items(lo,hi)
if hi: setlist=index.items(lo,hi) else: setlist=index.items(lo)
def _apply_index(self, request, cid=''):
4fff45ca4fad8ac6244c86b407f3b3de0611596f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/4fff45ca4fad8ac6244c86b407f3b3de0611596f/Index.py
if self.REQUEST['REQUEST_METHOD']=='PUT': return PUTer(self,key)
if self.REQUEST['REQUEST_METHOD']=='PUT': return PUTer(self,key).__of__(self)
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
3037ef1e742284417a24582fb954269110270387 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/3037ef1e742284417a24582fb954269110270387/Folder.py
class PUTer:
class PUTer(Acquisition.Explicit):
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
3037ef1e742284417a24582fb954269110270387 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/3037ef1e742284417a24582fb954269110270387/Folder.py
if lower(type)=='text/html':
if lower(type)[:5]=='text/':
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'
3037ef1e742284417a24582fb954269110270387 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/3037ef1e742284417a24582fb954269110270387/Folder.py
self._parent._setObject(name, Image(name, '', BODY, type))
self._parent._setObject(name, Image(name, '', BODY, content_type=type))
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'
3037ef1e742284417a24582fb954269110270387 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/3037ef1e742284417a24582fb954269110270387/Folder.py
self._parent._setObject(name, File(name, '', BODY, type))
self._parent._setObject(name, File(name, '', BODY, content_type=type))
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'
3037ef1e742284417a24582fb954269110270387 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/3037ef1e742284417a24582fb954269110270387/Folder.py
"""Edit object properties via the web."""
"""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. """
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')
0006e835a6b11991b010c8b10351aa33c74c5138 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/0006e835a6b11991b010c8b10351aa33c74c5138/PropertyManager.py
if REQUEST.has_key(name): if 'w' in prop.get('mode', 'wd'): value=REQUEST.get(name) self._setPropValue(name, value)
if 'w' in prop.get('mode', 'wd'): value=REQUEST.get(name, '') self._setPropValue(name, value)
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')
0006e835a6b11991b010c8b10351aa33c74c5138 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/0006e835a6b11991b010c8b10351aa33c74c5138/PropertyManager.py
h=HTTP() h.connect(self.host, self.port)
h=HTTP(self.host, self.port)
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'
543e95ece3f6da4856025bedc08cbb2529e43b97 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/543e95ece3f6da4856025bedc08cbb2529e43b97/Client.py
if not sys.modules.has_key('logging'): import logging logging.basicConfig()
def _configure_logging(): if not sys.modules.has_key('logging'): import logging logging.basicConfig()
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))
f8c45562b7ce76e16b3ca098b95a6ff1e22605e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f8c45562b7ce76e16b3ca098b95a6ff1e22605e6/ZopeLite.py
import App.config config = App.config.getConfiguration() config.debug_mode = 0 App.config.setConfiguration(config)
def _configure_debug_mode(): import App.config config = App.config.getConfiguration() config.debug_mode = 0 App.config.setConfiguration(config)
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))
f8c45562b7ce76e16b3ca098b95a6ff1e22605e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f8c45562b7ce76e16b3ca098b95a6ff1e22605e6/ZopeLite.py
def _configure_client_cache(): import App.config config = App.config.getConfiguration() config.zeo_client_name = None App.config.setConfiguration(config) _configure_logging() _configure_debug_mode() _configure_client_cache()
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))
f8c45562b7ce76e16b3ca098b95a6ff1e22605e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f8c45562b7ce76e16b3ca098b95a6ff1e22605e6/ZopeLite.py
def _null_import_products(): pass OFS.Application.import_products = _null_import_products
def _apply_patches(): def null_import_products(): pass OFS.Application.import_products = null_import_products
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))
f8c45562b7ce76e16b3ca098b95a6ff1e22605e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f8c45562b7ce76e16b3ca098b95a6ff1e22605e6/ZopeLite.py
def _null_initialize(app): pass OFS.Application.initialize = _null_initialize
def null_initialize(app): pass OFS.Application.initialize = null_initialize
def _null_import_products(): pass
f8c45562b7ce76e16b3ca098b95a6ff1e22605e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f8c45562b7ce76e16b3ca098b95a6ff1e22605e6/ZopeLite.py
def _null_register_topic(self,id,topic): pass App.ProductContext.ProductContext.registerHelpTopic = _null_register_topic def _null_register_title(self,title): pass App.ProductContext.ProductContext.registerHelpTitle = _null_register_title def _null_register_help(self,directory='',clear=1,title_re=None): pass App.ProductContext.ProductContext.registerHelp = _null_register_help
def null_register_topic(self,id,topic): pass App.ProductContext.ProductContext.registerHelpTopic = null_register_topic def null_register_title(self,title): pass App.ProductContext.ProductContext.registerHelpTitle = null_register_title def null_register_help(self,directory='',clear=1,title_re=None): pass App.ProductContext.ProductContext.registerHelp = null_register_help
def _null_initialize(app): pass
f8c45562b7ce76e16b3ca098b95a6ff1e22605e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f8c45562b7ce76e16b3ca098b95a6ff1e22605e6/ZopeLite.py
if os.environ.get('ZEO_CLIENT'): del os.environ['ZEO_CLIENT']
if not Zope2._began_startup: _apply_patches()
def _null_register_help(self,directory='',clear=1,title_re=None): pass
f8c45562b7ce76e16b3ca098b95a6ff1e22605e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f8c45562b7ce76e16b3ca098b95a6ff1e22605e6/ZopeLite.py
'''Tests if a product can be found along Products.__path__'''
'''Checks if a product can be found along Products.__path__'''
def hasProduct(name): '''Tests if a product can be found along Products.__path__''' return name in [n[1] for n in get_products()]
f8c45562b7ce76e16b3ca098b95a6ff1e22605e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f8c45562b7ce76e16b3ca098b95a6ff1e22605e6/ZopeLite.py
app = _theApp
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)
f8c45562b7ce76e16b3ca098b95a6ff1e22605e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f8c45562b7ce76e16b3ca098b95a6ff1e22605e6/ZopeLite.py
install_product(app, product_dir, product_name, meta_types,
install_product(_theApp, product_dir, product_name, meta_types,
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)
f8c45562b7ce76e16b3ca098b95a6ff1e22605e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f8c45562b7ce76e16b3ca098b95a6ff1e22605e6/ZopeLite.py
if name != 'SomeProduct':
if name != 'SomeProduct':
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)
f8c45562b7ce76e16b3ca098b95a6ff1e22605e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f8c45562b7ce76e16b3ca098b95a6ff1e22605e6/ZopeLite.py
_s = time.time(); _max = (_s - _start) / 4 _exec('_theApp.Control_Panel') _cp = _theApp.Control_Panel if hasattr(_cp, 'initialize_cache'): _cp.initialize_cache() if (time.time() - _s) > _max: _write('.')
def _load_control_panel(): start = time.time() max = (start - _start) / 4 _exec('_theApp.Control_Panel') _theApp.Control_Panel if (time.time() - start) > max: _write('.')
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)
f8c45562b7ce76e16b3ca098b95a6ff1e22605e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f8c45562b7ce76e16b3ca098b95a6ff1e22605e6/ZopeLite.py
installProduct('PluginIndexes', 1) installProduct('OFSP', 1)
def _install_products(): installProduct('PluginIndexes', 1) installProduct('OFSP', 1) _load_control_panel() _install_products()
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)
f8c45562b7ce76e16b3ca098b95a6ff1e22605e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f8c45562b7ce76e16b3ca098b95a6ff1e22605e6/ZopeLite.py
'''Returns what amounts to a sandbox copy of the base ZODB.'''
'''Returns a sandbox copy of the base ZODB.'''
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)
f8c45562b7ce76e16b3ca098b95a6ff1e22605e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f8c45562b7ce76e16b3ca098b95a6ff1e22605e6/ZopeLite.py
if env.has_key('HTTP_CGI_AUTHORIZATION'): dict['HTTP_AUTHORIZATION']=env['HTTP_CGI_AUTHORIZATION'] try: del env['HTTP_CGI_AUTHORIZATION']
if dict.has_key('HTTP_CGI_AUTHORIZATION'): dict['HTTP_AUTHORIZATION']=dict['HTTP_CGI_AUTHORIZATION'] try: del dict['HTTP_CGI_AUTHORIZATION']
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
5b433e3c5558e4619dc01e30ebe079e89c5f671f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/5b433e3c5558e4619dc01e30ebe079e89c5f671f/Publish.py
def testNotValidateWithoutRoles(self):
def testValidateWithoutRoles(self):
def testNotValidateWithoutRoles(self): user = self.uf.validate(self.app.REQUEST, self.basic) self.assertEqual(user, None)
a45b9e05debbb1dbf9cbb758ab9d14f4590bb2d2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/a45b9e05debbb1dbf9cbb758ab9d14f4590bb2d2/testUserFolder.py
self.assertEqual(user, None)
self.assertEqual(user.getUserName(), 'user1')
def testNotValidateWithoutRoles(self): user = self.uf.validate(self.app.REQUEST, self.basic) self.assertEqual(user, None)
a45b9e05debbb1dbf9cbb758ab9d14f4590bb2d2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/a45b9e05debbb1dbf9cbb758ab9d14f4590bb2d2/testUserFolder.py
def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(UserFolderTests)) suite.addTest(unittest.makeSuite(UserTests)) return suite
a45b9e05debbb1dbf9cbb758ab9d14f4590bb2d2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/a45b9e05debbb1dbf9cbb758ab9d14f4590bb2d2/testUserFolder.py
else: result=apply(DB__.query, query) r=compress(result) cache[query]= now, r if compressed: return r
return result result=apply(DB__.query, query) r=compress(result) cache[query]= now, r if compressed: return r
def _cached_result(self, DB__, query, compressed=0):
fc556a6a8958f9b5407cc798cd36fb278afde571 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/fc556a6a8958f9b5407cc798cd36fb278afde571/DA.py
offset=(-localzone/(60*60))
offset=(-localzone/(60*60.0))
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
b39e614bc46d4c5d2133dcbd9c72faf00ecf638f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/b39e614bc46d4c5d2133dcbd9c72faf00ecf638f/DateTime.py
def manage_addFolder(self,id,title='',createPublic=0,createUserF=0, REQUEST=None):
def manage_addFolder(self, id, title='', createPublic=0, createUserF=0, REQUEST=None):
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)
566da61e8d5234ed411f999cb48ecc572c7e0aae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/566da61e8d5234ed411f999cb48ecc572c7e0aae/Folder.py
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)
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)
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)
566da61e8d5234ed411f999cb48ecc572c7e0aae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/566da61e8d5234ed411f999cb48ecc572c7e0aae/Folder.py
tb=sys.exc_traceback
tb=sys.exc_info()[2]
def __call__(self, *args, **kw): """Call an ExternalMethod
7bbd4be712b94d967a3f2f42ae02e2412676f197 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/7bbd4be712b94d967a3f2f42ae02e2412676f197/ExternalMethod.py
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
8d2817c7510574c144e733630f85598482f5ed02 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8d2817c7510574c144e733630f85598482f5ed02/ZCatalog.py
""" 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)
""" """ 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
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
8d2817c7510574c144e733630f85598482f5ed02 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8d2817c7510574c144e733630f85598482f5ed02/ZCatalog.py
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
8d2817c7510574c144e733630f85598482f5ed02 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8d2817c7510574c144e733630f85598482f5ed02/ZCatalog.py
def __init__(self, id, text=None, content_type=None, encoding='utf-8', strict=True, output_encoding='utf-8'):
def __init__(self, id, text=None, content_type=None, strict=True, output_encoding='utf-8'):
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
a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e/ZopePageTemplate.py
self.pt_edit(text, content_type, True)
self.pt_edit(text, content_type)
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
a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e/ZopePageTemplate.py
guessed_content_type = guess_type('', text) if guessed_content_type != content_type: raise ValueError('Guessed content-type != passed content-type (%s vs. %s)' % (guessed_content_type, content_type))
def pt_edit(self, text, content_type, keep_output_encoding=False):
a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e/ZopePageTemplate.py
print charset
def pt_edit(self, text, content_type, keep_output_encoding=False):
a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e/ZopePageTemplate.py
def pt_edit(self, text, content_type, keep_output_encoding=False):
a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e/ZopePageTemplate.py
raise ValueError('Unsupported content_type %s' % content_type)
raise ValueError('Unsupported content-type %s' % content_type)
def pt_edit(self, text, content_type, keep_output_encoding=False):
a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e/ZopePageTemplate.py
response.setHeader('content-type', '%s; charset=%s' % (self.content_type, self.output_encoding))
response.setHeader('content-type', self.content_type)
def _exec(self, bound_names, args, kw): """Call a Page Template""" if not kw.has_key('args'): kw['args'] = args bound_names['options'] = kw
a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e/ZopePageTemplate.py
encoding = sniffEncoding(text)
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
a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e/ZopePageTemplate.py
encoding = sniffEncoding(text) zpt = ZopePageTemplate(id, text, content_type, encoding, True)
if not isinstance(text, unicode): text = unicode(text, encoding) zpt = ZopePageTemplate(id, text, content_type, output_encoding=encoding)
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
a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/a4f57c3a9dc9677420ec24e2ab70f40ecc5cc78e/ZopePageTemplate.py
'url_quote' function.
'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 'url_quote' function. """
8a7dac44e5b13112e47e784d5f1511a9a4a63404 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8a7dac44e5b13112e47e784d5f1511a9a4a63404/standard.py
'url_quote_plus' function.
'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 'url_quote_plus' function. """
8a7dac44e5b13112e47e784d5f1511a9a4a63404 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8a7dac44e5b13112e47e784d5f1511a9a4a63404/standard.py
Convert HTML character entities in strings back to their real values.
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.
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. """
8a7dac44e5b13112e47e784d5f1511a9a4a63404 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8a7dac44e5b13112e47e784d5f1511a9a4a63404/standard.py
'url_unquote' function. """ def url_unquote(s): """ Like url_unquote, but also replace '+' characters with spaces.
'unquote_plus' 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. """
8a7dac44e5b13112e47e784d5f1511a9a4a63404 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8a7dac44e5b13112e47e784d5f1511a9a4a63404/standard.py
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. See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'url_unquote_plus' function. """
8a7dac44e5b13112e47e784d5f1511a9a4a63404 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8a7dac44e5b13112e47e784d5f1511a9a4a63404/standard.py
t=[]; a=t.append for s in subs: a(s.getNodeValue()) apply(ST.StructuredTextParagraph.__init__, (self, join(t,'\n\n'), ()), kw)
t=[] a=t.append for s in subs: flatten(s, a) 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)
269550f7ef5e3a98495bddfc61de1d9bf07232ac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/269550f7ef5e3a98495bddfc61de1d9bf07232ac/DocumentClass.py
'getContentType', '__call__', '')),
'getContentType', '')),
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')
c12e5349ffeb3dc11bd832082318fe404a5b4ff7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c12e5349ffeb3dc11bd832082318fe404a5b4ff7/Image.py
'getContentType', '__call__', '')),
'getContentType', '')),
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
c12e5349ffeb3dc11bd832082318fe404a5b4ff7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c12e5349ffeb3dc11bd832082318fe404a5b4ff7/Image.py
main()
unittest.main(defaultTest='test_suite')
def test_suite(): return unittest.makeSuite(HTMLTests, 'check')
7006502f1c7cbd946169753181fe8b44e9ce0c7c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/7006502f1c7cbd946169753181fe8b44e9ce0c7c/testHTMLTests.py
"""IMplement a contents view by redirecting to the true view
"""Implement a contents view by redirecting to the true view
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)
5f0e905ba0cabb0fa334077a2657317d35896929 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/5f0e905ba0cabb0fa334077a2657317d35896929/FactoryDispatcher.py
mm = TemplateDict() mm._push(var) mm._push({'_ob': ob}) return mm['_ob']
return render(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']
b6b70769d466497fbc77d60b6933611ad7255a7c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/b6b70769d466497fbc77d60b6933611ad7255a7c/Expressions.py
prop=' <n:%s%s>%s</n:%s>' % (name, attrs, xml_escape(value), name)
if hasattr(self,"dav__"+name): prop=' <n:%s%s>%s</n:%s>' % (name, attrs, value, name) else: prop=' <n:%s%s>%s</n:%s>' % (name, attrs, xml_escape(value), name)
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=''
a85fb5699520687030a044cd38d951a2665447c9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/a85fb5699520687030a044cd38d951a2665447c9/PropertySheets.py
if REQUEST is not None: return self.manage_main(self,REQUEST)
if REQUEST is not None: try: url=self.DestinationURL() except: url=REQUEST['URL1'] REQUEST.RESPONSE.redirect('%s/manage_main' % url)
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
65bd59473d3c0693c5f70b0384fedf6f4de3025f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/65bd59473d3c0693c5f70b0384fedf6f4de3025f/Image.py
"""Principia object for *Images*, can be GIF, PNG or JPEG. Has the same methods as File objects. Images also have a string representation that renders an HTML 'IMG' tag.
"""Image objects can be GIF, PNG or JPEG and have the same methods as File objects. Images also have a string representation that renders an HTML 'IMG' tag.
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
65bd59473d3c0693c5f70b0384fedf6f4de3025f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/65bd59473d3c0693c5f70b0384fedf6f4de3025f/Image.py
raise ParseError, "%s, for tag %s, on line %s of %s<p>" % (
raise ParseError, "%s, for tag %s, on line %s of %s" % (
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__))
b0b56654eb4022b1c5183a2436d6036dec528504 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/b0b56654eb4022b1c5183a2436d6036dec528504/DT_String.py
self.index = self._index_factory(self.getLexicon())
self.index = self._index_factory(aq_base(self.getLexicon()))
def __init__(self, id, extra=None, caller=None, index_factory=None, field_name=None, lexicon_id=None): self.id = id
1983f3222982f9762c68c1c0082667236969059b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/1983f3222982f9762c68c1c0082667236969059b/ZCTextIndex.py
print tag, self.nsdict
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)
df4d0c74a69327d848b994100662ee069776ae40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/df4d0c74a69327d848b994100662ee069776ae40/HTMLTALParser.py
print "<", tag, self.nsdict
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)
df4d0c74a69327d848b994100662ee069776ae40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/df4d0c74a69327d848b994100662ee069776ae40/HTMLTALParser.py
print "<", tag, self.nsdict
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)
df4d0c74a69327d848b994100662ee069776ae40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/df4d0c74a69327d848b994100662ee069776ae40/HTMLTALParser.py
obj=obj._getCopy(self)
def pasteFromClipboard(self,clip_id='',clip_data='',REQUEST=None): """ """
a811511462eb67d5a9c5f6eb83f8eeac1b6552d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/a811511462eb67d5a9c5f6eb83f8eeac1b6552d9/CopySupport.py
if hasattr(ob, '__call__'): return 1 else: return isinstance(ob, types.ClassType)
return hasattr(ob, '__call__') or isinstance(ob, types.ClassType)
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)
8430ae6c5d023444299a01fa4d815c7986f5ea7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8430ae6c5d023444299a01fa4d815c7986f5ea7b/Catalog.py
def catalogObject(self, object, uid, threshold=None,idxs=[]): """ Adds an object to the Catalog by iteratively applying it all indexes.
8430ae6c5d023444299a01fa4d815c7986f5ea7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8430ae6c5d023444299a01fa4d815c7986f5ea7b/Catalog.py
if index%4000 == 0: index = randid()
if index % 4000 == 0: index = randint(-2000000000, 2000000000)
def catalogObject(self, object, uid, threshold=None,idxs=[]): """ Adds an object to the Catalog by iteratively applying it all indexes.
8430ae6c5d023444299a01fa4d815c7986f5ea7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8430ae6c5d023444299a01fa4d815c7986f5ea7b/Catalog.py
index=randid()
index = randint(-2000000000, 2000000000)
def catalogObject(self, object, uid, threshold=None,idxs=[]): """ Adds an object to the Catalog by iteratively applying it all indexes.
8430ae6c5d023444299a01fa4d815c7986f5ea7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8430ae6c5d023444299a01fa4d815c7986f5ea7b/Catalog.py
% (fields[i], self._names[i], _index))
% (fields[i], self._names[i], index))
def __getitem__(self,index):
d53be4db1828076cf563123dda09807797b5d68d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/d53be4db1828076cf563123dda09807797b5d68d/RDB.py
def _delOb(self, id, value):
def _delOb(self, id):
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)
587a5c227b00b6d743bd416d3c62bcc7cfcbc94b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/587a5c227b00b6d743bd416d3c62bcc7cfcbc94b/Property.py
CatalogAwareInterface=Interface(CatalogAware)
def reindex_all(obj=None): """
63317c2664b935dd0d24567a26eab0cac246a246 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/63317c2664b935dd0d24567a26eab0cac246a246/CatalogAwarenessInterface.py
if 'Anonymous' in roles: return 1
if 'Anonymous' in object_roles: 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 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
995ab4d721e0d0e83a1b565d61aad7f69e7f302a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/995ab4d721e0d0e83a1b565d61aad7f69e7f302a/User.py