bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def __call__(self, *args): return self.__send(self.__name, args)
def __call__(self, *args): return self.__send(self.__name, args)
3,700
def parse_response(self, f): # read response from input file, and parse it
def parse_response(self, f): # read response from input file, and parse it
3,701
def parse_response(self, f): # read response from input file, and parse it
def parse_response(self, f): # read response from input file, and parse it
3,702
def send_host(self, connection, host): if isinstance(host, TupleType): host, x509 = host connection.putheader("Host", host)
def send_host(self, connection, host): if isinstance(host, TupleType): host, x509 = host connection.putheader("Host", host)
3,703
def __repr__(self): return ( "<Server proxy for %s%s>" % (self.__host, self.__handler) )
def __repr__(self): return ( "<ServerProxy for %s%s>" % (self.__host, self.__handler) )
3,704
def __getattr__(self, name): # magic method dispatcher return _Method(self.__request, name)
def __getattr__(self, name): # magic method dispatcher return _Method(self.__request, name)
3,705
def parse(text, result=None, keys=None, unparmre=re.compile( r'([\000- ]*([^\000- ="]+))'), parmre=re.compile( r'([\000- ]*([^\000- ="]+)=([^\000- ="]+))'), qparmre=re.compile( r'([\000- ]*([^\000- ="]+)="([^"]*)")'), ): if result is None: result = {} keys=[] __traceback_info__=text mo = parmre.match(text) if mo: name=mo.group(1) value={'default':mo.group(2)} l=len(mo.group(0)) else: mo = qparmre.match(text) if mo: name=mo.group(0) value={'default':mo.group(2)} l=len(mo.group(0)) else: mo = unparmre.match(text) if ts_results: name=mo.group(1) l=len(mo.group(0)) value={} else: if not text or not strip(text): return Args(result,keys) raise InvalidParameter, text lt=string.find(name,':') if lt > 0: value['type']=name[lt+1:] name=name[:lt] result[name]=value keys.append(name) return parse(text[l:],result,keys)
def parse(text, result=None, keys=None, unparmre=re.compile( r'([\000- ]*([^\000- ="]+))'), parmre=re.compile( r'([\000- ]*([^\000- ="]+)=([^\000- ="]+))'), qparmre=re.compile( r'([\000- ]*([^\000- ="]+)="([^"]*)")'), ): if result is None: result = {} keys=[] __traceback_info__=text mo = parmre.match(text) if mo: name=mo.group(2) value={'default':mo.group(3)} l=len(mo.group(1)) else: mo = qparmre.match(text) if mo: name=mo.group(0) value={'default':mo.group(2)} l=len(mo.group(0)) else: mo = unparmre.match(text) if ts_results: name=mo.group(1) l=len(mo.group(0)) value={} else: if not text or not strip(text): return Args(result,keys) raise InvalidParameter, text lt=string.find(name,':') if lt > 0: value['type']=name[lt+1:] name=name[:lt] result[name]=value keys.append(name) return parse(text[l:],result,keys)
3,706
def parse(text, result=None, keys=None, unparmre=re.compile( r'([\000- ]*([^\000- ="]+))'), parmre=re.compile( r'([\000- ]*([^\000- ="]+)=([^\000- ="]+))'), qparmre=re.compile( r'([\000- ]*([^\000- ="]+)="([^"]*)")'), ): if result is None: result = {} keys=[] __traceback_info__=text mo = parmre.match(text) if mo: name=mo.group(1) value={'default':mo.group(2)} l=len(mo.group(0)) else: mo = qparmre.match(text) if mo: name=mo.group(0) value={'default':mo.group(2)} l=len(mo.group(0)) else: mo = unparmre.match(text) if ts_results: name=mo.group(1) l=len(mo.group(0)) value={} else: if not text or not strip(text): return Args(result,keys) raise InvalidParameter, text lt=string.find(name,':') if lt > 0: value['type']=name[lt+1:] name=name[:lt] result[name]=value keys.append(name) return parse(text[l:],result,keys)
def parse(text, result=None, keys=None, unparmre=re.compile( r'([\000- ]*([^\000- ="]+))'), parmre=re.compile( r'([\000- ]*([^\000- ="]+)=([^\000- ="]+))'), qparmre=re.compile( r'([\000- ]*([^\000- ="]+)="([^"]*)")'), ): if result is None: result = {} keys=[] __traceback_info__=text mo = parmre.match(text) if mo: name=mo.group(1) value={'default':mo.group(2)} l=len(mo.group(0)) else: mo = qparmre.match(text) if mo: name=mo.group(1) value={'default':mo.group(3)} l=len(mo.group(2)) else: mo = unparmre.match(text) if ts_results: name=mo.group(1) l=len(mo.group(0)) value={} else: if not text or not strip(text): return Args(result,keys) raise InvalidParameter, text lt=string.find(name,':') if lt > 0: value['type']=name[lt+1:] name=name[:lt] result[name]=value keys.append(name) return parse(text[l:],result,keys)
3,707
def parse(text, result=None, keys=None, unparmre=re.compile( r'([\000- ]*([^\000- ="]+))'), parmre=re.compile( r'([\000- ]*([^\000- ="]+)=([^\000- ="]+))'), qparmre=re.compile( r'([\000- ]*([^\000- ="]+)="([^"]*)")'), ): if result is None: result = {} keys=[] __traceback_info__=text mo = parmre.match(text) if mo: name=mo.group(1) value={'default':mo.group(2)} l=len(mo.group(0)) else: mo = qparmre.match(text) if mo: name=mo.group(0) value={'default':mo.group(2)} l=len(mo.group(0)) else: mo = unparmre.match(text) if ts_results: name=mo.group(1) l=len(mo.group(0)) value={} else: if not text or not strip(text): return Args(result,keys) raise InvalidParameter, text lt=string.find(name,':') if lt > 0: value['type']=name[lt+1:] name=name[:lt] result[name]=value keys.append(name) return parse(text[l:],result,keys)
def parse(text, result=None, keys=None, unparmre=re.compile( r'([\000- ]*([^\000- ="]+))'), parmre=re.compile( r'([\000- ]*([^\000- ="]+)=([^\000- ="]+))'), qparmre=re.compile( r'([\000- ]*([^\000- ="]+)="([^"]*)")'), ): if result is None: result = {} keys=[] __traceback_info__=text mo = parmre.match(text) if mo: name=mo.group(1) value={'default':mo.group(2)} l=len(mo.group(0)) else: mo = qparmre.match(text) if mo: name=mo.group(0) value={'default':mo.group(2)} l=len(mo.group(0)) else: mo = unparmre.match(text) if ts_results: name=mo.group(2) l=len(mo.group(1)) value={} else: if not text or not strip(text): return Args(result,keys) raise InvalidParameter, text lt=string.find(name,':') if lt > 0: value['type']=name[lt+1:] name=name[:lt] result[name]=value keys.append(name) return parse(text[l:],result,keys)
3,708
def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction)
defstore(self,oid,serial,data,version,transaction):iftransactionisnotself._transaction:raisePOSException.StorageTransactionError(self,transaction)
3,709
def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction)
def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction)
3,710
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp s=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < s: oid, ldata = unpack(">8sI", read(12)) data=read(ldata)
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp oidlen=8 intlen=4 fsize=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < s: oid, ldata = unpack(">8sI", read(12)) data=read(ldata)
3,711
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp s=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < s: oid, ldata = unpack(">8sI", read(12)) data=read(ldata)
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp s=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < fsize: sdata = read(oidlen+intlen) oid, ldata = unpack(">%ssi" % oidlen, sdata) data=read(ldata)
3,712
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp s=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < s: oid, ldata = unpack(">8sI", read(12)) data=read(ldata)
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp s=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < s: oid, ldata = unpack(">8sI", read(12)) data=read(ldata)
3,713
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp s=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < s: oid, ldata = unpack(">8sI", read(12)) data=read(ldata)
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp s=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < s: oid, ldata = unpack(">8sI", read(12)) data=read(ldata)
3,714
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp s=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < s: oid, ldata = unpack(">8sI", read(12)) data=read(ldata)
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp s=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < s: oid, ldata = unpack(">8sI", read(12)) data=read(ldata)
3,715
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp s=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < s: oid, ldata = unpack(">8sI", read(12)) data=read(ldata)
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp s=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < s: oid, ldata = unpack(">8sI", read(12)) data=read(ldata)
3,716
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp s=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < s: oid, ldata = unpack(">8sI", read(12)) data=read(ldata)
def _finish(self, tid, u, d, e): txn = self._env.txn_begin() try: zeros={} referenceCount=self._referenceCount referenceCount_get=referenceCount.get referenceCount_put=referenceCount.put oreferences=self._oreferences oreferences_put=oreferences.put serial_put=self._index.put opickle_put=self._opickle.put serial=self._serial tmp=self._tmp s=tmp.tell() tmp.seek(0) read=tmp.read l=0 while l < s: oid, ldata = unpack(">8sI", read(12)) data=read(ldata)
3,717
def _takeOutGarbage(self, oid, txn): # take out the garbage. referenceCount=self._referenceCount referenceCount.delete(oid, txn) self._opickle.delete(oid, txn) self._current.delete(oid, txn)
def _takeOutGarbage(self, oid, txn): # take out the garbage. referenceCount=self._referenceCount referenceCount.delete(oid, txn) self._opickle.delete(oid, txn) self._current.delete(oid, txn)
3,718
def _takeOutGarbage(self, oid, txn): # take out the garbage. referenceCount=self._referenceCount referenceCount.delete(oid, txn) self._opickle.delete(oid, txn) self._current.delete(oid, txn)
def_takeOutGarbage(self,oid,txn):#takeoutthegarbage.referenceCount=self._referenceCountreferenceCount.delete(oid,txn)self._opickle.delete(oid,txn)self._current.delete(oid,txn)
3,719
def pack(self, t, referencesf): self._lock_acquire() try: pass # TBD finally: self._lock_release()
defpack(self,t,referencesf):self._lock_acquire()try:pass#TBDfinally:self._lock_release()
3,720
def pack(self, t, referencesf): self._lock_acquire() try: pass # TBD finally: self._lock_release()
def pack(self, t, referencesf): self._lock_acquire() try: pass # TBD finally: self._lock_release()
3,721
def zpublisher_exception_hook(published, REQUEST, t, v, traceback): try: if isinstance(t, StringType): if t.lower() in ('unauthorized', 'redirect'): raise else: if t is SystemExit: raise if issubclass(t, ConflictError): # First, we need to close the current connection. We'll # do this by releasing the hold on it. There should be # some sane protocol for this, but for now we'll use # brute force: global conflict_errors conflict_errors = conflict_errors + 1 method_name = REQUEST.get('PATH_INFO', '') err = ('ZODB conflict error at %s ' '(%s conflicts since startup at %s)') LOG(err % (method_name, conflict_errors, startup_time), INFO, '') LOG('Conflict traceback', BLATHER, '', error=sys.exc_info()) raise ZPublisher.Retry(t, v, traceback) if t is ZPublisher.Retry: v.reraise() try: log = aq_acquire(published, '__error_log__', containment=1) except AttributeError: error_log_url = '' else: error_log_url = log.raising((t, v, traceback)) if (getattr(REQUEST.get('RESPONSE', None), '_error_format', '') !='text/html'): raise if (published is None or published is app or type(published) is ListType): # At least get the top-level object published=app.__bobo_traverse__(REQUEST).__of__( RequestContainer(REQUEST)) get_transaction().begin() # Just to be sure. published=getattr(published, 'im_self', published) while 1: f=getattr(published, 'raise_standardErrorMessage', None) if f is None: published=getattr(published, 'aq_parent', None) if published is None: raise else: break client=published while 1: if getattr(client, 'standard_error_message', None) is not None: break client=getattr(client, 'aq_parent', None) if client is None: raise if REQUEST.get('AUTHENTICATED_USER', None) is None: REQUEST['AUTHENTICATED_USER']=AccessControl.User.nobody try: f(client, REQUEST, t, v, traceback, error_log_url=error_log_url) except TypeError: # Pre 2.6 call signature f(client, REQUEST, t, v, traceback) finally: traceback=None
def zpublisher_exception_hook(published, REQUEST, t, v, traceback): try: if isinstance(t, StringType): if t.lower() in ('unauthorized', 'redirect'): raise else: if t is SystemExit: raise if issubclass(t, ConflictError): # First, we need to close the current connection. We'll # do this by releasing the hold on it. There should be # some sane protocol for this, but for now we'll use # brute force: global conflict_errors conflict_errors = conflict_errors + 1 method_name = REQUEST.get('PATH_INFO', '') err = ('ZODB conflict error at %s ' '(%s conflicts since startup at %s)') LOG(err % (method_name, conflict_errors, startup_time), INFO, '') LOG('Conflict traceback', BLATHER, '', error=sys.exc_info()) raise ZPublisher.Retry(t, v, traceback) if t is ZPublisher.Retry: v.reraise() try: log = aq_acquire(published, '__error_log__', containment=1) except AttributeError: error_log_url = '' else: error_log_url = log.raising((t, v, traceback)) if (getattr(REQUEST.get('RESPONSE', None), '_error_format', '') !='text/html'): raise if (published is None or published is app or type(published) is ListType): # At least get the top-level object published=app.__bobo_traverse__(REQUEST).__of__( RequestContainer(REQUEST)) get_transaction().begin() # Just to be sure. published=getattr(published, 'im_self', published) while 1: f=getattr(published, 'raise_standardErrorMessage', None) if f is None: published=getattr(published, 'aq_parent', None) if published is None: raise t, v, traceback else: break client=published while 1: if getattr(client, 'standard_error_message', None) is not None: break client=getattr(client, 'aq_parent', None) if client is None: raise if REQUEST.get('AUTHENTICATED_USER', None) is None: REQUEST['AUTHENTICATED_USER']=AccessControl.User.nobody try: f(client, REQUEST, t, v, traceback, error_log_url=error_log_url) except TypeError: # Pre 2.6 call signature f(client, REQUEST, t, v, traceback) finally: traceback=None
3,722
def zpublisher_exception_hook(published, REQUEST, t, v, traceback): try: if isinstance(t, StringType): if t.lower() in ('unauthorized', 'redirect'): raise else: if t is SystemExit: raise if issubclass(t, ConflictError): # First, we need to close the current connection. We'll # do this by releasing the hold on it. There should be # some sane protocol for this, but for now we'll use # brute force: global conflict_errors conflict_errors = conflict_errors + 1 method_name = REQUEST.get('PATH_INFO', '') err = ('ZODB conflict error at %s ' '(%s conflicts since startup at %s)') LOG(err % (method_name, conflict_errors, startup_time), INFO, '') LOG('Conflict traceback', BLATHER, '', error=sys.exc_info()) raise ZPublisher.Retry(t, v, traceback) if t is ZPublisher.Retry: v.reraise() try: log = aq_acquire(published, '__error_log__', containment=1) except AttributeError: error_log_url = '' else: error_log_url = log.raising((t, v, traceback)) if (getattr(REQUEST.get('RESPONSE', None), '_error_format', '') !='text/html'): raise if (published is None or published is app or type(published) is ListType): # At least get the top-level object published=app.__bobo_traverse__(REQUEST).__of__( RequestContainer(REQUEST)) get_transaction().begin() # Just to be sure. published=getattr(published, 'im_self', published) while 1: f=getattr(published, 'raise_standardErrorMessage', None) if f is None: published=getattr(published, 'aq_parent', None) if published is None: raise else: break client=published while 1: if getattr(client, 'standard_error_message', None) is not None: break client=getattr(client, 'aq_parent', None) if client is None: raise if REQUEST.get('AUTHENTICATED_USER', None) is None: REQUEST['AUTHENTICATED_USER']=AccessControl.User.nobody try: f(client, REQUEST, t, v, traceback, error_log_url=error_log_url) except TypeError: # Pre 2.6 call signature f(client, REQUEST, t, v, traceback) finally: traceback=None
def zpublisher_exception_hook(published, REQUEST, t, v, traceback): try: if isinstance(t, StringType): if t.lower() in ('unauthorized', 'redirect'): raise else: if t is SystemExit: raise if issubclass(t, ConflictError): # First, we need to close the current connection. We'll # do this by releasing the hold on it. There should be # some sane protocol for this, but for now we'll use # brute force: global conflict_errors conflict_errors = conflict_errors + 1 method_name = REQUEST.get('PATH_INFO', '') err = ('ZODB conflict error at %s ' '(%s conflicts since startup at %s)') LOG(err % (method_name, conflict_errors, startup_time), INFO, '') LOG('Conflict traceback', BLATHER, '', error=sys.exc_info()) raise ZPublisher.Retry(t, v, traceback) if t is ZPublisher.Retry: v.reraise() try: log = aq_acquire(published, '__error_log__', containment=1) except AttributeError: error_log_url = '' else: error_log_url = log.raising((t, v, traceback)) if (getattr(REQUEST.get('RESPONSE', None), '_error_format', '') !='text/html'): raise if (published is None or published is app or type(published) is ListType): # At least get the top-level object published=app.__bobo_traverse__(REQUEST).__of__( RequestContainer(REQUEST)) get_transaction().begin() # Just to be sure. published=getattr(published, 'im_self', published) while 1: f=getattr(published, 'raise_standardErrorMessage', None) if f is None: published=getattr(published, 'aq_parent', None) if published is None: raise else: break client=published while 1: if getattr(client, 'standard_error_message', None) is not None: break client=getattr(client, 'aq_parent', None) if client is None: raise t, v, traceback if REQUEST.get('AUTHENTICATED_USER', None) is None: REQUEST['AUTHENTICATED_USER']=AccessControl.User.nobody try: f(client, REQUEST, t, v, traceback, error_log_url=error_log_url) except TypeError: # Pre 2.6 call signature f(client, REQUEST, t, v, traceback) finally: traceback=None
3,723
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
3,724
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
3,725
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
3,726
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
3,727
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
3,728
def pret(ast, level=0): if ISTERMINAL(ast[0]): print ' '*level, ast[1] else: print ' '*level, sym_name[ast[0]] for a in ast[1:]: pret(a,level+1)
def pret(ast, level=0): if ISTERMINAL(ast[0]): print ' '*level, ast[1] else: print ' '*level, sym_name[ast[0]], '(%s)' % ast[0] for a in ast[1:]: pret(a,level+1)
3,729
def munge(ast): if ISTERMINAL(ast[0]): return else: if ast[0]==term and len(ast) > 2: ast[1:]=[multi_munge(ast[1:])] elif ast[0]==power: keep_going=1 while keep_going: keep_going=0 start=2 for i in range(start,len(ast)): a=ast[i] if a[0]==trailer: if a[1][0]==DOT: ast[:i+1]=dot_munge(ast,i) keep_going=1 start=3 break if a[1][0]==LSQB: if (a[2][0] != subscriptlist or a[2][1][0] != subscript): raise ParseError, ( 'Unexpected form after left square brace') slist=a[2] if len(slist)==2: # One subscript, check for range and ... sub=slist[1] if sub[1][0]==DOT: raise ParseError, ( 'ellipses are not supported') l=len(sub) if l < 3 and sub[1][0] != COLON: ast[:i+1]=item_munge(ast, i) elif l < 5: ast[:i+1]=slice_munge(ast, i) else: raise ParseError, 'Invalid slice' else: ast[:i+1]=item_munge(ast, i) keep_going=1 start=3 break for a in ast[1:]: munge(a) else: for a in ast[1:]: munge(a) return ast
def munge(ast): if ISTERMINAL(ast[0]): return else: if ast[0]==term and len(ast) > 2: keep_going=1 while keep_going: keep_going=0 start=2 for i in range(start,len(ast)-1): if ast[i][0]==STAR: ast[i-1:i+2]=[multi_munge(ast[i-1:i+2])] keep_going=1 break for a in ast[1:]: munge(a) elif ast[0]==power: keep_going=1 while keep_going: keep_going=0 start=2 for i in range(start,len(ast)): a=ast[i] if a[0]==trailer: if a[1][0]==DOT: ast[:i+1]=dot_munge(ast,i) keep_going=1 start=3 break if a[1][0]==LSQB: if (a[2][0] != subscriptlist or a[2][1][0] != subscript): raise ParseError, ( 'Unexpected form after left square brace') slist=a[2] if len(slist)==2: # One subscript, check for range and ... sub=slist[1] if sub[1][0]==DOT: raise ParseError, ( 'ellipses are not supported') l=len(sub) if l < 3 and sub[1][0] != COLON: ast[:i+1]=item_munge(ast, i) elif l < 5: ast[:i+1]=slice_munge(ast, i) else: raise ParseError, 'Invalid slice' else: ast[:i+1]=item_munge(ast, i) keep_going=1 start=3 break for a in ast[1:]: munge(a) else: for a in ast[1:]: munge(a) return ast
3,730
def multi_munge(ast): # Munge a multiplication into a function call: __very_safe_multiply__ args=[arglist] append=args.append a=(factor, (power, (atom, (NAME, '_vars')))) a=(argument, (test, (and_test, (not_test, (comparison, (expr, (xor_expr, (and_expr, (shift_expr, (arith_expr, (term, a))))))))))) append(a) append([COMMA,',']) for a in ast: if a[0]==STAR: args.append([COMMA,',']) else: a=(argument, (test, (and_test, (not_test, (comparison, (expr, (xor_expr, (and_expr, (shift_expr, (arith_expr, (term, a))))))))))) append(a) return [factor, [power, [atom, [NAME, '__guarded_mul__']], [trailer, [LPAR, '('], args, [RPAR, ')'], ]]]
def multi_munge(ast): # Munge a multiplication into a function call: __very_safe_multiply__ args=[arglist] append=args.append a=(factor, (power, (atom, (NAME, '_vars')))) a=(argument, (test, (and_test, (not_test, (comparison, (expr, (xor_expr, (and_expr, (shift_expr, (arith_expr, (term, a))))))))))) append(a) append([COMMA,',']) for a in ast: if a[0]==STAR: args.append([COMMA,',']) else: a=(argument, (test, (and_test, (not_test, (comparison, (expr, (xor_expr, (and_expr, (shift_expr, (arith_expr, (term, a))))))))))) append(a) return [factor, [power, [atom, [NAME, '__guarded_mul__']], [trailer, [LPAR, '('], args, [RPAR, ')'], ]]]
3,731
def spam(): # Regression test import traceback ok=1 for expr1, expr2 in ( ("a*b", "__guarded_mul__(_vars, a, b)"), ("a*b*c", "__guarded_mul__(_vars, a, b, c)"), ("a.b", "__guarded_getattr__(_vars, a, 'b')"), ("a[b]", "__guarded_getitem__(_vars, a, b)"), ("a[b,c]", "__guarded_getitem__(_vars, a, b, c)"), ("a[b:c]", "__guarded_getslice__(_vars, a, b, c)"), ("a[:c]", "__guarded_getslice__(_vars, a, 0, c)"), ("a[b:]", "__guarded_getslice__(_vars, a, b)"), ("a[:]", "__guarded_getslice__(_vars, a)"), ): l1=munge(astl(expr1)) l2=astl(expr2) try: c1=compileast(sequence2ast(l1)) except: traceback.print_exc c1=None c2=compileast(sequence2ast(l2)) if c1 !=c2: ok=0 print 'test failed', expr1, expr2 print print l1 print print l2 print ast=parser.sequence2ast(l1) c=parser.compileast(ast) if ok: print 'all tests succeeded'
def spam(): # Regression test import traceback ok=1 for expr1, expr2 in ( ("a*b", "__guarded_mul__(_vars, a, b)"), ("a*b*c", "__guarded_mul__(_vars, __guarded_mul__(_vars, a, b), c)" ), ("a.b", "__guarded_getattr__(_vars, a, 'b')"), ("a[b]", "__guarded_getitem__(_vars, a, b)"), ("a[b,c]", "__guarded_getitem__(_vars, a, b, c)"), ("a[b:c]", "__guarded_getslice__(_vars, a, b, c)"), ("a[:c]", "__guarded_getslice__(_vars, a, 0, c)"), ("a[b:]", "__guarded_getslice__(_vars, a, b)"), ("a[:]", "__guarded_getslice__(_vars, a)"), ): l1=munge(astl(expr1)) l2=astl(expr2) try: c1=compileast(sequence2ast(l1)) except: traceback.print_exc c1=None c2=compileast(sequence2ast(l2)) if c1 !=c2: ok=0 print 'test failed', expr1, expr2 print print l1 print print l2 print ast=parser.sequence2ast(l1) c=parser.compileast(ast) if ok: print 'all tests succeeded'
3,732
def __init__(self, stdin, environ, response, clean=0): self._orig_env=environ # Avoid the overhead of scrubbing the environment in the # case of request cloning for traversal purposes. If the # clean flag is set, we know we can use the passed in # environ dict directly. if not clean: environ=sane_environment(environ)
def __init__(self, stdin, environ, response, clean=0): self._orig_env=environ # Avoid the overhead of scrubbing the environment in the # case of request cloning for traversal purposes. If the # clean flag is set, we know we can use the passed in # environ dict directly. if not clean: environ=sane_environment(environ)
3,733
def __init__(self, stdin, environ, response, clean=0): self._orig_env=environ # Avoid the overhead of scrubbing the environment in the # case of request cloning for traversal purposes. If the # clean flag is set, we know we can use the passed in # environ dict directly. if not clean: environ=sane_environment(environ)
def __init__(self, stdin, environ, response, clean=0): self._orig_env=environ # Avoid the overhead of scrubbing the environment in the # case of request cloning for traversal purposes. If the # clean flag is set, we know we can use the passed in # environ dict directly. if not clean: environ=sane_environment(environ)
3,734
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
3,735
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
3,736
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
3,737
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
3,738
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
3,739
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
3,740
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
3,741
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=re.compile('(:[a-zA-Z][a-zA-Z0-9_]+|\\.[xy])$').search, ): """Process request inputs
3,742
def keys(self): keys = {} keys.update(self.common) keys.update(self._lazies)
def keys(self): keys = {} keys.update(self.common) keys.update(self._lazies)
3,743
def manage_clone(self, ob, id, REQUEST=None): """Clone an object, creating a new object with the given id.""" if not ob.cb_isCopyable(): raise CopyError, eNotSupported % absattr(ob.id) try: self._checkId(id) except: raise CopyError, MessageDialog( title='Invalid Id', message=sys.exc_value, action ='manage_main') self._verifyObjectPaste(ob, REQUEST) try: ob._notifyOfCopyTo(self, op=0) except: raise CopyError, MessageDialog( title='Rename Error', message=sys.exc_value, action ='manage_main') ob=ob._getCopy(self) ob._setId(id) self._setObject(id, ob) #ob=ob.__of__(self) #ob._postCopy(self, op=0) return ob
defob=ob.__of__(self) manage_clone(self,ob=ob.__of__(self) ob,ob=ob.__of__(self) id,ob=ob.__of__(self) REQUEST=None):ob=ob.__of__(self) """Cloneob=ob.__of__(self) anob=ob.__of__(self) object,ob=ob.__of__(self) creatingob=ob.__of__(self) aob=ob.__of__(self) newob=ob.__of__(self) objectob=ob.__of__(self) withob=ob.__of__(self) theob=ob.__of__(self) givenob=ob.__of__(self) id."""ob=ob.__of__(self) ifob=ob.__of__(self) notob=ob.__of__(self) ob.cb_isCopyable():ob=ob.__of__(self) raiseob=ob.__of__(self) CopyError,ob=ob.__of__(self) eNotSupportedob=ob.__of__(self) %ob=ob.__of__(self) absattr(ob.id)ob=ob.__of__(self) try:ob=ob.__of__(self) self._checkId(id)ob=ob.__of__(self) except:ob=ob.__of__(self) raiseob=ob.__of__(self) CopyError,ob=ob.__of__(self) MessageDialog(ob=ob.__of__(self) title='Invalidob=ob.__of__(self) Id',ob=ob.__of__(self) message=sys.exc_value,ob=ob.__of__(self) actionob=ob.__of__(self) ='manage_main')ob=ob.__of__(self) self._verifyObjectPaste(ob,ob=ob.__of__(self) REQUEST)ob=ob.__of__(self) try:ob=ob.__of__(self) ob=ob.__of__(self) ob=ob.__of__(self) ob=ob.__of__(self) ob._notifyOfCopyTo(self,ob=ob.__of__(self) op=0)ob=ob.__of__(self) except:ob=ob.__of__(self) raiseob=ob.__of__(self) CopyError,ob=ob.__of__(self) MessageDialog(ob=ob.__of__(self) title='Renameob=ob.__of__(self) Error',ob=ob.__of__(self) message=sys.exc_value,ob=ob.__of__(self) actionob=ob.__of__(self) ='manage_main')ob=ob.__of__(self) ob=ob._getCopy(self)ob=ob.__of__(self) ob._setId(id)ob=ob.__of__(self) self._setObject(id,ob=ob.__of__(self) ob)ob=ob.__of__(self) #ob=ob.__of__(self)ob=ob.__of__(self) #ob._postCopy(self,ob=ob.__of__(self) op=0)ob=ob.__of__(self) returnob=ob.__of__(self) ob
3,744
def manage_edit(self, title, base, path, REQUEST=None): '''Set the title, base, and path''' self.__init__(title, base, path) if REQUEST: return MessageDialog(title='SiteRoot changed.', message='The title is now "%s"<br>' 'The base is now "%s"<br>' 'The path is now "%s"<br>' % map(escape, (title, base, path)), action='%s/manage_main' % REQUEST['URL1'])
def manage_edit(self, title, base, path, REQUEST=None): '''Set the title, base, and path''' self.__init__(title, base, path) if REQUEST: return MessageDialog(title='SiteRoot changed.', message='SiteRoot changed.', action='%s/manage_main' % REQUEST['URL1'])
3,745
def dav__init(self, request, response): # By the spec, we are not supposed to accept /foo for a # collection, we are supposed to redirect to /foo/. if request['PATH_INFO'][-1] != '/': raise 'Moved Permanently', request['URL1']+'/' response.setHeader('Connection', 'close', 1) response.setHeader('Date', rfc1123_date(), 1) response.setHeader('DAV', '1', 1)
def dav__init(self, request, response): # By the spec, we are not supposed to accept /foo for a # collection, we are supposed to redirect to /foo/. pathinfo=request.get('PATH_INFO','') if pathinfo and pathinfo[-1] != '/': raise 'Moved Permanently', request['URL1']+'/' response.setHeader('Connection', 'close', 1) response.setHeader('Date', rfc1123_date(), 1) response.setHeader('DAV', '1', 1)
3,746
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 content_type: self._getOb(id).content_type=content_type if REQUEST is not None: REQUEST['RESPONSE'].redirect(self.absolute_url()+'/manage_main')
def manage_addFile(self,id,file='',title='',precondition='', content_type='', REQUEST=None): """Add a new File object. Creates a new File object 'id' with the contents of 'file'""" id=str(id) title=str(title) content_type=str(content_type) precondition=str(precondition) id, title = cookId(id, title, file) self=self.this() # First, we create the file without data: self._setObject(id, File(id,title,'',content_type, precondition)) # Now we "upload" the data. By doing this in two steps, we # can use a database trick to make the upload more efficient. if file: self._getOb(id).manage_upload(file) if content_type: self._getOb(id).content_type=content_type if REQUEST is not None: REQUEST['RESPONSE'].redirect(self.absolute_url()+'/manage_main')
3,747
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 content_type: self._getOb(id).content_type=content_type if REQUEST is not None: try: url=self.DestinationURL() except: url=REQUEST['URL1'] REQUEST.RESPONSE.redirect('%s/manage_main' % url) return id
def manage_addImage(self, id, file, title='', precondition='', content_type='', REQUEST=None): """ Add a new Image object. Creates a new Image object 'id' with the contents of 'file'. """ id=str(id) title=str(title) content_type=str(content_type) precondition=str(precondition) id, title = cookId(id, title, file) self=self.this() # First, we create the image without data: self._setObject(id, Image(id,title,'',content_type, precondition)) # Now we "upload" the data. By doing this in two steps, we # can use a database trick to make the upload more efficient. if file: self._getOb(id).manage_upload(file) if content_type: self._getOb(id).content_type=content_type if REQUEST is not None: try: url=self.DestinationURL() except: url=REQUEST['URL1'] REQUEST.RESPONSE.redirect('%s/manage_main' % url) return id
3,748
def pw_validate(reference, attempt): """Validate the provided password string, which uses LDAP-style encoding notation. Reference is the correct password, attempt is clear text password attempt.""" result = 0 if upper(reference[:5]) == '{SHA}': attempt = binascii.b2a_base64(sha.new(attempt).digest())[:-1] result = reference[5:] == attempt elif upper(reference[:7]) == '{CRYPT}' and crypt is not None: #if crypt is None, it's not compiled in and everything will fail attempt = crypt(attempt, reference[7:9]) result = reference[7:] == attempt else: result = reference == attempt return result
def pw_validate(reference, attempt): """Validate the provided password string, which uses LDAP-style encoding notation. Reference is the correct password, attempt is clear text password attempt.""" result = 0 if upper(reference[:5]) == '{SHA}': attempt = binascii.b2a_base64(sha.new(attempt).digest())[:-1] result = reference[5:] == attempt elif upper(reference[:7]) == '{CRYPT}' and crypt is not None: #if crypt is None, it's not compiled in and everything will fail attempt = crypt.crypt(attempt, reference[7:9]) result = reference[7:] == attempt else: result = reference == attempt return result
3,749
def manage_test(self, REQUEST):
def manage_test(self, REQUEST):
3,750
def _init_headers(self, request, response): # Attempt to handle If-Modified-Since headers. ms=request.get_header('If-Modified-Since', None) if ms is not None: ms=split(ms, ';')[0] ms=DateTime(ms).timeTime() if self.lmt > ms: RESPONSE.setStatus(304) return RESPONSE response.setHeader('Content-Type', self.content_type) response.setHeader('Last-Modified', self.lmh)
def _init_headers(self, request, response): # Attempt to handle If-Modified-Since headers. ms=request.get_header('If-Modified-Since', None) if ms is not None: ms=split(ms, ';')[0] ms=DateTime(ms).timeTime() if self.lmt > ms: response.setStatus(304) return response response.setHeader('Content-Type', self.content_type) response.setHeader('Last-Modified', self.lmh)
3,751
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
3,752
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
3,753
def validate(self,groups,realm=None):
def validate(self,groups,realm=None):
3,754
def validate(self,groups,realm=None):
def validate(self,groups,realm=None):
3,755
def open_bobobase(): # Open the application database Bobobase=Globals.Bobobase=Globals.PickleDictionary(Globals.BobobaseName) product_dir=os.path.join(SOFTWARE_HOME,'lib/python/Products') __traceback_info__=sys.path try: app=Bobobase['Application'] except KeyError: app=Application() app._init() Bobobase['Application']=app get_transaction().commit() # Backward compatibility if not hasattr(app, 'Control_Panel'): cpl=ApplicationManager() cpl._init() app._setObject('Control_Panel', cpl) get_transaction().commit() if not hasattr(app, 'standard_error_message'): import Document Document.manage_addDocument( app, 'standard_error_message', 'Standard Error Message', _standard_error_msg) get_transaction().commit() install_products(app) get_transaction().commit() return Bobobase
def open_bobobase(): # Open the application database Bobobase=Globals.Bobobase=Globals.PickleDictionary(Globals.BobobaseName) product_dir=os.path.join(SOFTWARE_HOME,'lib/python/Products') __traceback_info__=sys.path try: app=Bobobase['Application'] except KeyError: app=Application() app._init() Bobobase['Application']=app get_transaction().commit() # Backward compatibility if not hasattr(app, 'Control_Panel'): cpl=ApplicationManager() cpl._init() app._setObject('Control_Panel', cpl) get_transaction().commit() if not hasattr(app, 'standard_error_message'): import Document Document.manage_addDocument( app, 'standard_error_message', 'Standard Error Message', _standard_error_msg) get_transaction().commit() install_products(app) get_transaction().commit() return Bobobase
3,756
def catalog_object(self, obj, uid=None, idxs=[]): """ wrapper around catalog """
def catalog_object(self, obj, uid=None, idxs=[]): """ wrapper around catalog """
3,757
def ZopeFindAndApply(self, obj, obj_ids=None, obj_metatypes=None, obj_searchterm=None, obj_expr=None, obj_mtime=None, obj_mspec=None, obj_permission=None, obj_roles=None, search_sub=0, REQUEST=None, result=None, pre='', apply_func=None, apply_path=''): """Zope Find interface and apply
def ZopeFindAndApply(self, obj, obj_ids=None, obj_metatypes=None, obj_searchterm=None, obj_expr=None, obj_mtime=None, obj_mspec=None, obj_permission=None, obj_roles=None, search_sub=0, REQUEST=None, result=None, pre='', apply_func=None, apply_path=''): """Zope Find interface and apply
3,758
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) try: return REQUEST.resolve_url(path) except: pass
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 path.find(script) != 0: path='%s/%s' % (script, path) try: return REQUEST.resolve_url(path) except: pass
3,759
def manage_normalize_paths(self, REQUEST): """Ensure that all catalog paths are full physical paths
def manage_normalize_paths(self, REQUEST): """Ensure that all catalog paths are full physical paths
3,760
def loadmail(dest, name, mbox, printstat=0, max=99999999): try: import Products.BTreeFolder.BTreeFolder except: dest.manage_addFolder(name) else: Products.BTreeFolder.BTreeFolder.manage_addBTreeFolder(dest, name) dest=getattr(dest, name) f=open(mbox) mb=mailbox.UnixMailbox(f) i=0 message=mb.next() while message: if i > max: break if i%100 == 0 and printstat: sys.stdout.write("\t%s\t%s\t\r" % (i, f.tell())) sys.stdout.flush() if i and (i%5000 == 0): get_transaction().commit() dest._p_jar._cache.invalidate(None) dest._p_jar._cache.minimize() loadmessage(dest, message, i) i=i+1 message=mb.next() dest.number_of_messages=i get_transaction().commit()
def loadmail(dest, name, mbox, printstat=0, max=-1): try: import Products.BTreeFolder.BTreeFolder except: dest.manage_addFolder(name) else: Products.BTreeFolder.BTreeFolder.manage_addBTreeFolder(dest, name) dest=getattr(dest, name) f=open(mbox) mb=mailbox.UnixMailbox(f) i=0 message=mb.next() while message: if i > max: break if i%100 == 0 and printstat: sys.stdout.write("\t%s\t%s\t\r" % (i, f.tell())) sys.stdout.flush() if i and (i%5000 == 0): get_transaction().commit() dest._p_jar._cache.invalidate(None) dest._p_jar._cache.minimize() loadmessage(dest, message, i) i=i+1 message=mb.next() dest.number_of_messages=i get_transaction().commit()
3,761
def loadmail(dest, name, mbox, printstat=0, max=99999999): try: import Products.BTreeFolder.BTreeFolder except: dest.manage_addFolder(name) else: Products.BTreeFolder.BTreeFolder.manage_addBTreeFolder(dest, name) dest=getattr(dest, name) f=open(mbox) mb=mailbox.UnixMailbox(f) i=0 message=mb.next() while message: if i > max: break if i%100 == 0 and printstat: sys.stdout.write("\t%s\t%s\t\r" % (i, f.tell())) sys.stdout.flush() if i and (i%5000 == 0): get_transaction().commit() dest._p_jar._cache.invalidate(None) dest._p_jar._cache.minimize() loadmessage(dest, message, i) i=i+1 message=mb.next() dest.number_of_messages=i get_transaction().commit()
def loadmail(dest, name, mbox, printstat=0, max=99999999): try: import Products.BTreeFolder.BTreeFolder except: dest.manage_addFolder(name) else: Products.BTreeFolder.BTreeFolder.manage_addBTreeFolder(dest, name) dest=getattr(dest, name) f=open(mbox) mb=mailbox.UnixMailbox(f) i=0 message=mb.next() while message: if max >= 0 and i > max: break if i%100 == 0 and printstat: sys.stdout.write("\t%s\t%s\t\r" % (i, f.tell())) sys.stdout.flush() if i and (i%5000 == 0): get_transaction().commit() dest._p_jar._cache.invalidate(None) dest._p_jar._cache.minimize() loadmessage(dest, message, i) i=i+1 message=mb.next() dest.number_of_messages=i get_transaction().commit()
3,762
def loadmail(dest, name, mbox, printstat=0, max=99999999): try: import Products.BTreeFolder.BTreeFolder except: dest.manage_addFolder(name) else: Products.BTreeFolder.BTreeFolder.manage_addBTreeFolder(dest, name) dest=getattr(dest, name) f=open(mbox) mb=mailbox.UnixMailbox(f) i=0 message=mb.next() while message: if i > max: break if i%100 == 0 and printstat: sys.stdout.write("\t%s\t%s\t\r" % (i, f.tell())) sys.stdout.flush() if i and (i%5000 == 0): get_transaction().commit() dest._p_jar._cache.invalidate(None) dest._p_jar._cache.minimize() loadmessage(dest, message, i) i=i+1 message=mb.next() dest.number_of_messages=i get_transaction().commit()
def loadmail(dest, name, mbox, printstat=0, max=99999999): try: import Products.BTreeFolder.BTreeFolder except: dest.manage_addFolder(name) else: Products.BTreeFolder.BTreeFolder.manage_addBTreeFolder(dest, name) dest=getattr(dest, name) f=open(mbox) mb=mailbox.UnixMailbox(f) i=0 message=mb.next() while message: if i > max: break if i%100 == 0 and printstat: fmt = "\t%s\t%s\t\r" if os.environ.get('TERM') == 'emacs': fmt = "\t%s\t%s\t\n" sys.stdout.write(fmt % (i, f.tell())) sys.stdout.flush() if i and (i%5000 == 0): get_transaction().commit() dest._p_jar._cache.invalidate(None) dest._p_jar._cache.minimize() loadmessage(dest, message, i) i=i+1 message=mb.next() dest.number_of_messages=i get_transaction().commit()
3,763
def loadmail(dest, name, mbox, printstat=0, max=99999999): try: import Products.BTreeFolder.BTreeFolder except: dest.manage_addFolder(name) else: Products.BTreeFolder.BTreeFolder.manage_addBTreeFolder(dest, name) dest=getattr(dest, name) f=open(mbox) mb=mailbox.UnixMailbox(f) i=0 message=mb.next() while message: if i > max: break if i%100 == 0 and printstat: sys.stdout.write("\t%s\t%s\t\r" % (i, f.tell())) sys.stdout.flush() if i and (i%5000 == 0): get_transaction().commit() dest._p_jar._cache.invalidate(None) dest._p_jar._cache.minimize() loadmessage(dest, message, i) i=i+1 message=mb.next() dest.number_of_messages=i get_transaction().commit()
def loadmail(dest, name, mbox, printstat=0, max=99999999): try: import Products.BTreeFolder.BTreeFolder except: dest.manage_addFolder(name) else: Products.BTreeFolder.BTreeFolder.manage_addBTreeFolder(dest, name) dest=getattr(dest, name) f=open(mbox) mb=mailbox.UnixMailbox(f) i=0 message=mb.next() while message: if i > max: break if i%100 == 0 and printstat: sys.stdout.write("\t%s\t%s\t\r" % (i, f.tell())) sys.stdout.flush() if i and (i%5000 == 0): get_transaction().commit() dest._p_jar._cache.minimize() loadmessage(dest, message, i) i=i+1 message=mb.next() dest.number_of_messages=i get_transaction().commit()
3,764
def base(): try: os.unlink('../../var/Data.fs') except: pass import Zope app=Zope.app() max=atoi(sys.argv[3]) print do(Zope.DB, loadmail, (app, 'mail', sys.argv[2], 1, max)) Zope.DB.close()
def base(): try: os.unlink('../../var/Data.fs') except: pass import Zope app=Zope.app() if len(sys.argv) > 3: max = atoi(sys.argv[3]) else: max = -1 print do(Zope.DB, loadmail, (app, 'mail', sys.argv[2], 1, max)) Zope.DB.close()
3,765
def name_param(params,tag='',expr=0, attr='name', default_unnamed=1): used=params.has_key __traceback_info__=params, tag, expr, attr #if expr and used('expr') and used('') and not used(params['']): # # Fix up something like: <!--#in expr="whatever" mapping--> # params[params['']]=default_unnamed # del params[''] if used(''): v=params[''] if v[:1]=='"' and v[-1:]=='"' and len(v) > 1: # expr shorthand if used(attr): raise ParseError, ('%s and expr given' % attr, tag) if expr: if used('expr'): raise ParseError, ('two exprs given', tag) v=v[1:-1] try: expr=Eval(v, expr_globals) except SyntaxError, v: m,(huh,l,c,src) = v raise ParseError, ( '<strong>Expression (Python) Syntax error</strong>:' '\n<pre>\n%s\n</pre>\n' % v[0], tag) return v, expr else: raise ParseError, ( 'The "..." shorthand for expr was used in a tag ' 'that doesn\'t support expr attributes.', tag) else: # name shorthand if used(attr): raise ParseError, ('Two %s values were given' % attr, tag) if expr: if used('expr'): # raise 'Waaaaaa', 'waaa' raise ParseError, ('%s and expr given' % attr, tag) return params[''],None return params[''] elif used(attr): if expr: if used('expr'): raise ParseError, ('%s and expr given' % attr, tag) return params[attr],None return params[attr] elif expr and used('expr'): name=params['expr'] expr=Eval(name, expr_globals) return name, expr raise ParseError, ('No %s given' % attr, tag)
def name_param(params,tag='',expr=0, attr='name', default_unnamed=1): used=params.has_key __traceback_info__=params, tag, expr, attr #if expr and used('expr') and used('') and not used(params['']): # # Fix up something like: <!--#in expr="whatever" mapping--> # params[params['']]=default_unnamed # del params[''] if used(''): v=params[''] if v[:1]=='"' and v[-1:]=='"' and len(v) > 1: # expr shorthand if used(attr): raise ParseError, ('%s and expr given' % attr, tag) if expr: if used('expr'): raise ParseError, ('two exprs given', tag) v=v[1:-1] try: expr=Eval(v, expr_globals) except SyntaxError, v: raise ParseError, ( '<strong>Expression (Python) Syntax error</strong>:' '\n<pre>\n%s\n</pre>\n' % v[0], tag) return v, expr else: raise ParseError, ( 'The "..." shorthand for expr was used in a tag ' 'that doesn\'t support expr attributes.', tag) else: # name shorthand if used(attr): raise ParseError, ('Two %s values were given' % attr, tag) if expr: if used('expr'): # raise 'Waaaaaa', 'waaa' raise ParseError, ('%s and expr given' % attr, tag) return params[''],None return params[''] elif used(attr): if expr: if used('expr'): raise ParseError, ('%s and expr given' % attr, tag) return params[attr],None return params[attr] elif expr and used('expr'): name=params['expr'] expr=Eval(name, expr_globals) return name, expr raise ParseError, ('No %s given' % attr, tag)
3,766
def __init__(self): self.Products=ProductFolder()
def __init__(self): self.Products=ProductFolder()
3,767
def __str__(self): return """The implementation of %(method)s violates it's contract because %(mess)s. """ % self.__dict__
def __str__(self): return """The implementation of %(method)s violates its contract because %(mess)s. """ % self.__dict__
3,768
def earliestTime(self): """Return a new DateTime object that represents the earliest possible time (in whole seconds) that still falls within the current object\'s day, in the object\'s timezone context""" return self.__class__(self._year,self._month,self._day,0,0,1,self._tz)
def earliestTime(self): """Return a new DateTime object that represents the earliest possible time (in whole seconds) that still falls within the current object\'s day, in the object\'s timezone context""" return self.__class__(self._year,self._month,self._day,0,0,1,self._tz)
3,769
def manage_test(self, REQUEST):
def manage_test(self, REQUEST):
3,770
def manage_test(self, REQUEST):
def manage_test(self, REQUEST):
3,771
def manage_test(self, REQUEST):
def manage_test(self, REQUEST):
3,772
def name_param(params,tag='',expr=0): used=params.has_key if used(''): if used('name'): raise ParseError, _tm('Two names were given', tag) if expr: if used('expr'): raise ParseError, _tm('name and expr given', tag) return params[''],None return params[''] elif used('name'): if expr: if used('expr'): raise ParseError, _tm('name and expr given', tag) return params['name'],None return params['name'] elif expr and used('expr'): name=params['expr'] expr=VSEval.Eval(name, __mul__=VSEval.careful_mul, __getattr__=None) return name, expr raise ParseError, ('No name given', tag)
def name_param(params,tag='',expr=0): used=params.has_key if used(''): if used('name'): raise ParseError, _tm('Two names were given', tag) if expr: if used('expr'): raise ParseError, _tm('name and expr given', tag) return params[''],None return params[''] elif used('name'): if expr: if used('expr'): raise ParseError, _tm('name and expr given', tag) return params['name'],None return params['name'] elif expr and used('expr'): name=params['expr'] expr=VSEval.Eval(name, __mul__=VSEval.careful_mul, __getattr__=careful_getattr, validate=validate) return name, expr raise ParseError, ('No name given', tag)
3,773
def parse_params(text, result=None, tag='', unparmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)\)'), parmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)=\([^\0- =\"]+\)\)'), qparmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)="\([^"]*\)\"\)'), **parms): """Parse tag parameters The format of tag parameters consists of 1 or more parameter specifications separated by whitespace. Each specification consists of an unnamed and unquoted value, a valueless name, or a name-value pair. A name-value pair consists of a name and a quoted or unquoted value separated by an '='. The input parameter, text, gives the text to be parsed. The keyword parameters give valid parameter names and default values. If a specification is not a name-value pair and it is not the first specification that is not a name-value pair and it is a valid parameter name, then it is treated as a name-value pair with a value as given in the keyword argument. Otherwise, if it is not a name-value pair, it is treated as an unnamed value. The data are parsed into a dictionary mapping names to values. Unnamed values are mapped from the name '""'. Only one value may be given for a name and there may be only one unnamed value. """ result=result or {} if parmre.match(text) >= 0: name=lower(parmre.group(2)) value=parmre.group(3) l=len(parmre.group(1)) elif qparmre.match(text) >= 0: name=lower(qparmre.group(2)) value=qparmre.group(3) l=len(qparmre.group(1)) elif unparmre.match(text) >= 0: name=unparmre.group(2) l=len(unparmre.group(1)) if result.has_key(''): if parms.has_key(name): result[name]=parms[name] else: raise ParseError, ( ('Invalid parameter name, %s <!--%s--> <!--u-->' % (name, text)), tag) else: result['']=name return apply(parse_params,(text[l:],result),parms) else: if not text or not strip(text): return result raise InvalidParameter, text if not parms.has_key(name): raise ParseError, ( ('Invalid parameter name, %s <!--%s-->' % (name, text)), tag) result[name]=value text=strip(text[l:]) if text: return apply(parse_params,(text,result),parms) else: return result
def parse_params(text, result=None, tag='', unparmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)\)'), parmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)=\([^\0- =\"]+\)\)'), qparmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)="\([^"]*\)\"\)'), **parms): """Parse tag parameters The format of tag parameters consists of 1 or more parameter specifications separated by whitespace. Each specification consists of an unnamed and unquoted value, a valueless name, or a name-value pair. A name-value pair consists of a name and a quoted or unquoted value separated by an '='. The input parameter, text, gives the text to be parsed. The keyword parameters give valid parameter names and default values. If a specification is not a name-value pair and it is not the first specification that is not a name-value pair and it is a valid parameter name, then it is treated as a name-value pair with a value as given in the keyword argument. Otherwise, if it is not a name-value pair, it is treated as an unnamed value. The data are parsed into a dictionary mapping names to values. Unnamed values are mapped from the name '""'. Only one value may be given for a name and there may be only one unnamed value. """ result=result or {} if parmre.match(text) >= 0: name=lower(parmre.group(2)) value=parmre.group(3) l=len(parmre.group(1)) elif qparmre.match(text) >= 0: name=lower(qparmre.group(2)) value=qparmre.group(3) l=len(qparmre.group(1)) elif unparmre.match(text) >= 0: name=unparmre.group(2) l=len(unparmre.group(1)) if result.has_key(''): if parms.has_key(name): result[name]=parms[name] else: raise ParseError, ( 'Invalid parameter name, "%s"' % name, tag) else: result['']=name return apply(parse_params,(text[l:],result),parms) else: if not text or not strip(text): return result raise InvalidParameter, text if not parms.has_key(name): raise ParseError, ( ('Invalid parameter name, %s <!--%s-->' % (name, text)), tag) result[name]=value text=strip(text[l:]) if text: return apply(parse_params,(text,result),parms) else: return result
3,774
def parse_params(text, result=None, tag='', unparmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)\)'), parmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)=\([^\0- =\"]+\)\)'), qparmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)="\([^"]*\)\"\)'), **parms): """Parse tag parameters The format of tag parameters consists of 1 or more parameter specifications separated by whitespace. Each specification consists of an unnamed and unquoted value, a valueless name, or a name-value pair. A name-value pair consists of a name and a quoted or unquoted value separated by an '='. The input parameter, text, gives the text to be parsed. The keyword parameters give valid parameter names and default values. If a specification is not a name-value pair and it is not the first specification that is not a name-value pair and it is a valid parameter name, then it is treated as a name-value pair with a value as given in the keyword argument. Otherwise, if it is not a name-value pair, it is treated as an unnamed value. The data are parsed into a dictionary mapping names to values. Unnamed values are mapped from the name '""'. Only one value may be given for a name and there may be only one unnamed value. """ result=result or {} if parmre.match(text) >= 0: name=lower(parmre.group(2)) value=parmre.group(3) l=len(parmre.group(1)) elif qparmre.match(text) >= 0: name=lower(qparmre.group(2)) value=qparmre.group(3) l=len(qparmre.group(1)) elif unparmre.match(text) >= 0: name=unparmre.group(2) l=len(unparmre.group(1)) if result.has_key(''): if parms.has_key(name): result[name]=parms[name] else: raise ParseError, ( ('Invalid parameter name, %s <!--%s--> <!--u-->' % (name, text)), tag) else: result['']=name return apply(parse_params,(text[l:],result),parms) else: if not text or not strip(text): return result raise InvalidParameter, text if not parms.has_key(name): raise ParseError, ( ('Invalid parameter name, %s <!--%s-->' % (name, text)), tag) result[name]=value text=strip(text[l:]) if text: return apply(parse_params,(text,result),parms) else: return result
def parse_params(text, result=None, tag='', unparmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)\)'), parmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)=\([^\0- =\"]+\)\)'), qparmre=regex.compile( '\([\0- ]*\([^\0- =\"]+\)="\([^"]*\)\"\)'), **parms): """Parse tag parameters The format of tag parameters consists of 1 or more parameter specifications separated by whitespace. Each specification consists of an unnamed and unquoted value, a valueless name, or a name-value pair. A name-value pair consists of a name and a quoted or unquoted value separated by an '='. The input parameter, text, gives the text to be parsed. The keyword parameters give valid parameter names and default values. If a specification is not a name-value pair and it is not the first specification that is not a name-value pair and it is a valid parameter name, then it is treated as a name-value pair with a value as given in the keyword argument. Otherwise, if it is not a name-value pair, it is treated as an unnamed value. The data are parsed into a dictionary mapping names to values. Unnamed values are mapped from the name '""'. Only one value may be given for a name and there may be only one unnamed value. """ result=result or {} if parmre.match(text) >= 0: name=lower(parmre.group(2)) value=parmre.group(3) l=len(parmre.group(1)) elif qparmre.match(text) >= 0: name=lower(qparmre.group(2)) value=qparmre.group(3) l=len(qparmre.group(1)) elif unparmre.match(text) >= 0: name=unparmre.group(2) l=len(unparmre.group(1)) if result.has_key(''): if parms.has_key(name): result[name]=parms[name] else: raise ParseError, ( ('Invalid parameter name, %s <!--%s--> <!--u-->' % (name, text)), tag) else: result['']=name return apply(parse_params,(text[l:],result),parms) else: if not text or not strip(text): return result raise InvalidParameter, text if not parms.has_key(name): raise ParseError, ( 'Invalid parameter name, "%s"' % name, tag) result[name]=value text=strip(text[l:]) if text: return apply(parse_params,(text,result),parms) else: return result
3,775
def _calcIndependentSecondEtc(tz, x, ms): # Derive the timezone-independent second from the timezone # dependent second. fsetAtEpoch = _tzoffset(tz, 0.0) nearTime = x - fsetAtEpoch - long(EPOCH) + 86400L + ms # nearTime is now within an hour of being correct. # Recalculate t according to DST. fset = long(_tzoffset(tz, nearTime)) x_adjusted = x - fset + ms d = x_adjusted / 86400.0 t = x_adjusted - long(EPOCH) + 86400L millis = (x + 86400 - fset) * 1000 + \ long(ms * 1000.0) - long(EPOCH * 1000.0) s = d - math.floor(d) return s,d,t,millis
def _calcIndependentSecondEtc(tz, x, ms): # Derive the timezone-independent second from the timezone # dependent second. fsetAtEpoch = _tzoffset(tz, 0.0) nearTime = x - fsetAtEpoch - long(EPOCH) + 86400L + ms # nearTime is now within an hour of being correct. # Recalculate t according to DST. fset = long(_tzoffset(tz, nearTime)) x_adjusted = x - fset + ms d = x_adjusted / 86400.0 t = x_adjusted - long(EPOCH) + 86400L millis = (x + 86400 - fset) * 1000 + \ long(round(ms * 1000.0)) - long(EPOCH * 1000.0) s = d - math.floor(d) return s,d,t,millis
3,776
def __str__(self): """Convert a DateTime to a string.""" y,m,d =self._year,self._month,self._day h,mn,s,t=self._hour,self._minute,self._second,self._tz if(h+mn+s): if (s-int(s))> 0.0001: try: # For the seconds, print two digits # before the decimal point. subsec = ('%g' % s).split('.')[1] return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d.%s %s' % ( y,m,d,h,mn,s,subsec,t) except: # Didn't produce the decimal point as expected. # Just fall through. pass return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d %s' % ( y,m,d,h,mn,s,t) return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d %s' % ( y,m,d,h,mn,s,t) else: return '%4.4d/%2.2d/%2.2d' % (y,m,d)
def __str__(self): """Convert a DateTime to a string.""" y,m,d =self._year,self._month,self._day h,mn,s,t=self._hour,self._minute,self._second,self._tz if(h+mn+s): if (s-int(s))> 0.0001: try: # For the seconds, print two digits # before the decimal point. subsec = ('%g' % s).split('.')[1] return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d.%s %s' % ( y,m,d,h,mn,s,subsec,t) except: # Didn't produce the decimal point as expected. # Just fall through. pass return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d %s' % ( y,m,d,h,mn,s,t) return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d %s' % ( y,m,d,h,mn,s,t) else: return '%4.4d/%2.2d/%2.2d' % (y,m,d)
3,777
def __str__(self): """Convert a DateTime to a string.""" y,m,d =self._year,self._month,self._day h,mn,s,t=self._hour,self._minute,self._second,self._tz if(h+mn+s): if (s-int(s))> 0.0001: try: # For the seconds, print two digits # before the decimal point. subsec = ('%g' % s).split('.')[1] return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d.%s %s' % ( y,m,d,h,mn,s,subsec,t) except: # Didn't produce the decimal point as expected. # Just fall through. pass return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d %s' % ( y,m,d,h,mn,s,t) return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d %s' % ( y,m,d,h,mn,s,t) else: return '%4.4d/%2.2d/%2.2d' % (y,m,d)
def __str__(self): """Convert a DateTime to a string.""" y,m,d =self._year,self._month,self._day h,mn,s,t=self._hour,self._minute,self._second,self._tz if(h+mn+s): if (s-int(s))> 0.0001: try: # For the seconds, print two digits # before the decimal point. subsec = ('%g' % s).split('.')[1] return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d.%s %s' % ( y,m,d,h,mn,s,subsec,t) except: # Didn't produce the decimal point as expected. # Just fall through. pass return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d %s' % ( y,m,d,h,mn,s,t) return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d %s' % ( y,m,d,h,mn,s,t) else: return '%4.4d/%2.2d/%2.2d' % (y,m,d)
3,778
def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw): """Render the document given a client object, REQUEST mapping, Response, and key word arguments."""
def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw): """Render the document given a client object, REQUEST mapping, Response, and key word arguments."""
3,779
def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw): """Render the document given a client object, REQUEST mapping, Response, and key word arguments."""
def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw): """Render the document given a client object, REQUEST mapping, Response, and key word arguments."""
3,780
def recordMetaData(self, object, request, # Optimize global var lookups: hasattr=hasattr, getattr=getattr, logger=ac_logger, ): request_get = request.get if hasattr(object, 'getPhysicalPath'): path = '/'.join(object.getPhysicalPath()) else: # Try hard to get the physical path of the object, # but there are many circumstances where that's not possible. to_append = ()
def recordMetaData(self, object, request, # Optimize global var lookups: hasattr=hasattr, getattr=getattr, logger=ac_logger, ): request_get = request.get if hasattr(object, 'getPhysicalPath'): path = '/'.join(object.getPhysicalPath()) else: # Try hard to get the physical path of the object, # but there are many circumstances where that's not possible. to_append = ()
3,781
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
3,782
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
3,783
def env(key,d=environ): try: return d[key] except: if string.upper(key) == 'HTTP_AUTHORIZATION': try: return d['HTTP_CGI_AUTHORIZATION'] except: return '' return ''
def env(key,d=environ): try: return d[key] except: if string.upper(key) == 'HTTP_AUTHORIZATION': try: return d['HTTP_CGI_AUTHORIZATION'] except: return '' return ''
3,784
def __getitem__(self, key): '''\ Get the ResultList objects for the inverted key, key. The key may be a regular expression, in which case a regular expression match is done. The key may be a string, in which case an case-insensitive match is done. ''' index = self._index_object synstop = self.synstop List = self.list_class if (type(key) == RegexType): dict = {} for k in index.keys(): if (key.search(k) >= 0): try: while (type(index[k]) == StringType): k = index[k] except KeyError: continue if (index[k] is None): continue dict[index[k]] = 1 Lists = dict.keys() if (not len(Lists)): return List() return reduce(lambda x, y: x | y, Lists) key = lower(key) while (1): try: key = synstop[key] except KeyError: break if (key is None): return List()
def __getitem__(self, key): '''\ Get the ResultList objects for the inverted key, key. The key may be a regular expression, in which case a regular expression match is done. The key may be a string, in which case an case-insensitive match is done. ''' index = self._index_object synstop = self.synstop List = self.list_class if (type(key) == RegexType): dict = {} for k in index.keys(): if (key.search(k) >= 0): try: while (type(index[k]) == StringType): k = index[k] except KeyError: continue if (index[k] is None): continue dict[index[k]] = 1 Lists = dict.keys() if (not len(Lists)): return List() return reduce(lambda x, y: x | y, Lists) key = lower(key) while (1): try: key = synstop[key] except KeyError: break if (key is None): return List()
3,785
def highlight(self, text, positions, before, after): ws = WordSequence(text, self.synstop) positions.sort() positions.reverse()
def highlight(self, text, positions, before, after): ws = WordSequence(text, self.synstop) positions.sort() positions.reverse()
3,786
def highlight(self, text, positions, before, after): ws = WordSequence(text, self.synstop) positions.sort() positions.reverse()
def highlight(self, text, positions, before, after): ws = WordSequence(text, self.synstop) positions.sort() positions.reverse()
3,787
def _checkApply( self, req, expectedValues ): result, used = self._index._apply_index( req ) assert used == ( 'foo', ) try: length = len(result) except: result = result.keys() length = len(result) assert length == len( expectedValues ), \ '%s | %s' % ( map( None, result ), map(lambda x: x[0], expectedValues )) for k, v in expectedValues: assert k in result
def _checkApply( self, req, expectedValues ): result, used = self._index._apply_index( req ) assert used == ( 'foo', ) assert len(result) == len( expectedValues ), \ '%s | %s' % ( map( None, result ), map(lambda x: x[0], expectedValues )) for k, v in expectedValues: assert k in result
3,788
def test_suite(): return unittest.makeSuite( TestCase )
def test_suite(): return unittest.makeSuite( TestCase )
3,789
def lic_check(product_name): path_join =os.path.join product_dir=path_join(SOFTWARE_HOME,'lib/python/Products') package_dir=path_join(product_dir, product_name) bobobase =Globals.Bobobase try: f=open(path_join(package_dir,'%s.lic' % product_name), 'rb') except: try: product=getattr(__import__("Products.%s" % product_name), product_name) for s in pgetattr(product, 'classes', ()): p=rfind(s,'.') m='Products.%s.%s' % (product_name, s[:p]) c=s[p+1:] __import__(m) setattr(sys.modules[m], c, Expired) except: pass return 0 dat=f.read() f.close() rot=rotor.newrotor('\357\261\390\247\357\362\306\216\226', 13) dat=rot.decrypt(dat) dat=list(dat) dat.reverse() dat=join(dat,'') dat=marshal.loads(dat) del rot name=dat[0] val =dat[1] if name != product_name: return 0 if val is None: return 1 else: if not bobobase.has_key('_t_'): bobobase['_t_']={} t=bobobase['_t_'] if not t.has_key(product_name): t[product_name]=time.time() bobobase['_t_']=t if (t[product_name] + (86400.0 * val)) < time.time(): product=getattr(__import__("Products.%s" % product_name), product_name) for s in pgetattr(product, 'classes', ()): p=rfind(s,'.') m='Products.%s.%s' % (product_name, s[:p]) c=s[p+1:] try: __import__(m) except: m=s[:p] __import__(m) setattr(sys.modules[m], c, Expired) return 0 return 1
def lic_check(product_name): path_join =os.path.join product_dir=path_join(SOFTWARE_HOME,'lib/python/Products') package_dir=path_join(product_dir, product_name) bobobase =Globals.Bobobase try: f=open(path_join(package_dir,'%s.lic' % product_name), 'rb') except: try: product=getattr(__import__("Products.%s" % product_name), product_name) for s in pgetattr(product, 'classes', ()): p=rfind(s,'.') m='Products.%s.%s' % (product_name, s[:p]) c=s[p+1:] __import__(m) setattr(sys.modules[m], c, Expired) except: pass return 0 dat=f.read() f.close() dat=lcd(dat) if dat is None: return 0 name=dat[0] val =dat[1] if name != product_name: return 0 if val is None: return 1 else: if not bobobase.has_key('_t_'): bobobase['_t_']={} t=bobobase['_t_'] if not t.has_key(product_name): t[product_name]=time.time() bobobase['_t_']=t if (t[product_name] + (86400.0 * val)) < time.time(): product=getattr(__import__("Products.%s" % product_name), product_name) for s in pgetattr(product, 'classes', ()): p=rfind(s,'.') m='Products.%s.%s' % (product_name, s[:p]) c=s[p+1:] try: __import__(m) except: m=s[:p] __import__(m) setattr(sys.modules[m], c, Expired) return 0 return 1
3,790
def handler(self, conn): from string import split, join, atoi hdr = conn.recv(10)
def handler(self, conn): from string import split, join, atoi hdr = conn.recv(10)
3,791
def testAllowed(self): """hasRole is an alias for allowed, which should be unaffected.""" try: self.userObject.allowed(None) except DeprecationWarning: self.fail('Expected DeprecationWarning, none given') else: pass
def testAllowed(self): """hasRole is an alias for allowed, which should be unaffected.""" try: self.userObject.allowed(None) except DeprecationWarning: self.fail('Unexpected DeprecationWarning, ' 'no warnings expected here') else: pass
3,792
def filtered_meta_types(self, user): "Those meta types for which a user has adequite permissions." meta_types=[] all=callable(self.all_meta_types) and self.all_meta_types() or \ self.all_meta_types for meta_type in all: if meta_type.has_key('permission'): if user.has_permission(meta_type['permission'],self): meta_types.append(meta_type) else: meta_types.append(meta_type) return meta_types
def filtered_meta_types(self, user): "Those meta types for which a user has adequite permissions." meta_types=[] if callable(self.all_meta_types): all=self.all_meta_types() else: all=self.all_meta_types for meta_type in all: if meta_type.has_key('permission'): if user.has_permission(meta_type['permission'],self): meta_types.append(meta_type) else: meta_types.append(meta_type) return meta_types
3,793
def __getitem__(self, index): """ returns instances of self._v_brains, or whatever is passed into self.useBrains. """ self.useBrains(self._v_brains) r=self._v_result_class(self.data[index]).__of__(self.aq_parent) r.data_record_id_ = index return r
def __getitem__(self, index): """ returns instances of self._v_brains, or whatever is passed into self.useBrains. """ r=self._v_result_class(self.data[index]).__of__(self.aq_parent) r.data_record_id_ = index return r
3,794
def has_key(self, key): return self.__record_schema__.has_key(key)
def has_key(self, key): return self.__record_schema__.has_key(key)
3,795
def has_key(self, key): return self.__record_schema__.has_key(key)
def has_key(self, key): return self.__record_schema__.has_key(key)
3,796
def instantiate(self, record): self.useBrains(self._v_brains)
def instantiate(self, record): self.useBrains(self._v_brains)
3,797
def searchResults(self, REQUEST=None, used=None, query_map={ type(regex.compile('')): Query.Regex, type([]): orify, type(''): Query.String, }, **kw):
def searchResults(self, REQUEST=None, used=None, query_map={ type(regex.compile('')): Query.Regex, type([]): orify, type(''): Query.String, }, **kw):
3,798
def manage_test(self, REQUEST):
def manage_test(self, REQUEST):
3,799