rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
if hasattr(self, 'REQUEST') and hasattr(object, '__ac_local_roles__'):
if hasattr(self, 'REQUEST') and type(self.REQUEST) != type('') and \ hasattr(object, '__ac_local_roles__'):
def _setObject(self,id,object,roles=None,user=None): v=self._checkId(id) if v is not None: id=v try: t=object.meta_type except: t=None self._objects=self._objects+({'id':id,'meta_type':t},) self._setOb(id,object) object=self._getOb(id) object.manage_afterAdd(object, self) # Try to give user the local role "Owner", but only if # no local roles have been set on the object yet. if hasattr(self, 'REQUEST') and hasattr(object, '__ac_local_roles__'): if object.__ac_local_roles__ is None: user=self.REQUEST['AUTHENTICATED_USER'] name=user.getUserName() if name != 'Anonymous User': object.manage_setLocalRoles(name, ['Owner']) return id
5ee0341f317b39889dafe1afb7abea303f5bc038 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/5ee0341f317b39889dafe1afb7abea303f5bc038/ObjectManager.py
self._stop = False
self._stop = self._closed = False
def __init__(self, name, env=None, prefix='zodb_', config=None): """Create a new storage.
ea82bc70eae6ac2afa78935c67947cd34432ac5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/ea82bc70eae6ac2afa78935c67947cd34432ac5f/BerkeleyBase.py
self._doclose()
if not self._closed: self._doclose() self._closed = True
def close(self): """Close the storage.
ea82bc70eae6ac2afa78935c67947cd34432ac5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/ea82bc70eae6ac2afa78935c67947cd34432ac5f/BerkeleyBase.py
+SimpleItem.Item.manage_options
def locked_in_version(self): return 0
09e6a202ddf687c78c33a7a6774b6900b16fb69b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/09e6a202ddf687c78c33a7a6774b6900b16fb69b/ApplicationManager.py
+SimpleItem.Item.manage_options
def locked_in_version(self): return 0
09e6a202ddf687c78c33a7a6774b6900b16fb69b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/09e6a202ddf687c78c33a7a6774b6900b16fb69b/ApplicationManager.py
class ApplicationManager(Folder,CacheManager): """System management""" __roles__=('Manager',) isPrincipiaFolderish=1 Database=DatabaseManager() Versions=VersionManager() manage=manage_main=HTMLFile('cpContents', globals()) manage_undoForm=HTMLFile('undo', globals()) def version_txt(self): if not hasattr(self, '_v_version_txt'): self._v_version_txt=version_txt() return self._v_version_txt def sys_version(self): return sys.version def sys_platform(self): return sys.platform _objects=( {'id': 'Database', 'meta_type': Database.meta_type}, {'id': 'Versions', 'meta_type': Versions.meta_type}, {'id': 'Products', 'meta_type': 'Product Management'}, )
class DebugManager(Fake, SimpleItem.Item, Acquisition.Implicit): """Debug and profiling information""" manage=manage_main=HTMLFile('debug', globals()) id ='DebugInfo' name=title='Debug Information' meta_type = name icon='p_/DebugManager_icon'
def locked_in_version(self): return 0
09e6a202ddf687c78c33a7a6774b6900b16fb69b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/09e6a202ddf687c78c33a7a6774b6900b16fb69b/ApplicationManager.py
( {'label':'Contents', 'action':'manage_main', 'help':('OFSP','Control-Panel_Contents.dtml')}, ) +Undo.UndoSupport.manage_options ) id ='Control_Panel' name=title='Control Panel' meta_type ='Control Panel' icon='p_/ControlPanel_icon' process_id=os.getpid() process_start=int(time.time()) manage_addObject=None manage_delObjects=None manage_addProperty=None manage_editProperties=None manage_delProperties=None def __init__(self): self.Products=ProductFolder() def _canCopy(self, op=0): return 0 def _init(self): pass def manage_app(self, URL2): """Return to the main management screen""" raise 'Redirect', URL2+'/manage' def process_time(self): s=int(time.time())-self.process_start d=int(s/86400) s=s-(d*86400) h=int(s/3600) s=s-(h*3600) m=int(s/60) s=s-(m*60) d=d and ('%d day%s' % (d, (d != 1 and 's' or ''))) or '' h=h and ('%d hour%s' % (h, (h != 1 and 's' or ''))) or '' m=m and ('%d min' % m) or '' s='%d sec' % s return '%s %s %s %s' % (d, h, m, s) def thread_get_ident(self): return get_ident() def db_name(self): return self._p_jar.db().getName() def db_size(self): if Globals.DatabaseVersion=='2': s=os.stat(self.db_name())[6] else: s=self._p_jar.db().getSize() if s >= 1048576.0: return '%.1fM' % (s/1048576.0) return '%.1fK' % (s/1024.0)
( {'label':'Debugging Info', 'action':'manage_main', 'help':('OFSP','DebugInfo-Debug.dtml')}, {'label':'Profiling', 'action':'manage_profile', 'help':('OFSP','DebugInfo-Profile.dtml')}, ) )
def sys_platform(self): return sys.platform
09e6a202ddf687c78c33a7a6774b6900b16fb69b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/09e6a202ddf687c78c33a7a6774b6900b16fb69b/ApplicationManager.py
def rcdeltas(self): if _v_rcs is None: self.rcsnapshot() nc=self.refdict() rc=_v_rcs rd=[] for n, c in nc.items(): try: prev=rc[n] if c > prev: rd.append( (c - prev, (c, prev, n)) ) except: pass rd.sort() rd.reverse()
09e6a202ddf687c78c33a7a6774b6900b16fb69b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/09e6a202ddf687c78c33a7a6774b6900b16fb69b/ApplicationManager.py
def rcdeltas(self): if _v_rcs is None: self.rcsnapshot() nc=self.refdict() rc=_v_rcs rd=[] for n, c in nc.items(): try: prev=rc[n] if c > prev: rd.append( (c - prev, (c, prev, n)) ) except: pass rd.sort() rd.reverse()
09e6a202ddf687c78c33a7a6774b6900b16fb69b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/09e6a202ddf687c78c33a7a6774b6900b16fb69b/ApplicationManager.py
manage_profile=HTMLFile('profile', globals()) def manage_profile_stats(self, sort='time', limit=200): """Return profile data if available""" stats=getattr(sys, '_ps_', None) if stats is None: return None output=StringIO() stdout=sys.stdout sys.stdout=output stats.strip_dirs().sort_stats(sort).print_stats(limit) sys.stdout.flush() sys.stdout=stdout return output.getvalue()
def manage_discardVersions(self, versions, REQUEST=None): "Discard some versions" db=self._p_jar.db() for v in versions: db.abortVersion(v) if REQUEST is not None: REQUEST['RESPONSE'].redirect(REQUEST['URL1']+'/manage_main')
09e6a202ddf687c78c33a7a6774b6900b16fb69b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/09e6a202ddf687c78c33a7a6774b6900b16fb69b/ApplicationManager.py
if hasattr(aq_base(ob), 'isTopLevelPrincipiaApplicationObject'):
if hasattr(aq_base(ob), 'isTopLevelPrincipiaApplicationObject') and \ ob.isTopLevelPrincipiaApplicationObject:
def is_acquired(ob): # Return true if this object is not a direct # subobject of its aq_parent object. if not hasattr(ob, 'aq_parent'): return 0 if hasattr(aq_base(ob.aq_parent), absattr(ob.id)): return 0 if hasattr(aq_base(ob), 'isTopLevelPrincipiaApplicationObject'): return 0 return 1
ff86bd9b72ef70fe24dea2340e5a39d38984529b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/ff86bd9b72ef70fe24dea2340e5a39d38984529b/common.py
if err[0] is KeyboardInterrupt:
if error[0] is KeyboardInterrupt:
def addError(self, test, error): TestResult.addError(self,test,error) self.stream.write('E') self.stream.flush() if err[0] is KeyboardInterrupt: self.shouldStop = 1
012baf7a18f42568dc02aa5d088f5d1db4e3ead3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/012baf7a18f42568dc02aa5d088f5d1db4e3ead3/unittest.py
if rawdata[i-1] != ';':
if rawdata[k-1] != ';':
def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: if self.nomoretags: self.handle_data(rawdata[i:n]) i = self.updatepos(i, n) break match = interesting.search(rawdata, i) if match: j = match.start(0) else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): if self.literal: self.handle_data(rawdata[i]) i = self.updatepos(i, i+1) continue k = self.parse_starttag(i) if k < 0: break i = self.updatepos(i, k) continue if endtagopen.match(rawdata, i): k = self.parse_endtag(i) if k < 0: break i = self.updatepos(i, k) self.literal = 0 continue if commentopen.match(rawdata, i): if self.literal: self.handle_data(rawdata[i]) i = self.updatepos(i, i+1) continue k = self.parse_comment(i) if k < 0: break i = self.updatepos(i, i+k) continue if piopen.match(rawdata, i): if self.literal: self.handle_data(rawdata[i]) i = self.updatepos(i, i+1) continue k = self.parse_pi(i) if k < 0: break i = self.updatepos(i, i+k) continue match = special.match(rawdata, i) if match: if self.literal: self.handle_data(rawdata[i]) i = self.updatepos(i, i+1) continue k = match.end(0) i = self.updatepos(i, k) continue elif rawdata[i] == '&': match = charref.match(rawdata, i) if match: name = match.group(1) self.handle_charref(name) k = match.end(0) if rawdata[i-1] != ';': k = k-1 i = self.updatepos(i, k) continue match = entityref.match(rawdata, i) if match: name = match.group(1) self.handle_entityref(name) k = match.end(0) if rawdata[i-1] != ';': k = k-1 i = self.updatepos(i, k) continue else: raise RuntimeError, 'neither < nor & ??' # We get here only if incomplete matches but # nothing else match = incomplete.match(rawdata, i) if not match: self.handle_data(rawdata[i]) i = self.updatepos(i, i+1) continue j = match.end(0) if j == n: break # Really incomplete self.handle_data(rawdata[i:j]) i = self.updatepos(self, i, j) # end while if end and i < n: self.handle_data(rawdata[i:n]) i = self.updatepos(i, n) self.rawdata = rawdata[i:] # XXX if end: check for empty stack
0b792d8094f520575040b643318b715059dada75 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/0b792d8094f520575040b643318b715059dada75/nsgmllib.py
if rawdata[i-1] != ';':
if rawdata[k-1] != ';':
def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: if self.nomoretags: self.handle_data(rawdata[i:n]) i = self.updatepos(i, n) break match = interesting.search(rawdata, i) if match: j = match.start(0) else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): if self.literal: self.handle_data(rawdata[i]) i = self.updatepos(i, i+1) continue k = self.parse_starttag(i) if k < 0: break i = self.updatepos(i, k) continue if endtagopen.match(rawdata, i): k = self.parse_endtag(i) if k < 0: break i = self.updatepos(i, k) self.literal = 0 continue if commentopen.match(rawdata, i): if self.literal: self.handle_data(rawdata[i]) i = self.updatepos(i, i+1) continue k = self.parse_comment(i) if k < 0: break i = self.updatepos(i, i+k) continue if piopen.match(rawdata, i): if self.literal: self.handle_data(rawdata[i]) i = self.updatepos(i, i+1) continue k = self.parse_pi(i) if k < 0: break i = self.updatepos(i, i+k) continue match = special.match(rawdata, i) if match: if self.literal: self.handle_data(rawdata[i]) i = self.updatepos(i, i+1) continue k = match.end(0) i = self.updatepos(i, k) continue elif rawdata[i] == '&': match = charref.match(rawdata, i) if match: name = match.group(1) self.handle_charref(name) k = match.end(0) if rawdata[i-1] != ';': k = k-1 i = self.updatepos(i, k) continue match = entityref.match(rawdata, i) if match: name = match.group(1) self.handle_entityref(name) k = match.end(0) if rawdata[i-1] != ';': k = k-1 i = self.updatepos(i, k) continue else: raise RuntimeError, 'neither < nor & ??' # We get here only if incomplete matches but # nothing else match = incomplete.match(rawdata, i) if not match: self.handle_data(rawdata[i]) i = self.updatepos(i, i+1) continue j = match.end(0) if j == n: break # Really incomplete self.handle_data(rawdata[i:j]) i = self.updatepos(self, i, j) # end while if end and i < n: self.handle_data(rawdata[i:n]) i = self.updatepos(i, n) self.rawdata = rawdata[i:] # XXX if end: check for empty stack
0b792d8094f520575040b643318b715059dada75 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/0b792d8094f520575040b643318b715059dada75/nsgmllib.py
sm= getattr(response,'setMessage',None)
try: sm= response.setMessage except: sm= None
def publish(request, module_name, after_list, debug=0, # Optimize: call_object=call_object, missing_name=missing_name, dont_publish_class=dont_publish_class, mapply=mapply, ): (bobo_before, bobo_after, object, realm, debug_mode, err_hook, validated_hook, transactions_manager)= get_module_info(module_name) parents=None try: request.processInputs() request_get=request.get response=request.response # First check for "cancel" redirect: cancel='' if request_get('SUBMIT','').strip().lower()=='cancel': cancel=request_get('CANCEL_ACTION','') if cancel: raise 'Redirect', cancel after_list[0]=bobo_after if debug_mode: response.debug_mode=debug_mode if realm and not request.get('REMOTE_USER',None): response.realm=realm if bobo_before is not None: bobo_before() # Get a nice clean path list: path=request_get('PATH_INFO').strip() request['PARENTS']=parents=[object] if transactions_manager: transactions_manager.begin() object=request.traverse(path, validated_hook=validated_hook) if transactions_manager: transactions_manager.recordMetaData(object, request) result=mapply(object, request.args, request, call_object,1, missing_name, dont_publish_class, request, bind=1) if result is not response: response.setBody(result) if transactions_manager: transactions_manager.commit() return response except: if transactions_manager: transactions_manager.abort() # DM: provide nicer error message for FTP sm= getattr(response,'setMessage',None) if sm is not None: from ZServer.medusa.asyncore import compact_traceback cl,val= sys.exc_info()[:2] sm('%s: %s %s' % (getattr(cl,'__name__',cl), val, debug_mode and compact_traceback()[-1] or '')) if err_hook is not None: if parents: parents=parents[0] try: return err_hook(parents, request, sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2], ) except Retry: # We need to try again.... if not request.supports_retry(): return err_hook(parents, request, sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2], ) newrequest=request.retry() request.close() # Free resources held by the request. try: return publish(newrequest, module_name, after_list, debug) finally: newrequest.close() else: raise
1d0408111cfe5175fdb01a81c5ea831eaf791a19 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/1d0408111cfe5175fdb01a81c5ea831eaf791a19/Publish.py
os.unlink(filename) def checkCloseNoUnlink(self):
assert not os.path.exists(filename) def checkCloseDoesUnlink(self):
def checkCreateWithFileobj(self): filename = 'commit.log' fp = open(filename, 'w+b') try: self.assertRaises(CommitLog.TruncationError, CommitLog.CommitLog, fp) finally: fp.close() os.unlink(filename)
aa3de9c148eda3d9e95edbdc591bdfb27b69db11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/aa3de9c148eda3d9e95edbdc591bdfb27b69db11/test_commitlog.py
try: assert os.path.exists(filename) finally: os.unlink(filename) assert not os.path.exists(filename)
assert not os.path.exists(filename)
def checkCloseNoUnlink(self): log = CommitLog.CommitLog() filename = log.get_filename() log.close() try: assert os.path.exists(filename) finally: os.unlink(filename) assert not os.path.exists(filename)
aa3de9c148eda3d9e95edbdc591bdfb27b69db11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/aa3de9c148eda3d9e95edbdc591bdfb27b69db11/test_commitlog.py
try: assert os.path.exists(filename) finally: os.unlink(filename) assert not os.path.exists(filename)
assert not os.path.exists(filename)
def checkDel(self): log = CommitLog.CommitLog() filename = log.get_filename() del log try: assert os.path.exists(filename) finally: os.unlink(filename) assert not os.path.exists(filename)
aa3de9c148eda3d9e95edbdc591bdfb27b69db11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/aa3de9c148eda3d9e95edbdc591bdfb27b69db11/test_commitlog.py
self._log.close(unlink=1)
try: self._log.close(unlink=1) except OSError, e: if e.errno <> errno.ENOENT: raise
def tearDown(self): self._log.close(unlink=1)
aa3de9c148eda3d9e95edbdc591bdfb27b69db11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/aa3de9c148eda3d9e95edbdc591bdfb27b69db11/test_commitlog.py
suite.addTest(CreateCommitLogTest('checkCreateNoFile')) suite.addTest(CreateCommitLogTest('checkCreateWithFilename')) suite.addTest(CreateCommitLogTest('checkCreateWithFileobj')) suite.addTest(CreateCommitLogTest('checkCloseNoUnlink')) suite.addTest(CreateCommitLogTest('checkDel')) suite.addTest(CommitLogStateTransitionTest('checkProperStart')) suite.addTest(CommitLogStateTransitionTest('checkAppendSetsOpen')) suite.addTest(CommitLogStateTransitionTest('checkPromiseSetsPromise')) suite.addTest(CommitLogStateTransitionTest('checkBadDoublePromise')) suite.addTest(CommitLogStateTransitionTest('checkFinishSetsStart')) suite.addTest(LowLevelStoreAndLoadTest('checkOneStoreAndLoad')) suite.addTest(LowLevelStoreAndLoadTest('checkTenStoresAndLoads')) suite.addTest(PacklessLogTest('checkOneStoreAndLoad')) suite.addTest(PacklessLogTest('checkTenStoresAndLoads')) suite.addTest(FullLogTest('checkOneStoreAndLoad')) suite.addTest(FullLogTest('checkOtherWriteMethods'))
suite.addTest(unittest.makeSuite(CreateCommitLogTest, 'check')) suite.addTest(unittest.makeSuite(CommitLogStateTransitionTest, 'check')) suite.addTest(unittest.makeSuite(LowLevelStoreAndLoadTest, 'check')) suite.addTest(unittest.makeSuite(PacklessLogTest, 'check')) suite.addTest(unittest.makeSuite(FullLogTest, 'check'))
def suite(): suite = unittest.TestSuite() # Creation and closing suite.addTest(CreateCommitLogTest('checkCreateNoFile')) suite.addTest(CreateCommitLogTest('checkCreateWithFilename')) suite.addTest(CreateCommitLogTest('checkCreateWithFileobj')) suite.addTest(CreateCommitLogTest('checkCloseNoUnlink')) suite.addTest(CreateCommitLogTest('checkDel')) # State transitions suite.addTest(CommitLogStateTransitionTest('checkProperStart')) suite.addTest(CommitLogStateTransitionTest('checkAppendSetsOpen')) suite.addTest(CommitLogStateTransitionTest('checkPromiseSetsPromise')) suite.addTest(CommitLogStateTransitionTest('checkBadDoublePromise')) suite.addTest(CommitLogStateTransitionTest('checkFinishSetsStart')) # Base class for storing and loading suite.addTest(LowLevelStoreAndLoadTest('checkOneStoreAndLoad')) suite.addTest(LowLevelStoreAndLoadTest('checkTenStoresAndLoads')) # PacklessLog API suite.addTest(PacklessLogTest('checkOneStoreAndLoad')) suite.addTest(PacklessLogTest('checkTenStoresAndLoads')) # FullLog API suite.addTest(FullLogTest('checkOneStoreAndLoad')) suite.addTest(FullLogTest('checkOtherWriteMethods')) return suite
aa3de9c148eda3d9e95edbdc591bdfb27b69db11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/aa3de9c148eda3d9e95edbdc591bdfb27b69db11/test_commitlog.py
self._.migrate_length()
self._migrate_length()
def index_object(self, docid, obj ,threshold=100): """ hook for (Z)Catalog """
2bdc12d5e9d853fd09b57487bcc4ed9a87c5d58d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/2bdc12d5e9d853fd09b57487bcc4ed9a87c5d58d/PathIndex.py
self._.migrate_length()
self._migrate_length()
def unindex_object(self, docid): """ hook for (Z)Catalog """
2bdc12d5e9d853fd09b57487bcc4ed9a87c5d58d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/2bdc12d5e9d853fd09b57487bcc4ed9a87c5d58d/PathIndex.py
if jar is None: return 1
if jar is None: if hasattr(self, 'aq_parent') and hasattr(self.aq_parent, '_p_jar'): jar=self.aq_parent._p_jar if jar is None: return 0
def modified_in_session(self):
1254bb47e042080a9a64fed0d28cca8ed35d3a39 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/1254bb47e042080a9a64fed0d28cca8ed35d3a39/SimpleItem.py
ostream = tempfile.NamedTemporaryFile(suffix='.xml')
handle, path = tempfile.mkstemp(suffix='.xml')
def test_export_import_as_file_idempotent(self): from OFS.DTMLMethod import DTMLMethod from OFS.XMLExportImport import exportXML from OFS.XMLExportImport import importXML
77e086c8919a0209ebd7eda0130e6c30bbba3b4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/77e086c8919a0209ebd7eda0130e6c30bbba3b4f/test_XMLExportImport.py
ostream.flush() newobj = importXML(connection, ostream.name)
ostream.close() newobj = importXML(connection, path) self.failUnless(isinstance(newobj, DTMLMethod)) self.assertEqual(newobj.read(), dm.read())
def test_export_import_as_file_idempotent(self): from OFS.DTMLMethod import DTMLMethod from OFS.XMLExportImport import exportXML from OFS.XMLExportImport import importXML
77e086c8919a0209ebd7eda0130e6c30bbba3b4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/77e086c8919a0209ebd7eda0130e6c30bbba3b4f/test_XMLExportImport.py
ostream.close()
os.remove(path)
def test_export_import_as_file_idempotent(self): from OFS.DTMLMethod import DTMLMethod from OFS.XMLExportImport import exportXML from OFS.XMLExportImport import importXML
77e086c8919a0209ebd7eda0130e6c30bbba3b4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/77e086c8919a0209ebd7eda0130e6c30bbba3b4f/test_XMLExportImport.py
self.failUnless(isinstance(newobj, DTMLMethod)) self.assertEqual(newobj.read(), dm.read())
def test_export_import_as_file_idempotent(self): from OFS.DTMLMethod import DTMLMethod from OFS.XMLExportImport import exportXML from OFS.XMLExportImport import importXML
77e086c8919a0209ebd7eda0130e6c30bbba3b4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/77e086c8919a0209ebd7eda0130e6c30bbba3b4f/test_XMLExportImport.py
ostream = tempfile.NamedTemporaryFile(suffix='.xml')
handle, path = tempfile.mkstemp(suffix='.xml')
def test_OFS_ObjectManager__importObjectFromFile_xml(self): from OFS.DTMLMethod import DTMLMethod from OFS.Folder import Folder from OFS.XMLExportImport import exportXML
77e086c8919a0209ebd7eda0130e6c30bbba3b4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/77e086c8919a0209ebd7eda0130e6c30bbba3b4f/test_XMLExportImport.py
ostream.flush() sub._importObjectFromFile(ostream.name, 0, 0)
ostream.close() sub._importObjectFromFile(path, 0, 0)
def test_OFS_ObjectManager__importObjectFromFile_xml(self): from OFS.DTMLMethod import DTMLMethod from OFS.Folder import Folder from OFS.XMLExportImport import exportXML
77e086c8919a0209ebd7eda0130e6c30bbba3b4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/77e086c8919a0209ebd7eda0130e6c30bbba3b4f/test_XMLExportImport.py
ostream.close()
os.remove(path)
def test_OFS_ObjectManager__importObjectFromFile_xml(self): from OFS.DTMLMethod import DTMLMethod from OFS.Folder import Folder from OFS.XMLExportImport import exportXML
77e086c8919a0209ebd7eda0130e6c30bbba3b4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/77e086c8919a0209ebd7eda0130e6c30bbba3b4f/test_XMLExportImport.py
return self.objectIds()
return len(self.objectIds())
def hasChildNodes(self): """Returns true if the node has any children, false if it doesn't. """ return self.objectIds()
c8ae5ffbca873780c4e78ef8f80593471370b673 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c8ae5ffbca873780c4e78ef8f80593471370b673/ZDOM.py
if (child.getNodeType==1 and child.getTagName()==tagname or tagname== '*'):
if (child.getNodeType()==ELEMENT_NODE and \ child.getTagName()==tagname or tagname== '*'):
def getElementsByTagName(self, tagname): """ Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree. Parameter: tagname The name of the tag to match (* = all tags). Return Value: A new NodeList object containing all the matched Elements. """ nodeList = [] for child in self.objectValues(): if (child.getNodeType==1 and child.getTagName()==tagname or tagname== '*'): nodeList.append( child ) n1 = child.getElementsByTagName(tagname) nodeList = nodeList + n1._data return NodeList(nodeList)
c8ae5ffbca873780c4e78ef8f80593471370b673 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c8ae5ffbca873780c4e78ef8f80593471370b673/ZDOM.py
""" Elements that allow DOM access to Zope properties of type 'string'. Note: This sub-class should only be used by PropertyManagers """
def getElementsByTagName(self, tagname): """ Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree. Parameter: tagname The name of the tag to match (* = all tags). Return Value: A new NodeList object containing all the matched Elements. """ nodeList = [] for child in self.objectValues(): if (child.getNodeType==1 and child.getTagName()==tagname or tagname== '*'): nodeList.append( child ) n1 = child.getElementsByTagName(tagname) nodeList = nodeList + n1._data return NodeList(nodeList)
c8ae5ffbca873780c4e78ef8f80593471370b673 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c8ae5ffbca873780c4e78ef8f80593471370b673/ZDOM.py
attributes = self.propdict() list = [] for a in attributes.keys(): attributeNode = Attr(a, attributes[a], self.getOwnerDocument()) list.append(attributeNode) return NamedNodeMap(list)
attribs={} for p in self._properties: if p['type'] == 'string': name=p['id'] attrib=Attr(name, self.getProperty(name,'')).__of__(self) attribs[name]=attrib return NamedNodeMap(attribs)
def getAttributes(self): attributes = self.propdict() list = [] for a in attributes.keys(): attributeNode = Attr(a, attributes[a], self.getOwnerDocument()) list.append(attributeNode) return NamedNodeMap(list)
c8ae5ffbca873780c4e78ef8f80593471370b673 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c8ae5ffbca873780c4e78ef8f80593471370b673/ZDOM.py
return str(self.getProperty(name))
if self.getPropertyType(name) == 'string': return self.getProperty(name,'')
def getAttribute(self, name): return str(self.getProperty(name))
c8ae5ffbca873780c4e78ef8f80593471370b673 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c8ae5ffbca873780c4e78ef8f80593471370b673/ZDOM.py
attributes = self.propdict() if attributes.has_key(name): node = Attr(name, self.getProperty(name), self.getOwnerDocument()) return node return None
if self.getPropertyType(name) == 'string': return Attr(name, self.getProperty(name,'')).__of__(self) return None class ElementWithTitle(Element): """ Elements that allow DOM access to Zope title property. Note: Don't use this sub-class for PropertyManagers """ def getAttributes(self): if self.getAttribute('title'): return NamedNodeMap({'title' : self.title}) return NamedNodeMap() def getAttribute(self, name): if name=='title' and hasattr(self.aq_base, 'title'): return self.title return '' def getAttributeNode(self, name): value=self.getAttribute(name) if value: return Attr(name, value).__of__(self) return None
def getAttributeNode(self, name): attributes = self.propdict() if attributes.has_key(name): node = Attr(name, self.getProperty(name), self.getOwnerDocument()) return node return None
c8ae5ffbca873780c4e78ef8f80593471370b673 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c8ae5ffbca873780c4e78ef8f80593471370b673/ZDOM.py
def __init__(self,list=[]): self._data = list self.length = len(list)
def __init__(self,list=None): self._data = list or []
def __init__(self,list=[]): self._data = list self.length = len(list)
c8ae5ffbca873780c4e78ef8f80593471370b673 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c8ae5ffbca873780c4e78ef8f80593471370b673/ZDOM.py
if index >= self.length: return None return self._data[index] item = __getitem__
try: return self._data[index] except IndexError: return None
def __getitem__(self, index): """Returns the index-th item in the collection""" if index >= self.length: return None return self._data[index]
c8ae5ffbca873780c4e78ef8f80593471370b673 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c8ae5ffbca873780c4e78ef8f80593471370b673/ZDOM.py
return self.length
return len(self._data) __len__=getLength
def getLength(self): """The length of the NodeList""" return self.length
c8ae5ffbca873780c4e78ef8f80593471370b673 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c8ae5ffbca873780c4e78ef8f80593471370b673/ZDOM.py
self.length = len(data)
def __init__(self, data=None): if data is None : data = {} self._data = data self.length = len(data)
c8ae5ffbca873780c4e78ef8f80593471370b673 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c8ae5ffbca873780c4e78ef8f80593471370b673/ZDOM.py
return self._data[index]
try: return self._data.values()[index] except IndexError: return None
def __getitem__(self, index): """Returns the index-th item in the map""" return self._data[index]
c8ae5ffbca873780c4e78ef8f80593471370b673 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c8ae5ffbca873780c4e78ef8f80593471370b673/ZDOM.py
return self.length
return len(self._data) __len__ = getLength
def getLength(self): """The length of the NodeList""" return self.length
c8ae5ffbca873780c4e78ef8f80593471370b673 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c8ae5ffbca873780c4e78ef8f80593471370b673/ZDOM.py
class Attr(Node): def __init__(self, name, value, ownerDocument): self.nodeName = name
class Attr(Acquisition.Implicit, Node): def __init__(self, name, value):
def getNamedItem(self, name): """Retrieves a node specified by name. Parameters: name Name of a node to retrieve. Return Value A Node (of any type) with the specified name, or null if the specified name did not identify any node in the map. """ if self._data.has_key(name): return self._data[name] return None
c8ae5ffbca873780c4e78ef8f80593471370b673 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c8ae5ffbca873780c4e78ef8f80593471370b673/ZDOM.py
self.ownerDocument = ownerDocument
def __init__(self, name, value, ownerDocument): self.nodeName = name # attr attributes self.name = name self.value = value self.specified = 1 # attr nodes are specified because properties # don't exist without having a value self.ownerDocument = ownerDocument
c8ae5ffbca873780c4e78ef8f80593471370b673 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c8ae5ffbca873780c4e78ef8f80593471370b673/ZDOM.py
def getOwnerDocument(self): return self.ownerDocument
def getSpecified(self): return self.specified
def getNodeType(self): return ATTRIBUTE_NODE
c8ae5ffbca873780c4e78ef8f80593471370b673 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/c8ae5ffbca873780c4e78ef8f80593471370b673/ZDOM.py
tree = self.parseQueryEx(query)
tree = self.parseQuery(query)
def parseQueryEx(self, query): tree = self.parseQueryEx(query) ignored = self.getIgnored() return tree, ignored
98607a5c90ddf186bbecc81dbf61abc7d7fa43d1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/98607a5c90ddf186bbecc81dbf61abc7d7fa43d1/QueryParser.py
def __init__(self, stdin, environ, response, clean=0, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=regex.compile( ':[a-zA-Z][a-zA-Z0-9_]+$' ).search, rfind=string.rfind, ): # Avoid the overhead of scrubbing the environment in the # case of request cloning for traversal purposes. If the # clean flag is set, we know we can use the passed in # environ dict directly.
12a4e8aada7d58a8168558139d7eed2a699794fc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/12a4e8aada7d58a8168558139d7eed2a699794fc/HTTPRequest.py
l = form[keys] for x in values: if getattr(x, '__class__',0) is record: for k, v in x.__dict__.items(): for y in l: if not hasattr(y, k): setattr(y, k, v) else: if not a in l: l.append(a) form[keys] = l
pass
def __init__(self, stdin, environ, response, clean=0, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=regex.compile( ':[a-zA-Z][a-zA-Z0-9_]+$' ).search, rfind=string.rfind, ): # Avoid the overhead of scrubbing the environment in the # case of request cloning for traversal purposes. If the # clean flag is set, we know we can use the passed in # environ dict directly.
12a4e8aada7d58a8168558139d7eed2a699794fc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/12a4e8aada7d58a8168558139d7eed2a699794fc/HTTPRequest.py
'manage_advancedForm', 'PrincipiaSearchSource'
'manage_advancedForm', 'PrincipiaSearchSource', 'document_src'
def validate(self, inst, parent, name, value, md): return getSecurityManager().validate(inst, parent, name, value)
975a1b96dd813cc2fd8f107a96c690f0e5178d12 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/975a1b96dd813cc2fd8f107a96c690f0e5178d12/DA.py
'manage_product_zclass_info')),
'manage_product_zclass_info', 'PUT', 'manage_FTPput')),
def validate(self, inst, parent, name, value, md): return getSecurityManager().validate(inst, parent, name, value)
975a1b96dd813cc2fd8f107a96c690f0e5178d12 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/975a1b96dd813cc2fd8f107a96c690f0e5178d12/DA.py
default_content_type = 'text/plain' def document_src(self, REQUEST=None, RESPONSE=None): """Return unprocessed document source.""" if RESPONSE is not None: RESPONSE.setHeader('Content-Type', 'text/plain') return '<params>%s</params>\n%s' % (self.arguments_src, self.src) def manage_FTPget(self): """Get source for FTP download""" self.REQUEST.RESPONSE.setHeader('Content-Type', 'text/plain') return '<params>%s</params>\n%s' % (self.arguments_src, self.src) def PUT(self, REQUEST, RESPONSE): """Handle put requests""" self.dav__init(REQUEST, RESPONSE) body = REQUEST.get('BODY', '') m = re.match('\s*<params>(.*)</params>\s*\n', body, re.I) if m: self.arguments_src = m.group(1) self._arg=parse(self.arguments_src) body = body[m.end():] template = body self.src = template self.template=t=self.template_class(template) t.cook() self._v_cache={}, Bucket() RESPONSE.setStatus(204) return RESPONSE
def PrincipiaSearchSource(self): """Return content for use by the Find machinery.""" return '%s\n%s' % (self.arguments_src, self.src)
975a1b96dd813cc2fd8f107a96c690f0e5178d12 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/975a1b96dd813cc2fd8f107a96c690f0e5178d12/DA.py
path=urllib.unquote(string.split(URL2, REQUEST.script)[1])
path=string.split(URL2, REQUEST.script) if len(path) > 1: path=path[1] else: path='' path=urllib.unquote(path)
def manage_catalogFoundItems(self, REQUEST, RESPONSE, URL2, URL1, obj_metatypes=None, obj_ids=None, obj_searchterm=None, obj_expr=None, obj_mtime=None, obj_mspec=None, obj_roles=None, obj_permission=None): """ Find object according to search criteria and Catalog them """
2413d142cbaa7b5b74a9907119a4e9760c3f5111 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/2413d142cbaa7b5b74a9907119a4e9760c3f5111/ZCatalog.py
if nargs.split()=='':
if nargs.strip()=='':
def __init__(self, blocks): tname, args, section = blocks[0]
5ceff2c45166aa9aa2b66d1afe0893a73a67b512 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/5ceff2c45166aa9aa2b66d1afe0893a73a67b512/DT_Try.py
t.write(open('input/TeeShop1.html').read()) expect = open('output/TeeShop1.html').read() util.check_html(expect, t(getProducts=self.getProducts))
t.write(open('input/TeeShop2.html').read()) expect = open('output/TeeShop2.html').read() out = t(getProducts=self.getProducts) util.check_html(expect, out)
def check2(self): self.folder.laf.write(open('input/TeeShopLAF.html').read())
373be3802ded3f60ea752c5f47cc0af251428116 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/373be3802ded3f60ea752c5f47cc0af251428116/testHTMLTests.py
t.write(open('input/TeeShop2.html').read()) expect = open('output/TeeShop2.html').read() util.check_html(expect, t(getProducts=self.getProducts))
t.write(open('input/TeeShop1.html').read()) expect = open('output/TeeShop1.html').read() out = t(getProducts=self.getProducts) util.check_html(expect, out)
def check3(self): self.folder.laf.write(open('input/TeeShopLAF.html').read())
373be3802ded3f60ea752c5f47cc0af251428116 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/373be3802ded3f60ea752c5f47cc0af251428116/testHTMLTests.py
def check3(self): self.folder.laf.write(open('input/TeeShopLAF.html').read())
373be3802ded3f60ea752c5f47cc0af251428116 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/373be3802ded3f60ea752c5f47cc0af251428116/testHTMLTests.py
LOG('Zope', INFO, 'Checking product: %s' % product.id)
LOG('Zope', INFO, 'Searching in product: %s' % product.id)
def checkGlobalRegistry(self, rebuild=1): """Check the global (product) registry for problems, which can be caused by disk-based products being deleted and other things that Zope cannot know about. If rebuild is true, the global registry will be rebuilt automatically if a problem is found.
8b47dcb4d7182cde7f464983d969a7e5b5d45ee3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8b47dcb4d7182cde7f464983d969a7e5b5d45ee3/Application.py
LOG('Zope', WARNING, 'Successfully rebuilt global product registry')
try: if hasattr(ob, '_register') and hasattr(ob, '_zclass_'): ob._register() if hasattr(ob, 'objectItems'): m = list(ob.objectItems()) items.extend(m) if hasattr(ob, 'propertysheets'): ps = ob.propertysheets if (hasattr(ps, 'methods') and hasattr(ps.methods, 'objectItems')): m = list(ps.methods.objectItems()) items.extend(m) except: LOG('Zope', WARNING, 'Broken objects exist in product %s.' % product.id) idx = idx + 1 LOG('Zope', INFO, 'Successfully rebuilt global product registry')
def checkGlobalRegistry(self, rebuild=1): """Check the global (product) registry for problems, which can be caused by disk-based products being deleted and other things that Zope cannot know about. If rebuild is true, the global registry will be rebuilt automatically if a problem is found.
8b47dcb4d7182cde7f464983d969a7e5b5d45ee3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8b47dcb4d7182cde7f464983d969a7e5b5d45ee3/Application.py
def checkGlobalRegistry(self, rebuild=1): """Check the global (product) registry for problems, which can be caused by disk-based products being deleted and other things that Zope cannot know about. If rebuild is true, the global registry will be rebuilt automatically if a problem is found.
8b47dcb4d7182cde7f464983d969a7e5b5d45ee3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8b47dcb4d7182cde7f464983d969a7e5b5d45ee3/Application.py
'A problem was found in the global product registry but ' \
'A problem was found in the global product registry but '
def initialize(app): # Initialize the application # Initialize the cache: app.Control_Panel.initialize_cache() # The following items marked b/c are backward compatibility hacks # which make sure that expected system objects are added to the # bobobase. This is required because the bobobase in use may pre- # date the introduction of certain system objects such as those # which provide Lever support. # b/c: Ensure that Control Panel exists. if not hasattr(app, 'Control_Panel'): cpl=ApplicationManager() cpl._init() app._setObject('Control_Panel', cpl) get_transaction().note('Added Control_Panel') get_transaction().commit() # b/c: Ensure that a ProductFolder exists. if not hasattr(app.Control_Panel.aq_base, 'Products'): app.Control_Panel.Products=App.Product.ProductFolder() get_transaction().note('Added Control_Panel.Products') get_transaction().commit() # b/c: Ensure that std err msg exists. if not hasattr(app, 'standard_error_message'): import Document Document.manage_addDocument( app, 'standard_error_message', 'Standard Error Message', _standard_error_msg) get_transaction().note('Added standard_error_message') get_transaction().commit() # b/c: Ensure that Owner role exists. if hasattr(app, '__ac_roles__') and not ('Owner' in app.__ac_roles__): app.__ac_roles__=app.__ac_roles__ + ('Owner',) get_transaction().note('Added Owner role') get_transaction().commit() # Make sure we have Globals root=app._p_jar.root() if not root.has_key('ZGlobals'): import BTree app._p_jar.root()['ZGlobals']=BTree.BTree() get_transaction().note('Added Globals') get_transaction().commit() # Install the initial user. if hasattr(app, 'acl_users'): users = app.acl_users if hasattr(users, '_createInitialUser'): app.acl_users._createInitialUser() get_transaction().note('Created initial user') get_transaction().commit() install_products(app) # Check the global product registry for problems. Note that if the # check finds problems but fails to successfully rebuild the global # registry we abort the transaction so that we don't leave it in an # indeterminate state. try: if app.checkGlobalRegistry(): get_transaction().note('Rebuilt global product registry') get_transaction().commit() except: LOG('Zope', ERROR, 'A problem was found in the global product registry but ' \ 'the attempt to rebuild the registry failed.', error=sys.exc_info()) get_transaction().abort()
8b47dcb4d7182cde7f464983d969a7e5b5d45ee3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/8b47dcb4d7182cde7f464983d969a7e5b5d45ee3/Application.py
self.refreshCatalog(clear=1)
pgthreshold = self._getProgressThreshold() handler = (pgthreshold > 0) and ZLogHandler(pgthreshold) or None self.refreshCatalog(clear=1, pghandler=handler) print handler
def manage_catalogReindex(self, REQUEST, RESPONSE, URL1): """ clear the catalog, then re-index everything """
d2d5544a874a00d7efdf0cedc6e1b2b35da261a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/d2d5544a874a00d7efdf0cedc6e1b2b35da261a7/ZCatalog.py
def refreshCatalog(self, clear=0):
def refreshCatalog(self, clear=0, pghandler=None):
def refreshCatalog(self, clear=0): """ re-index everything we can find """
d2d5544a874a00d7efdf0cedc6e1b2b35da261a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/d2d5544a874a00d7efdf0cedc6e1b2b35da261a7/ZCatalog.py
LOG('ZCatalog', BLATHER, 'Starting recataloging of ZCatalog at %s' % self.absolute_url(1))
def refreshCatalog(self, clear=0): """ re-index everything we can find """
d2d5544a874a00d7efdf0cedc6e1b2b35da261a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/d2d5544a874a00d7efdf0cedc6e1b2b35da261a7/ZCatalog.py
LOG('ZCatalog', BLATHER, 'Recataloging object %s (%d/%d)' % (p, i, num_objects))
def refreshCatalog(self, clear=0): """ re-index everything we can find """
d2d5544a874a00d7efdf0cedc6e1b2b35da261a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/d2d5544a874a00d7efdf0cedc6e1b2b35da261a7/ZCatalog.py
LOG('ZCatalog', ERROR, 'Recataloging object at %s failed' % p, error=sys.exc_info()) LOG('ZCatalog', BLATHER, 'Recataloging of ZCatalog at %s terminated' % self.absolute_url(1))
LOG.error('Recataloging object at %s failed' % p, exc_info=sys.exc_info()) if pghandler: pghandler.finish()
def refreshCatalog(self, clear=0): """ re-index everything we can find """
d2d5544a874a00d7efdf0cedc6e1b2b35da261a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/d2d5544a874a00d7efdf0cedc6e1b2b35da261a7/ZCatalog.py
if compress: result = ':' + b2a(zlib.compress(result, 9))
if compress and len(result) > 2: zresult = ':' + b2a(zlib.compress(result, 9)) if len(zresult) < len(result): result = zresult
def encodeExpansion(nodes, compress=1): '''Encode the expanded node ids of a tree into a string. Accepts a list of nodes, such as that produced by root.flat(). Marks each expanded node with an expansion_number attribute. Since node ids are encoded, the resulting string is safe for use in cookies and URLs. ''' steps = [] last_depth = -1 n = 0 for node in nodes: if node.state <=0: continue dd = last_depth - node.depth + 1 last_depth = node.depth if dd > 0: steps.append('_' * dd) steps.append(node.id) node.expansion_number = n n = n + 1 result = ':'.join(steps) if compress: result = ':' + b2a(zlib.compress(result, 9)) return result
36edcfae887a1d0da7df93cfb1a7677c9a73a34a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/36edcfae887a1d0da7df93cfb1a7677c9a73a34a/Tree.py
if tag in EMPTY_HTML_TAGS: return self.handle_startendtag(tag, attrs)
def handle_starttag(self, tag, attrs): if tag in EMPTY_HTML_TAGS: return self.handle_startendtag(tag, attrs) self.close_para_tags(tag) self.tagstack.append(tag) self.scan_xmlns(attrs) attrlist, taldict, metaldict = self.extract_attrs(attrs) self.gen.emitStartElement(tag, attrlist, taldict, metaldict, self.getpos())
42be3b5fb189ad772250cd5eb34d5bd59d6bb8d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/42be3b5fb189ad772250cd5eb34d5bd59d6bb8d7/HTMLTALParser.py
if implied > 0: if tag in TIGHTEN_IMPLICIT_CLOSE_TAGS: white = self.gen.unEmitWhitespace() self.gen.emitEndElement(tag, implied=implied) if white: self.gen.emitRawText(white) else: self.gen.emitEndElement(tag, implied=implied)
isend = (implied < 0) if tag in TIGHTEN_IMPLICIT_CLOSE_TAGS: white = self.gen.unEmitWhitespace() else: white = None self.gen.emitEndElement(tag, isend=isend, implied=implied) if white: self.gen.emitRawText(white)
def implied_endtag(self, tag, implied): assert tag == self.tagstack[-1] assert implied in (-1, 1, 2) if implied > 0: if tag in TIGHTEN_IMPLICIT_CLOSE_TAGS: # Pick out trailing whitespace from the program, and # insert the close tag before the whitespace. white = self.gen.unEmitWhitespace() self.gen.emitEndElement(tag, implied=implied) if white: self.gen.emitRawText(white) else: self.gen.emitEndElement(tag, implied=implied) self.tagstack.pop() self.pop_xmlns()
42be3b5fb189ad772250cd5eb34d5bd59d6bb8d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/42be3b5fb189ad772250cd5eb34d5bd59d6bb8d7/HTMLTALParser.py
def addIndex(self, name, type,extra=None):
4064b327fefdf4bdd3eafccc24ea76432e7c06ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/4064b327fefdf4bdd3eafccc24ea76432e7c06ab/ZCatalog.py
def addIndex(self, name, type,extra=None):
4064b327fefdf4bdd3eafccc24ea76432e7c06ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/4064b327fefdf4bdd3eafccc24ea76432e7c06ab/ZCatalog.py
def delIndex(self, name ):
4064b327fefdf4bdd3eafccc24ea76432e7c06ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/4064b327fefdf4bdd3eafccc24ea76432e7c06ab/ZCatalog.py
self._catalog.indexes[name].clear()
self._catalog.getIndex(name).clear()
def clearIndex(self, name):
4064b327fefdf4bdd3eafccc24ea76432e7c06ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/4064b327fefdf4bdd3eafccc24ea76432e7c06ab/ZCatalog.py
if self.getAttribute('title'): return NamedNodeMap({'title' : self.title})
title = self.getAttributeNode('title') if title is not None: return NamedNodeMap({'title':title})
def getAttributes(self): """Returns a NamedNodeMap containing the attributes of this node (if it is an element) or None otherwise.""" if self.getAttribute('title'): return NamedNodeMap({'title' : self.title}) return NamedNodeMap()
6ab2d2564d13775f9ee47ebe419fe3cc0454cddf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/6ab2d2564d13775f9ee47ebe419fe3cc0454cddf/ZDOM.py
warn("\nZCatalog query using '%s' detected.\nUsing query parameters ending with '_usage' is deprecated.\nConsider using record-style parameters instead (see lib/python/Products/PluggableIndexes/README.txt for details)" % usage_param, DeprecationWarning)
warn("\nZCatalog query using '%s' detected.\nUsing query parameters ending with '_usage' is deprecated.\nConsider using record-style parameters instead (see lib/python/Products/PluginIndexes/README.txt for details)" % usage_param, DeprecationWarning)
def __init__(self, request, iid, options=[]): """ parse a request from the ZPublisher and return a uniform datastructure back to the _apply_index() method of the index
bfcfbb2557df367b95a8f9f7b3e746503113556f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/bfcfbb2557df367b95a8f9f7b3e746503113556f/util.py
"An integer was expected in the value '%s'" % escape(v)
"An integer was expected in the value %s" % escape(`v`)
def field2int(v): if isinstance(v, (ListType, TupleType)): return map(field2int, v) v = field2string(v) if v: try: return int(v) except ValueError: raise ValueError, ( "An integer was expected in the value '%s'" % escape(v) ) raise ValueError, 'Empty entry when <strong>integer</strong> expected'
fca9a010fcede1e9ef026951f09eadb0dcac800c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/fca9a010fcede1e9ef026951f09eadb0dcac800c/Converters.py
"A floating-point number was expected in the value '%s'" % escape(v)
"A floating-point number was expected in the value %s" % escape(`v`)
def field2float(v): if isinstance(v, (ListType, TupleType)): return map(field2float, v) v = field2string(v) if v: try: return float(v) except ValueError: raise ValueError, ( "A floating-point number was expected in the value '%s'" % escape(v) ) raise ValueError, ( 'Empty entry when <strong>floating-point number</strong> expected')
fca9a010fcede1e9ef026951f09eadb0dcac800c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/fca9a010fcede1e9ef026951f09eadb0dcac800c/Converters.py
"A long integer was expected in the value '%s'" % escape(v)
"A long integer was expected in the value %s" % escape(`v`)
def field2long(v): if isinstance(v, (ListType, TupleType)): return map(field2long, v) v = field2string(v) # handle trailing 'L' if present. if v[-1:] in ('L', 'l'): v = v[:-1] if v: try: return long(v) except ValueError: raise ValueError, ( "A long integer was expected in the value '%s'" % escape(v) ) raise ValueError, 'Empty entry when <strong>integer</strong> expected'
fca9a010fcede1e9ef026951f09eadb0dcac800c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/fca9a010fcede1e9ef026951f09eadb0dcac800c/Converters.py
raise DateTime.SyntaxError, escape(e)
raise DateTime.SyntaxError, "Invalid DateTime "+escape(`v`)
def field2date(v): v = field2string(v) try: v = DateTime(v) except DateTime.SyntaxError, e: raise DateTime.SyntaxError, escape(e) return v
fca9a010fcede1e9ef026951f09eadb0dcac800c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/fca9a010fcede1e9ef026951f09eadb0dcac800c/Converters.py
raise DateTime.SyntaxError, escape(e)
raise DateTime.SyntaxError, "Invalid DateTime "+escape(`v`)
def field2date_international(v): v = field2string(v) try: v = DateTime(v, datefmt="international") except DateTime.SyntaxError, e: raise DateTime.SyntaxError, escape(e) return v
fca9a010fcede1e9ef026951f09eadb0dcac800c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/fca9a010fcede1e9ef026951f09eadb0dcac800c/Converters.py
setup(name="zope",
setup(name="zopex30",
def __init__(self, *attrs): Distribution.__init__(self, *attrs) self.cmdclass['build'] = MyBuilder self.cmdclass['build_ext'] = MyExtBuilder self.cmdclass['install_lib'] = MyLibInstaller
0c3dd3abb8accd3ce6d20ebd50f9a4389b6332e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/0c3dd3abb8accd3ce6d20ebd50f9a4389b6332e5/setup.py
headers = ["persistent/cPersistence.h", "zope/proxy/proxy.h"], scripts = [],
def __init__(self, *attrs): Distribution.__init__(self, *attrs) self.cmdclass['build'] = MyBuilder self.cmdclass['build_ext'] = MyExtBuilder self.cmdclass['install_lib'] = MyLibInstaller
0c3dd3abb8accd3ce6d20ebd50f9a4389b6332e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/0c3dd3abb8accd3ce6d20ebd50f9a4389b6332e5/setup.py
def __init__(self, *attrs): Distribution.__init__(self, *attrs) self.cmdclass['build'] = MyBuilder self.cmdclass['build_ext'] = MyExtBuilder self.cmdclass['install_lib'] = MyLibInstaller
0c3dd3abb8accd3ce6d20ebd50f9a4389b6332e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/0c3dd3abb8accd3ce6d20ebd50f9a4389b6332e5/setup.py
setup( name='Five', author='Martijn Faassen', packages=['Products.Five'], data_files=[['Products/Five', ['Products/Five/*']], ['Products/Five/demo', ['Products/Five/demo/*']], ['Products/Five/doc', ['Products/Five/doc/*']], ['Products/Five/skel', ['Products/Five/skel/*']], ['Products/Five/tests', ['Products/Five/tests/*']], ], )
def __init__(self, *attrs): Distribution.__init__(self, *attrs) self.cmdclass['build'] = MyBuilder self.cmdclass['build_ext'] = MyExtBuilder self.cmdclass['install_lib'] = MyLibInstaller
0c3dd3abb8accd3ce6d20ebd50f9a4389b6332e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/0c3dd3abb8accd3ce6d20ebd50f9a4389b6332e5/setup.py
and not self._isPasswordEncrypted(pw):
and not self._isPasswordEncrypted(password):
def _doAddUser(self, name, password, roles, domains, **kw): """Create a new user""" if password is not None and self.encrypt_passwords \ and not self._isPasswordEncrypted(pw): password = self._encryptPassword(password) self.data[name]=User(name,password,roles,domains)
6880502f4d688bc0e32133d714eb90e7e4410e4e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/6880502f4d688bc0e32133d714eb90e7e4410e4e/User.py
if sys.platform != 'win32': locale.setlocale(locale.LC_ALL, 'de_DE.ISO8859-1') else: locale.setlocale(locale.LC_ALL, 'German_Germany.1252') words = ['mlltonne waschbr behrde berflieger']
try: if sys.platform != 'win32': locale.setlocale(locale.LC_ALL, 'de_DE.ISO8859-1') else: locale.setlocale(locale.LC_ALL, 'German_Germany.1252') except locale.Error: return expected = ['m\xfclltonne', 'waschb\xe4r', 'beh\xf6rde', '\xfcberflieger'] words = [" ".join(expected)]
def testSplitterLocaleAwareness(self): from Products.ZCTextIndex.HTMLSplitter import HTMLWordSplitter import locale loc = locale.setlocale(locale.LC_ALL) # get current locale # set German locale if sys.platform != 'win32': locale.setlocale(locale.LC_ALL, 'de_DE.ISO8859-1') else: locale.setlocale(locale.LC_ALL, 'German_Germany.1252') words = ['mlltonne waschbr behrde berflieger'] words = Splitter().process(words) self.assertEqual( words, ['mlltonne', 'waschbr', 'behrde', 'berflieger']) words = HTMLWordSplitter().process(words) self.assertEqual( words, ['mlltonne', 'waschbr', 'behrde', 'berflieger']) locale.setlocale(locale.LC_ALL, loc) # restore saved locale
d2e5544e12029c5a6374c1075a96832a38c8d0fe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/d2e5544e12029c5a6374c1075a96832a38c8d0fe/testLexicon.py
self.assertEqual( words, ['mlltonne', 'waschbr', 'behrde', 'berflieger'])
self.assertEqual(words, expected)
def testSplitterLocaleAwareness(self): from Products.ZCTextIndex.HTMLSplitter import HTMLWordSplitter import locale loc = locale.setlocale(locale.LC_ALL) # get current locale # set German locale if sys.platform != 'win32': locale.setlocale(locale.LC_ALL, 'de_DE.ISO8859-1') else: locale.setlocale(locale.LC_ALL, 'German_Germany.1252') words = ['mlltonne waschbr behrde berflieger'] words = Splitter().process(words) self.assertEqual( words, ['mlltonne', 'waschbr', 'behrde', 'berflieger']) words = HTMLWordSplitter().process(words) self.assertEqual( words, ['mlltonne', 'waschbr', 'behrde', 'berflieger']) locale.setlocale(locale.LC_ALL, loc) # restore saved locale
d2e5544e12029c5a6374c1075a96832a38c8d0fe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/d2e5544e12029c5a6374c1075a96832a38c8d0fe/testLexicon.py
self.assertEqual( words, ['mlltonne', 'waschbr', 'behrde', 'berflieger'])
self.assertEqual(words, expected)
def testSplitterLocaleAwareness(self): from Products.ZCTextIndex.HTMLSplitter import HTMLWordSplitter import locale loc = locale.setlocale(locale.LC_ALL) # get current locale # set German locale if sys.platform != 'win32': locale.setlocale(locale.LC_ALL, 'de_DE.ISO8859-1') else: locale.setlocale(locale.LC_ALL, 'German_Germany.1252') words = ['mlltonne waschbr behrde berflieger'] words = Splitter().process(words) self.assertEqual( words, ['mlltonne', 'waschbr', 'behrde', 'berflieger']) words = HTMLWordSplitter().process(words) self.assertEqual( words, ['mlltonne', 'waschbr', 'behrde', 'berflieger']) locale.setlocale(locale.LC_ALL, loc) # restore saved locale
d2e5544e12029c5a6374c1075a96832a38c8d0fe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/d2e5544e12029c5a6374c1075a96832a38c8d0fe/testLexicon.py
def manage_addZCatalog(self, id, title, vocab_id=None, REQUEST=None):
def manage_addZCatalog(self, id, title, vocab_id='create_default_catalog_', REQUEST=None):
def manage_addZCatalog(self, id, title, vocab_id=None, REQUEST=None): """Add a ZCatalog object """ id=str(id) title=str(title) vocab_id=str(vocab_id) if vocab_id == 'create_default_catalog_': vocab_id = None c=ZCatalog(id, title, vocab_id, self) self._setObject(id, c) if REQUEST is not None: return self.manage_main(self, REQUEST)
ccbcb7cca5665ae77db73aee4cfd0ab88cf9b95c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/ccbcb7cca5665ae77db73aee4cfd0ab88cf9b95c/ZCatalog.py
('View management screens', ('manage_tabs', 'manage_workspace')), ('Change permissions', ('manage_access',) ),
def PersistentClassDict(doc=None, meta_type=None): # Build new class dict dict={} dict.update(Template.__dict__) if meta_type is not None: dict['meta_type']=dict['__doc__']=meta_type if doc is not None: dict['__doc__']=doc return dict
f2a7d6642189f74e03b5151d84d89803fbb949bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f2a7d6642189f74e03b5151d84d89803fbb949bb/ZClass.py
self._zbases=bases
self._zbases=copy._zbases
def _setBasesHoldOnToYourButts(self, bases): # Eeeek copy=self.__class__(self.id, self.title, bases)
f2a7d6642189f74e03b5151d84d89803fbb949bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f2a7d6642189f74e03b5151d84d89803fbb949bb/ZClass.py
def index_html(self, id, REQUEST, RESPONSE=None):
def createInObjectManager(self, id, REQUEST, RESPONSE=None):
def index_html(self, id, REQUEST, RESPONSE=None): """ Create Z instance. If called with a RESPONSE, the RESPONSE will be redirected to the management screen of the new instance's parent Folder. Otherwise, the instance will be returned. """ i=mapply(self._zclass_, (), REQUEST) if not hasattr(i, 'id') or not i.id: i.id=id
f2a7d6642189f74e03b5151d84d89803fbb949bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f2a7d6642189f74e03b5151d84d89803fbb949bb/ZClass.py
__call__=index_html
index_html=createInObjectManager def fromRequest(self, id=None, REQUEST={}): i=mapply(self._zclass_, (), REQUEST) if id is not None and (not hasattr(i, 'id') or not i.id): i.id=id return i def __call__(self, *args, **kw): return apply(self._zclass_, args, kw)
def index_html(self, id, REQUEST, RESPONSE=None): """ Create Z instance. If called with a RESPONSE, the RESPONSE will be redirected to the management screen of the new instance's parent Folder. Otherwise, the instance will be returned. """ i=mapply(self._zclass_, (), REQUEST) if not hasattr(i, 'id') or not i.id: i.id=id
f2a7d6642189f74e03b5151d84d89803fbb949bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f2a7d6642189f74e03b5151d84d89803fbb949bb/ZClass.py
<!--
<!--
def findActions(klass, found): for b in klass.__bases__: try: for d in b.manage_options: found[d['action']]=1 findActions(b, found) except: pass
f2a7d6642189f74e03b5151d84d89803fbb949bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/f2a7d6642189f74e03b5151d84d89803fbb949bb/ZClass.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'
b517175688377823134db14b384c1839ada0aee4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/b517175688377823134db14b384c1839ada0aee4/Client.py
args += self._get_override("-m", "umask")
args += self._get_override("-m", "umask", oct(self.options.umask))
def do_start(self, arg): self.get_status() if not self.zd_up: args = [ self.options.python, self.options.zdrun, ] args += self._get_override("-S", "schemafile") args += self._get_override("-C", "configfile") args += self._get_override("-b", "backofflimit") args += self._get_override("-d", "daemon", flag=1) args += self._get_override("-f", "forever", flag=1) args += self._get_override("-s", "sockname") args += self._get_override("-u", "user") args += self._get_override("-m", "umask") args += self._get_override( "-x", "exitcodes", ",".join(map(str, self.options.exitcodes))) args += self._get_override("-z", "directory") args.extend(self.options.program) if self.options.daemon: flag = os.P_NOWAIT else: flag = os.P_WAIT os.spawnvp(flag, args[0], args) elif not self.zd_pid: self.send_action("start") else: print "daemon process already running; pid=%d" % self.zd_pid return self.awhile(lambda: self.zd_pid, "daemon process started, pid=%(zd_pid)d")
52e69f62a5d47c310d30f1e170a193e0aa2ed30c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/52e69f62a5d47c310d30f1e170a193e0aa2ed30c/zdctl.py
rq=join(rq,'\n')
rq=join(rq,'\r\n')
def _mp_call(self,kw, type2suffix={ type(1.0): ':float', type(1): ':int', type(1L): ':long', type([]): ':list', type(()): ':tuple', } ): # Call a function using the file-upload protcol
11b2a67e1419ea80c20f06030a12e4740918dc15 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/11b2a67e1419ea80c20f06030a12e4740918dc15/Client.py
s.append('\n')
s.append('\r\n')
def render(self): h=self._headers s=[]
11b2a67e1419ea80c20f06030a12e4740918dc15 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/11b2a67e1419ea80c20f06030a12e4740918dc15/Client.py
s.append('Content-Length: %s\n\n' % len(t))
s.append('Content-Length: %s\r\n\r\n' % len(t))
def render(self): h=self._headers s=[]
11b2a67e1419ea80c20f06030a12e4740918dc15 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/11b2a67e1419ea80c20f06030a12e4740918dc15/Client.py
s.append('\n') s.append('\n')
s.append('\r\n') s.append('\r\n')
def render(self): h=self._headers s=[]
11b2a67e1419ea80c20f06030a12e4740918dc15 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/11b2a67e1419ea80c20f06030a12e4740918dc15/Client.py
prev=rc[n] if c > prev: rd.append( (c - prev, (c, prev, n)) )
try: prev=rc[n] if c > prev: rd.append( (c - prev, (c, prev, n)) ) except: pass
def rcdeltas(self): if _v_rcs is None: self.rcsnapshot() nc=self.refdict() rc=_v_rcs rd=[] for n, c in nc.items(): prev=rc[n] if c > prev: rd.append( (c - prev, (c, prev, n)) ) rd.sort() rd.reverse()
df4ed39ef4cde7f168dfeb1c4e17a2045aaf15f8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/9658/df4ed39ef4cde7f168dfeb1c4e17a2045aaf15f8/ApplicationManager.py