bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def manage_FTPget(self): "Get source for FTP download" return self.read()
|
def manage_FTPget(self): "Get source for FTP download" return self.read()
| 2,900
|
def manage_addUserFolder(self,dtself=None,REQUEST=None,**ignored): """ """ f=UserFolder() self=self.this() try: self._setObject('acl_users', f) except: return MessageDialog( title ='Item Exists', message='This object already contains a User Folder', action ='%s/manage_main' % REQUEST['URL1']) self.__allow_groups__=f if REQUEST: return self.manage_main(self,REQUEST,update_menu=1)
|
def manage_addUserFolder(self,dtself=None,REQUEST=None,**ignored): """ """ f=UserFolder() self=self.this() try: self._setObject('acl_users', f) except: return MessageDialog( title ='Item Exists', message='This object already contains a User Folder', action ='%s/manage_main' % REQUEST['URL1']) self.__allow_groups__=f if REQUEST is not None: REQUEST['RESPONSE'].redirect(self.absolute_url()+'/manage_main')
| 2,901
|
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
|
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
| 2,902
|
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
|
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
| 2,903
|
def doc_literal( self, s, expr=re.compile( "(?:\s|^)'" # open "([^ \t\n\r\f\v']|[^ \t\n\r\f\v'][^\n']*[^ \t\n\r\f\v'])" # contents "'(?:\s|[,.;:!?]|$)" # close ).search): r=expr(s) if r: start, end = r.span(1) return (StructuredTextLiteral(s[start:end]), start-1, end+1) else: return None
|
def doc_literal( self, s, expr=re.compile( "(?:\s|^)'" # open "([^ \t\n\r\f\v']|[^ \t\n\r\f\v'][^\n']*[^ \t\n\r\f\v'])" # contents "'(?:\s|[,.;:!?]|$)" # close ).search): r=expr(s) if r: start, end = r.span(1) return (StructuredTextLiteral(s[start:end]), start-1, end+1) else: return None
| 2,904
|
def doc_literal( self, s, expr=re.compile( "(?:\s|^)'" # open "([^ \t\n\r\f\v']|[^ \t\n\r\f\v'][^\n']*[^ \t\n\r\f\v'])" # contents "'(?:\s|[,.;:!?]|$)" # close ).search): r=expr(s) if r: start, end = r.span(1) return (StructuredTextLiteral(s[start:end]), start-1, end+1) else: return None
|
def doc_literal( self, s, expr=re.compile( "(?:\s|^)'" # open "([^ \t\n\r\f\v']|[^ \t\n\r\f\v'][^\n']*[^ \t\n\r\f\v'])" # contents "'(?:\s|[,.;:!?]|$)" # close ).search): r=expr(s) if r: start, end = r.span(1) return (StructuredTextLiteral(s[start:end]), start-1, end+1) else: return None
| 2,905
|
def doc_emphasize( self, s, expr = re.compile('\s*\*([ \na-zA-Z0-9.:/;,\'\"\?]+)\*(?!\*|-)').search ):
|
def doc_emphasize( self, s, expr = re.compile('\s*\*([ \na-zA-Z0-9.:/;,\'\"\?\=\-\>\<\(\)]+)\*(?!\*|-)').search ):
| 2,906
|
def __cmp__(self,other): return cmp((self.co_argcount, self.co_varnames), (other.co_argcount, other.co_varnames))
|
def __cmp__(self,other): return cmp((self.co_argcount, self.co_varnames), (other.co_argcount, other.co_varnames))
| 2,907
|
def __init__(self,
|
def __init__(self,
| 2,908
|
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
| 2,909
|
def query_data(self,REQUEST):
|
def query_data(self,REQUEST):
| 2,910
|
def manage_test(self,REQUEST):
|
def manage_test(self,REQUEST):
| 2,911
|
def set(self, word): """ return the word id of 'word' """
|
def set(self, word): """ return the word id of 'word' """
| 2,912
|
def testRunIgnoresParentSignals(self): # Spawn a process which will in turn spawn a zdrun process. # We make sure that the zdrun process is still running even if # its parent process receives an interrupt signal (it should # not be passed to zdrun). zdrun_socket = os.path.join(self.here, 'testsock') zdctlpid = os.spawnvp( os.P_NOWAIT, sys.executable, [sys.executable, os.path.join(self.here, 'parent.py')] ) time.sleep(2) # race condition possible here os.kill(zdctlpid, signal.SIGINT) try: response = send_action('status\n', zdrun_socket) or '' except socket.error, msg: response = '' params = response.split('\n') self.assert_(len(params) > 1, repr(response)) # kill the process send_action('exit\n', zdrun_socket)
|
def testRunIgnoresParentSignals(self): # Spawn a process which will in turn spawn a zdrun process. # We make sure that the zdrun process is still running even if # its parent process receives an interrupt signal (it should # not be passed to zdrun). zdrun_socket = os.path.join(self.here, 'testsock') zdctlpid = os.spawnvp( os.P_NOWAIT, sys.executable, [sys.executable, os.path.join(self.here, 'parent.py')] ) deadline = time.time() + 60 is_started = False while time.time() < deadline: response = send_action('status\n', zdrun_socket) if response is None: time.sleep(0.05) else: is_started = True break self.assert_(is_started, "spawned process failed to start in a minute") # race condition possible here os.kill(zdctlpid, signal.SIGINT) try: response = send_action('status\n', zdrun_socket) or '' except socket.error, msg: response = '' params = response.split('\n') self.assert_(len(params) > 1, repr(response)) # kill the process send_action('exit\n', zdrun_socket)
| 2,913
|
def testRunIgnoresParentSignals(self): # Spawn a process which will in turn spawn a zdrun process. # We make sure that the zdrun process is still running even if # its parent process receives an interrupt signal (it should # not be passed to zdrun). zdrun_socket = os.path.join(self.here, 'testsock') zdctlpid = os.spawnvp( os.P_NOWAIT, sys.executable, [sys.executable, os.path.join(self.here, 'parent.py')] ) time.sleep(2) # race condition possible here os.kill(zdctlpid, signal.SIGINT) try: response = send_action('status\n', zdrun_socket) or '' except socket.error, msg: response = '' params = response.split('\n') self.assert_(len(params) > 1, repr(response)) # kill the process send_action('exit\n', zdrun_socket)
|
def testRunIgnoresParentSignals(self): # Spawn a process which will in turn spawn a zdrun process. # We make sure that the zdrun process is still running even if # its parent process receives an interrupt signal (it should # not be passed to zdrun). zdrun_socket = os.path.join(self.here, 'testsock') zdctlpid = os.spawnvp( os.P_NOWAIT, sys.executable, [sys.executable, os.path.join(self.here, 'parent.py')] ) time.sleep(2) # race condition possible here os.kill(zdctlpid, signal.SIGINT) try: response = send_action('status\n', zdrun_socket) or '' except socket.error, msg: response = '' params = response.split('\n') self.assert_(len(params) > 1, repr(response)) # kill the process send_action('exit\n', zdrun_socket)
| 2,914
|
def manage_cache_size(self,value,REQUEST): "set cache size" db = self._getDB() if self._inVersion(): db.setVersionCacheSize(value) else: db.setCacheSize(value)
|
def manage_cache_size(self,value,REQUEST): "set cache size" db = self._getDB() if self._inVersion(): db.setVersionCacheSize(value) else: db.setCacheSize(value)
| 2,915
|
def setRoles(self, roles):
|
def setRoles(self, roles):
| 2,916
|
def delRoles(self, roles):
|
def delRoles(self, roles):
| 2,917
|
def __setstate__(self, state): Globals.Persistent.__setstate__(self, state) if self.connection_string: try: self.connect(self.connection_string) except: LOG.error('Error connecting to relational database.', exc_info=exc_info())
|
def __setstate__(self, state): Globals.Persistent.__setstate__(self, state) if self.connection_string: try: self.connect(self.connection_string) except: LOG.error('Error connecting to relational database.', exc_info=exc_info())
| 2,918
|
def manage_close_connection(self, REQUEST=None): " " try: if hasattr(self,'_v_database_connection'): self._v_database_connection.close() except: LOG.error('Error closing relational database connection.', exc_info=exc_info()) self._v_connected='' if REQUEST is not None: return self.manage_main(self, REQUEST)
|
def manage_close_connection(self, REQUEST=None): " " try: if hasattr(self,'_v_database_connection'): self._v_database_connection.close() except: LOG.error('Error closing relational database connection.', exc_info=True) self._v_connected='' if REQUEST is not None: return self.manage_main(self, REQUEST)
| 2,919
|
def __init__(self, id, baseid, PATH_INFO): self.id=id self._refid=baseid version=PATH_INFO l=version.rfind(/') if l >= 0: version=version[:l] self._version="%s/%s" % (version, id) self.users__draft__=uf=AccessControl.User.UserFolder() self.__allow_groups__=uf
|
def __init__(self, id, baseid, PATH_INFO): self.id=id self._refid=baseid version=PATH_INFO l=version.rfind('/') if l >= 0: version=version[:l] self._version="%s/%s" % (version, id) self.users__draft__=uf=AccessControl.User.UserFolder() self.__allow_groups__=uf
| 2,920
|
def get(self, key, default=None, returnTaints=0, URLmatch=re.compile('URL(PATH)?([0-9]+)$').match, BASEmatch=re.compile('BASE(PATH)?([0-9]+)$').match, ): """Get a variable value
|
def get(self, key, default=None, returnTaints=0, URLmatch=re.compile('URL(PATH)?([0-9]+)$').match, BASEmatch=re.compile('BASE(PATH)?([0-9]+)$').match, ): """Get a variable value
| 2,921
|
def get(self, key, default=None, returnTaints=0, URLmatch=re.compile('URL(PATH)?([0-9]+)$').match, BASEmatch=re.compile('BASE(PATH)?([0-9]+)$').match, ): """Get a variable value
|
def get(self, key, default=None, returnTaints=0, URLmatch=re.compile('URL(PATH)?([0-9]+)$').match, BASEmatch=re.compile('BASE(PATH)?([0-9]+)$').match, ): """Get a variable value
| 2,922
|
def __getattr__(self, name): if name[:3]=='_p_': return BrokenClass.inheritedAttribute('__getattr__')(self, name) raise AttributeError, escape(name)
|
def __getattr__(self, name): if name[:3]=='_p_': return BrokenClass.inheritedAttribute('__getattr__')(self, name) raise AttributeError, escape(name)
| 2,923
|
def registerClass(self, instance_class=None, meta_type='', permission=None, constructors=(), icon=None, permissions=None, legacy=(), ): """Register a constructor
|
def registerClass(self, instance_class=None, meta_type='', permission=None, constructors=(), icon=None, permissions=None, legacy=(), ): """Register a constructor
| 2,924
|
def manage_historyCopy(self, keys=[], RESPONSE=None, URL1=None): "Copy a selected revision to the present" if not keys: raise HistorySelectionError, ( "No historical revision was selected.<p>")
|
def manage_historyCopy(self, keys=[], RESPONSE=None, URL1=None): "Copy a selected revision to the present" if not keys: raise HistorySelectionError, ( "No historical revision was selected.<p>")
| 2,925
|
def _setObject(self,id,object,roles=None,user=None, set_owner=1): v=self._checkId(id) if v is not None: id=v try: t=object.meta_type except: t=None
|
def _setObject(self,id,object,roles=None,user=None, set_owner=1): v=self._checkId(id) if v is not None: id=v try: t=object.meta_type except: t=None
| 2,926
|
def __init__(self,*args): """Return a new date-time object
|
def __init__(self,*args): """Return a new date-time object
| 2,927
|
def __init__(self,*args): """Return a new date-time object
|
def __init__(self,*args): """Return a new date-time object
| 2,928
|
def __init__(self,*args): """Return a new date-time object
|
def __init__(self,*args): """Return a new date-time object
| 2,929
|
def __init__(self,*args): """Return a new date-time object
|
def __init__(self,*args): """Return a new date-time object
| 2,930
|
def __init__(self,*args): """Return a new date-time object
|
def __init__(self,*args): """Return a new date-time object
| 2,931
|
def __init__(self,*args): """Return a new date-time object
|
def __init__(self,*args): """Return a new date-time object
| 2,932
|
def __init__(self,*args): """Return a new date-time object
|
def __init__(self,*args): """Return a new date-time object
| 2,933
|
def __init__(self,*args): """Return a new date-time object
|
def __init__(self,*args): """Return a new date-time object
| 2,934
|
def __init__(self,*args): """Return a new date-time object
|
def __init__(self,*args): """Return a new date-time object
| 2,935
|
def __init__(self,*args): """Return a new date-time object
|
def __init__(self,*args): """Return a new date-time object
| 2,936
|
def __init__(self,*args): """Return a new date-time object
|
def __init__(self,*args): """Return a new date-time object
| 2,937
|
def __init__(self,*args): """Return a new date-time object
|
def __init__(self,*args): """Return a new date-time object
| 2,938
|
def pCommonZ(self):
|
def pCommonZ(self):
| 2,939
|
def __add__(self,other):
|
def __add__(self,other):
| 2,940
|
def __add__(self,other):
|
def __add__(self,other):
| 2,941
|
def __add__(self,other):
|
def __add__(self,other):
| 2,942
|
def leave(self, REQUEST, RESPONSE): """Temporarily stop working in a version""" RESPONSE.setCookie( Globals.VersionNameName,'No longer active', expires="Mon, 25-Jan-1999 23:59:59 GMT", path=REQUEST['SCRIPT_NAME'], ) if (REQUEST.has_key('SERVER_SOFTWARE') and REQUEST['SERVER_SOFTWARE'][:9]=='Microsoft'): # IIS doesn't handle redirect headers correctly return MessageDialog( action=REQUEST['URL1']+'/manage_main', message=('If cookies are enabled by your browser, then ' 'you should have left version %s.' % self.id) ) return RESPONSE.redirect(REQUEST['URL1']+'/manage_main')
|
def leave(self, REQUEST, RESPONSE): """Temporarily stop working in a version""" RESPONSE.setCookie( Globals.VersionNameName,'No longer active', expires="Mon, 25-Jan-1999 23:59:59 GMT", path=(REQUEST['BASEPATH1'] or '/'), ) if (REQUEST.has_key('SERVER_SOFTWARE') and REQUEST['SERVER_SOFTWARE'][:9]=='Microsoft'): # IIS doesn't handle redirect headers correctly return MessageDialog( action=REQUEST['URL1']+'/manage_main', message=('If cookies are enabled by your browser, then ' 'you should have left version %s.' % self.id) ) return RESPONSE.redirect(REQUEST['URL1']+'/manage_main')
| 2,943
|
def evaluate(self, expression, isinstance=isinstance, StringType=StringType): if isinstance(expression, StringType): expression = self._engine.compile(expression) __traceback_supplement__ = ( TALESTracebackSupplement, self, expression) return expression(self)
|
def evaluate(self, expression, isinstance=isinstance, StringType=StringType): if isinstance(expression, StringType): expression = self._engine.compile(expression) __traceback_supplement__ = ( TALESTracebackSupplement, self, expression) return expression(self)
| 2,944
|
def main(): try: opts, args = getopt.getopt(sys.argv[1:], "hu:d:s:", ["help", "user=", "dir=", "skelsrc="] ) except getopt.GetoptError, msg: usage(sys.stderr, msg) sys.exit(2) script = os.path.abspath(sys.argv[0]) user = None password = None skeltarget = None skelsrc = None for opt, arg in opts: if opt in ("-d", "--dir"): skeltarget = os.path.abspath(os.path.expanduser(arg)) if not skeltarget: usage(sys.stderr, "dir must not be empty") sys.exit(2) if opt in ("-s", "--skelsrc"): skelsrc = os.path.abspath(os.path.expanduser(arg)) if not skelsrc: usage(sys.stderr, "skelsrc must not be empty") sys.exit(2) if opt in ("-h", "--help"): usage(sys.stdout) sys.exit() if opt in ("-u", "--user"): if not arg: usage(sys.stderr, "user must not be empty") sys.exit(2) if not ":" in arg: usage(sys.stderr, "user must be specified as name:password") sys.exit(2) user, password = arg.split(":", 1) if not skeltarget: # interactively ask for skeltarget and initial user name/passwd. # cant set custom instancehome in interactive mode, we default # to skeltarget. skeltarget = instancehome = os.path.abspath( os.path.expanduser(get_skeltarget()) ) instancehome = skeltarget zopehome = os.path.dirname(os.path.dirname(script)) softwarehome = os.path.join(zopehome, "lib", "python") configfile = os.path.join(instancehome, 'etc', 'zope.conf') if skelsrc is None: # default to using stock Zope skeleton source skelsrc = os.path.join(zopehome, "skel") inituser = os.path.join(instancehome, "inituser") if not (user or os.path.exists(inituser)): user, password = get_inituser() # we need to distinguish between python.exe and pythonw.exe under # Windows in order to make Zope run using python.exe when run in a # console window and pythonw.exe when run as a service, so we do a bit # of sniffing here. psplit = os.path.split(sys.executable) exedir = os.path.join(*psplit[:-1]) pythonexe = os.path.join(exedir, 'python.exe') pythonwexe = os.path.join(exedir, 'pythonw.exe') if ( os.path.isfile(pythonwexe) and os.path.isfile(pythonexe) and (sys.executable in [pythonwexe, pythonexe]) ): # we're using a Windows build with both python.exe and pythonw.exe # in the same directory PYTHON = pythonexe PYTHONW = pythonwexe else: # we're on UNIX or we have a nonstandard Windows setup PYTHON = PYTHONW = sys.executable kw = { "PYTHON":PYTHON, "PYTHONW":PYTHONW, "INSTANCE_HOME": instancehome, "SOFTWARE_HOME": softwarehome, "ZOPE_HOME": zopehome, } copyzopeskel.copyskel(skelsrc, skeltarget, None, None, **kw) write_inituser(inituser, user, password)
|
def main(): try: opts, args = getopt.getopt(sys.argv[1:], "hu:d:s:", ["help", "user=", "dir=", "skelsrc="] ) except getopt.GetoptError, msg: usage(sys.stderr, msg) sys.exit(2) script = os.path.abspath(sys.argv[0]) user = None password = None skeltarget = None skelsrc = None for opt, arg in opts: if opt in ("-d", "--dir"): skeltarget = os.path.abspath(os.path.expanduser(arg)) if not skeltarget: usage(sys.stderr, "dir must not be empty") sys.exit(2) if opt in ("-s", "--skelsrc"): skelsrc = os.path.abspath(os.path.expanduser(arg)) if not skelsrc: usage(sys.stderr, "skelsrc must not be empty") sys.exit(2) if opt in ("-h", "--help"): usage(sys.stdout) sys.exit() if opt in ("-u", "--user"): if not arg: usage(sys.stderr, "user must not be empty") sys.exit(2) if not ":" in arg: usage(sys.stderr, "user must be specified as name:password") sys.exit(2) user, password = arg.split(":", 1) if not skeltarget: # interactively ask for skeltarget and initial user name/passwd. # cant set custom instancehome in interactive mode, we default # to skeltarget. skeltarget = instancehome = os.path.abspath( os.path.expanduser(get_skeltarget()) ) instancehome = skeltarget zopehome = os.path.dirname(os.path.dirname(script)) softwarehome = os.path.join(zopehome, "lib", "python") configfile = os.path.join(instancehome, 'etc', 'zope.conf') if skelsrc is None: # default to using stock Zope skeleton source skelsrc = os.path.join(zopehome, "skel") inituser = os.path.join(instancehome, "inituser") if not (user or os.path.exists(inituser)): user, password = get_inituser() # we need to distinguish between python.exe and pythonw.exe under # Windows in order to make Zope run using python.exe when run in a # console window and pythonw.exe when run as a service, so we do a bit # of sniffing here. psplit = os.path.split(sys.executable) exedir = os.path.join(*psplit[:-1]) pythonexe = os.path.join(exedir, 'python.exe') pythonwexe = os.path.join(exedir, 'pythonw.exe') if ( os.path.isfile(pythonwexe) and os.path.isfile(pythonexe) and (sys.executable in [pythonwexe, pythonexe]) ): # we're using a Windows build with both python.exe and pythonw.exe # in the same directory PYTHON = pythonexe PYTHONW = pythonwexe else: # we're on UNIX or we have a nonstandard Windows setup PYTHON = PYTHONW = sys.executable kw = { "PYTHON":PYTHON, "PYTHONW":PYTHONW, "INSTANCE_HOME": instancehome, "SOFTWARE_HOME": softwarehome, "ZOPE_HOME": zopehome, } copyzopeskel.copyskel(skelsrc, skeltarget, None, None, **kw) if user and password: write_inituser(inituser, user, password)
| 2,945
|
def __init__(self, blocks): tname, args, section = blocks[0] args=parse_params(args, name='', start='1',end='-1',size='10', orphan='3',overlap='1',mapping=1, skip_unauthorized=1, previous=1, next=1, expr='', sort='', reverse=0) self.args=args has_key=args.has_key
|
def __init__(self, blocks): tname, args, section = blocks[0] args=parse_params(args, name='', start='1',end='-1',size='10', orphan='3',overlap='1',mapping=1, skip_unauthorized=1, previous=1, next=1, expr='', sort='', reverse=1) self.args=args has_key=args.has_key
| 2,946
|
def __init__(self, blocks): tname, args, section = blocks[0] args=parse_params(args, name='', start='1',end='-1',size='10', orphan='3',overlap='1',mapping=1, skip_unauthorized=1, previous=1, next=1, expr='', sort='', reverse=0) self.args=args has_key=args.has_key
|
def __init__(self, blocks): tname, args, section = blocks[0] args=parse_params(args, name='', start='1',end='-1',size='10', orphan='3',overlap='1',mapping=1, skip_unauthorized=1, previous=1, next=1, expr='', sort='', reverse=0) self.args=args has_key=args.has_key
| 2,947
|
def renderwb(self, md): expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
|
def renderwb(self, md): expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
| 2,948
|
def renderwob(self, md): expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
|
def renderwob(self, md): expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
| 2,949
|
def renderwob(self, md): expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
|
def renderwob(self, md): expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
| 2,950
|
def sort_sequence(self, sequence):
|
def sort_sequence(self, sequence):
| 2,951
|
def _get__roles__(self): imp = getattr(self.aq_parent, '%s__roles__' % self.__name__) return imp.__of__(self)
|
def _get__roles__(self): imp = getattr(self.aq_parent, '%s__roles__' % self.__name__) return imp.__of__(self)
| 2,952
|
def unindex_object(self,documentId): try: self.ids.remove(Id) except: pass
|
def unindex_object(self,documentId): try: self.ids.remove(Id) except: pass
| 2,953
|
def _setProperty(self, id, value, type='string'): # for selection and multiple selection properties # the value argument indicates the select variable # of the property id=id.strip() self._wrapperCheck(value) if not self.valid_property_id(id): raise 'Bad Request', 'Invalid or duplicate property id'
|
def _setProperty(self, id, value, type='string'): # for selection and multiple selection properties # the value argument indicates the select variable # of the property self._wrapperCheck(value) if not self.valid_property_id(id): raise 'Bad Request', 'Invalid or duplicate property id'
| 2,954
|
def manage_addProperty(self, id, value, type, REQUEST=None): """Add a new property via the web. Sets a new property with the given id, type, and value.""" if type_converters.has_key(type): value=type_converters[type](value) self._setProperty(id, value, type) if REQUEST is not None: return self.manage_propertiesForm(self, REQUEST)
|
def manage_addProperty(self, id, value, type, REQUEST=None): """Add a new property via the web. Sets a new property with the given id, type, and value.""" if type_converters.has_key(type): value=type_converters[type](value) self._setProperty(id.strip(), value, type) if REQUEST is not None: return self.manage_propertiesForm(self, REQUEST)
| 2,955
|
def __init__(self, name, seq, context): ZTUtils.Iterator.__init__(self, seq) self.name = name self._context = context
|
def __init__(self, name, seq, context): ZTUtils.Iterator.__init__(self, seq) self.name = name self._context = context
| 2,956
|
def next(self): if ZTUtils.Iterator.next(self): self._context.setLocal(self.name, self.item) return 1 return 0
|
def next(self): if ZTUtils.Iterator.next(self): context = self._context_ref() if context is not None: context.setLocal(self.name, self.item) return 1 return 0
| 2,957
|
def __init__(self, id, extra=None, caller=None, index_factory=None, field_name=None, lexicon_id=None): self.id = id
|
def __init__(self, id, extra=None, caller=None, index_factory=None, field_name=None, lexicon_id=None): self.id = id
| 2,958
|
def add(self, id, title, external_name, REQUEST=None): """Add an external method to a folder""" names=split(external_name,'.') module, function = join(names[:-1],'.'), names[-1] i=ExternalMethod(id,title,module,function) self._setObject(id,i) return self.manage_main(self,REQUEST)
|
def add(self, id, title, external_name, REQUEST=None): """Add an external method to a folder""" names=split(external_name,'.') module, function = join(names[:-1],'.'), names[-1] i=ExternalMethod(id,title,module,function) self._setObject(id,i) return self.manage_main(self,REQUEST)
| 2,959
|
def startup(): global app # Import products OFS.Application.import_products() configuration = getConfiguration() # Open the database dbtab = configuration.dbtab try: # Try to use custom storage try: m=imp.find_module('custom_zodb',[configuration.testinghome]) except: m=imp.find_module('custom_zodb',[configuration.instancehome]) except: # if there is no custom_zodb, use the config file specified databases DB = dbtab.getDatabase('/', is_root=1) else: m=imp.load_module('Zope2.custom_zodb', m[0], m[1], m[2]) sys.modules['Zope2.custom_zodb']=m if hasattr(m,'DB'): DB=m.DB dbtab.databases.update(getattr(DB, 'databases', {})) DB.databases = dbtab.databases else: DB = ZODB.DB(m.Storage, databases=dbtab.databases) Globals.BobobaseName = DB.getName() if DB.getActivityMonitor() is None: from ZODB.ActivityMonitor import ActivityMonitor DB.setActivityMonitor(ActivityMonitor()) Globals.DB = DB # Ick, this is temporary until we come up with some registry Zope2.DB = DB # Hook for providing multiple transaction object manager undo support: Globals.UndoManager=DB Globals.opened.append(DB) import ClassFactory DB.classFactory = ClassFactory.ClassFactory # "Log on" as system user newSecurityManager(None, AccessControl.User.system) # Set up the "app" object that automagically opens # connections app = App.ZApplication.ZApplicationWrapper( DB, 'Application', OFS.Application.Application, (), Globals.VersionNameName) Zope2.bobo_application = app # Initialize the app object application = app() OFS.Application.initialize(application) if Globals.DevelopmentMode: # Set up auto-refresh. from App.RefreshFuncs import setupAutoRefresh setupAutoRefresh(application._p_jar) application._p_jar.close() # "Log off" as system user noSecurityManager() global startup_time startup_time = asctime() Zope2.zpublisher_transactions_manager = TransactionsManager() Zope2.zpublisher_exception_hook = zpublisher_exception_hook Zope2.zpublisher_validated_hook = validated_hook Zope2.__bobo_before__ = noSecurityManager
|
def startup(): global app # Import products OFS.Application.import_products() configuration = getConfiguration() # Open the database dbtab = configuration.dbtab try: # Try to use custom storage try: m=imp.find_module('custom_zodb',[configuration.testinghome]) except: m=imp.find_module('custom_zodb',[configuration.instancehome]) except: # if there is no custom_zodb, use the config file specified databases DB = dbtab.getDatabase('/', is_root=1) else: m=imp.load_module('Zope2.custom_zodb', m[0], m[1], m[2]) sys.modules['Zope2.custom_zodb']=m if hasattr(m,'DB'): DB=m.DB databases.update(getattr(DB, 'databases', {})) DB.databases = databases else: DB = ZODB.DB(m.Storage, databases=databases) Globals.BobobaseName = DB.getName() if DB.getActivityMonitor() is None: from ZODB.ActivityMonitor import ActivityMonitor DB.setActivityMonitor(ActivityMonitor()) Globals.DB = DB # Ick, this is temporary until we come up with some registry Zope2.DB = DB # Hook for providing multiple transaction object manager undo support: Globals.UndoManager=DB Globals.opened.append(DB) import ClassFactory DB.classFactory = ClassFactory.ClassFactory # "Log on" as system user newSecurityManager(None, AccessControl.User.system) # Set up the "app" object that automagically opens # connections app = App.ZApplication.ZApplicationWrapper( DB, 'Application', OFS.Application.Application, (), Globals.VersionNameName) Zope2.bobo_application = app # Initialize the app object application = app() OFS.Application.initialize(application) if Globals.DevelopmentMode: # Set up auto-refresh. from App.RefreshFuncs import setupAutoRefresh setupAutoRefresh(application._p_jar) application._p_jar.close() # "Log off" as system user noSecurityManager() global startup_time startup_time = asctime() Zope2.zpublisher_transactions_manager = TransactionsManager() Zope2.zpublisher_exception_hook = zpublisher_exception_hook Zope2.zpublisher_validated_hook = validated_hook Zope2.__bobo_before__ = noSecurityManager
| 2,960
|
def manage_addZCatalog(id, title, vocab_id=None): """ Add a ZCatalog object. 'vocab_id' is the name of a Vocabulary object this catalog should use. A value of None will cause the Catalog to create its own private vocabulary. """
|
def manage_addZCatalog(id, title, vocab_id=None): """ Add a ZCatalog object. 'vocab_id' is the name of a Vocabulary object this catalog should use. A value of None will cause the Catalog to create its own private vocabulary. """
| 2,961
|
def removeForwardIndexEntry(self, entry, documentId): """Take the entry provided and remove any reference to documentId in its entry in the index. """ indexRow = self._index.get(entry, _marker) if indexRow is not _marker: try: indexRow.remove(documentId) if not indexRow: del self._index[entry] self._length.change(-1)
|
def removeForwardIndexEntry(self, entry, documentId): """Take the entry provided and remove any reference to documentId in its entry in the index. """ indexRow = self._index.get(entry, _marker) if indexRow is not _marker: try: indexRow.remove(documentId) if not indexRow: try: del self._index[entry] except KeyError: pass if isinstance(self.__len__, BTrees.Length.Length): self._length = self.__len__ del self.__len__ self._length.change(-1)
| 2,962
|
def insertForwardIndexEntry(self, entry, documentId): """Take the entry provided and put it in the correct place in the forward index.
|
def insertForwardIndexEntry(self, entry, documentId): """Take the entry provided and put it in the correct place in the forward index.
| 2,963
|
def getLexicon(self): """Get the lexicon for this index """ if hasattr(aq_base(self), 'lexicon'): # Fix up old ZCTextIndexes by removing direct lexicon ref # and changing it to an ID lexicon = getattr(aq_parent(aq_inner(self)), self.lexicon.getId()) self.lexicon_id = lexicon.getId() del self.lexicon
|
def getLexicon(self): """Get the lexicon for this index """ if hasattr(aq_base(self), 'lexicon'): # Fix up old ZCTextIndexes by removing direct lexicon ref # and changing it to an ID lexicon = getattr(aq_parent(aq_inner(self)), self.lexicon.getId()) self.lexicon_id = lexicon.getId() del self.lexicon
| 2,964
|
def createZopeEngine(): e = ZopeEngine() e.iteratorFactory = PathIterator for pt in ZopePathExpr._default_type_names: e.registerType(pt, ZopePathExpr) e.registerType('string', StringExpr) e.registerType('python', ZRPythonExpr.PythonExpr) e.registerType('not', NotExpr) e.registerType('defer', DeferExpr) e.registerType('lazy', LazyExpr) e.registerType('provider', TALESProviderExpression) e.registerBaseName('modules', SecureModuleImporter) return e
|
def createZopeEngine(): e = ZopeEngine() e.iteratorFactory = PathIterator for pt in ZopePathExpr._default_type_names: e.registerType(pt, ZopePathExpr) e.registerType('string', StringExpr) e.registerType('python', ZRPythonExpr.PythonExpr) e.registerType('not', NotExpr) e.registerType('defer', DeferExpr) e.registerType('lazy', LazyExpr) e.registerType('provider', Z2ProviderExpression) e.registerBaseName('modules', SecureModuleImporter) return e
| 2,965
|
def get_module_info(module_name, modules={}, acquire=_l.acquire, release=_l.release, ): if modules.has_key(module_name): return modules[module_name] if module_name[-4:]=='.cgi': module_name=module_name[:-4] acquire() try: module=__import__(module_name) realm=module_name # Let the app specify a realm if hasattr(module,'__bobo_realm__'): realm=module.__bobo_realm__ else: realm=module_name # Check whether tracebacks should be hidden: if (hasattr(module,'__bobo_hide_tracebacks__') and not module.__bobo_hide_tracebacks__): CGIResponse._tbopen, CGIResponse._tbclose = '<PRE>', '</PRE>' if hasattr(module,'__bobo_before__'): bobo_before=module.__bobo_before__ else: bobo_before=None if hasattr(module,'__bobo_after__'): bobo_after=module.__bobo_after__ else: bobo_after=None # Get request data from outermost environment: if hasattr(module,'__request_data__'): request_params=module.__request_data__ else: request_params=None # Get initial group data: inherited_groups=[] if hasattr(module,'__allow_groups__'): groups=module.__allow_groups__ inherited_groups.append(groups) else: groups=None web_objects=None roles=UNSPECIFIED_ROLES if hasattr(module,'bobo_application'): object=module.bobo_application if hasattr(object,'__allow_groups__'): groups=object.__allow_groups__ inherited_groups.append(groups) else: groups=None if hasattr(object,'__roles__'): roles=object.__roles__ else: if hasattr(module,'web_objects'): web_objects=module.web_objects object=web_objects else: object=module published=web_objects try: doc=module.__doc__ except: if web_objects is not None: doc=' ' else: doc=None info= (bobo_before, bobo_after, request_params, inherited_groups, groups, roles, object, doc, published, realm, module_name) modules[module_name]=modules[module_name+'.cgi']=info return info finally: release()
|
def get_module_info(module_name, modules={}, acquire=_l.acquire, release=_l.release, ): if modules.has_key(module_name): return modules[module_name] if module_name[-4:]=='.cgi': module_name=module_name[:-4] acquire() try: module=__import__(module_name) realm=module_name # Let the app specify a realm if hasattr(module,'__bobo_realm__'): realm=module.__bobo_realm__ else: realm=module_name # Check whether tracebacks should be hidden: if (hasattr(module,'__bobo_hide_tracebacks__') and not module.__bobo_hide_tracebacks__): CGIResponse._tbopen, CGIResponse._tbclose = '<PRE>', '</PRE>' if hasattr(module,'__bobo_before__'): bobo_before=module.__bobo_before__ else: bobo_before=None if hasattr(module,'__bobo_after__'): bobo_after=module.__bobo_after__ else: bobo_after=None # Get request data from outermost environment: if hasattr(module,'__request_data__'): request_params=module.__request_data__ else: request_params=None # Get initial group data: inherited_groups=[] if hasattr(module,'__allow_groups__'): groups=module.__allow_groups__ inherited_groups.append(groups) else: groups=None web_objects=None roles=UNSPECIFIED_ROLES if hasattr(module,'bobo_application'): object=module.bobo_application if hasattr(object,'__allow_groups__'): groups=object.__allow_groups__ inherited_groups.append(groups) else: groups=None if hasattr(object,'__roles__'): roles=object.__roles__ else: if hasattr(module,'web_objects'): web_objects=module.web_objects object=web_objects else: object=module published=web_objects try: doc=module.__doc__ except: if web_objects is not None: doc=' ' else: doc=None info= (bobo_before, bobo_after, request_params, inherited_groups, groups, roles, object, doc, published, realm, module_name) modules[module_name]=modules[module_name+'.cgi']=info return info finally: release()
| 2,966
|
def setProperty(self, id, value, type='string', meta=None): # Set a new property with the given id, value and optional type. # Note that different property sets may support different typing # systems. if not self.valid_property_id(id): raise 'Bad Request', 'Invalid property id.' self=self.v_self() if meta is None: meta={} prop={'id':id, 'type':type, 'meta':meta} self._properties=self._properties+(prop,) setattr(self, id, value)
|
def _setProperty(self, id, value, type='string', meta=None): # Set a new property with the given id, value and optional type. # Note that different property sets may support different typing # systems. if not self.valid_property_id(id): raise 'Bad Request', 'Invalid property id.' self=self.v_self() if meta is None: meta={} prop={'id':id, 'type':type, 'meta':meta} self._properties=self._properties+(prop,) setattr(self, id, value)
| 2,967
|
def updateProperty(self, id, value): # Update the value of an existing property. If value is a string, # an attempt will be made to convert the value to the type of the # existing property. if not self.hasProperty(id): raise 'Bad Request', 'The property %s does not exist.' % id if type(value)==type(''): proptype=self.propertyInfo(id).get('type', 'string') if type_converters.has_key(proptype): value=type_converters[proptype](value) setattr(self.v_self(), id, value)
|
def _updateProperty(self, id, value): # Update the value of an existing property. If value is a string, # an attempt will be made to convert the value to the type of the # existing property. if not self.hasProperty(id): raise 'Bad Request', 'The property %s does not exist.' % id if type(value)==type(''): proptype=self.propertyInfo(id).get('type', 'string') if type_converters.has_key(proptype): value=type_converters[proptype](value) setattr(self.v_self(), id, value)
| 2,968
|
def delProperty(self, id): # Delete the property with the given id. If a property with the # given id does not exist, a ValueError is raised. if not self.hasProperty(id): raise ValueError, 'The property %s does not exist.' % id self=self.v_self() delattr(self, id) self._properties=tuple(filter(lambda i, n=id: i['id'] != n, self._properties))
|
def _delProperty(self, id): # Delete the property with the given id. If a property with the # given id does not exist, a ValueError is raised. if not self.hasProperty(id): raise ValueError, 'The property %s does not exist.' % id self=self.v_self() delattr(self, id) self._properties=tuple(filter(lambda i, n=id: i['id'] != n, self._properties))
| 2,969
|
def manage_addProperty(self, id, value, type, REQUEST=None): """Add a new property via the web. Sets a new property with the given id, type, and value.""" if type_converters.has_key(type): value=type_converters[type](value) self.setProperty(id, value, type) if REQUEST is not None: return self.manage_propertiesForm(self, REQUEST)
|
def manage_addProperty(self, id, value, type, REQUEST=None): """Add a new property via the web. Sets a new property with the given id, type, and value.""" if type_converters.has_key(type): value=type_converters[type](value) self._setProperty(id, value, type) if REQUEST is not None: return self.manage_propertiesForm(self, REQUEST)
| 2,970
|
def manage_changeProperties(self, REQUEST=None, **kw): """Change existing object properties by passing either a mapping object of name:value pairs {'foo':6} or passing name=value parameters.""" if REQUEST is None: props={} else: props=REQUEST if kw: for name, value in kw.items(): props[name]=value propdict=self.propdict() vself=self.v_self() for name, value in props.items(): if self.hasProperty(name): if not 'w' in propdict[name].get('mode', 'wd'): raise 'BadRequest', '%s cannot be changed.' % name vself.updateProperty(name, value) if REQUEST is not None: return MessageDialog( title ='Success!', message='Your changes have been saved.', action ='manage_propertiesForm')
|
def manage_changeProperties(self, REQUEST=None, **kw): """Change existing object properties by passing either a mapping object of name:value pairs {'foo':6} or passing name=value parameters.""" if REQUEST is None: props={} else: props=REQUEST if kw: for name, value in kw.items(): props[name]=value propdict=self.propdict() vself=self.v_self() for name, value in props.items(): if self.hasProperty(name): if not 'w' in propdict[name].get('mode', 'wd'): raise 'BadRequest', '%s cannot be changed.' % name vself._updateProperty(name, value) if REQUEST is not None: return MessageDialog( title ='Success!', message='Your changes have been saved.', action ='manage_propertiesForm')
| 2,971
|
def manage_delProperties(self, ids=None, REQUEST=None): """Delete one or more properties specified by 'ids'.""" if ids is None: return MessageDialog( title='No property specified', message='No properties were specified!', action ='./manage_propertiesForm',) propdict=self.propdict() vself=self.v_self() if hasattr(vself, '_reserved_names'): nd=vself._reserved_names else: nd=() for id in ids: if not propdict.has_key(id): raise 'BadRequest', ( 'The property <em>%s</em> does not exist.' % id) if (not 'd' in propdict[id].get('mode', 'wd')) or (id in nd): return MessageDialog( title ='Cannot delete %s' % id, message='The property <em>%s</em> cannot be deleted.' % id, action ='manage_propertiesForm') self.delProperty(id) if REQUEST is not None: return self.manage_propertiesForm(self, REQUEST)
|
def manage_delProperties(self, ids=None, REQUEST=None): """Delete one or more properties specified by 'ids'.""" if ids is None: return MessageDialog( title='No property specified', message='No properties were specified!', action ='./manage_propertiesForm',) propdict=self.propdict() vself=self.v_self() if hasattr(vself, '_reserved_names'): nd=vself._reserved_names else: nd=() for id in ids: if not propdict.has_key(id): raise 'BadRequest', ( 'The property <em>%s</em> does not exist.' % id) if (not 'd' in propdict[id].get('mode', 'wd')) or (id in nd): return MessageDialog( title ='Cannot delete %s' % id, message='The property <em>%s</em> cannot be deleted.' % id, action ='manage_propertiesForm') self._delProperty(id) if REQUEST is not None: return self.manage_propertiesForm(self, REQUEST)
| 2,972
|
def setProperty(self, id, value, type='string', meta=None): raise ValueError, 'Property cannot be set.'
|
def _setProperty(self, id, value, type='string', meta=None): raise ValueError, 'Property cannot be set.'
| 2,973
|
def updateProperty(self, id, value): raise ValueError, 'Property cannot be set.'
|
def _updateProperty(self, id, value): raise ValueError, 'Property cannot be set.'
| 2,974
|
def delProperty(self, id): raise ValueError, 'Property cannot be deleted.'
|
def _delProperty(self, id): raise ValueError, 'Property cannot be deleted.'
| 2,975
|
def parse_text(s): if find(s,'\\') < 0 or (find(s,'\\t') < 0 and find(s,'\\n') < 0): return s r=[] for x in split(s,'\\\\'): x=join(split(x,'\\n'),'\n') r.append(join(split(x,'\\t'),'\t')) return join(r,'\\')
|
def parse_text(s): if find(s,'\\') < 0 and (find(s,'\\t') < 0 and find(s,'\\n') < 0): return s r=[] for x in split(s,'\\\\'): x=join(split(x,'\\n'),'\n') r.append(join(split(x,'\\t'),'\t')) return join(r,'\\')
| 2,976
|
def LOG(subsystem, severity, summary, detail='', error=None, reraise=None): """Log some information The required arguments are: subsystem -- The subsystem generating the message (e.g. ZODB) severity -- The "severity" of the event. This may be an integer or a floating point number. Logging back ends may consider the int() of this value to be significant. For example, a backend may consider any severity whos integer value is WARNING to be a warning. summary -- A short summary of the event detail -- A detailed description error -- A three-element tuple consisting of an error type, value, and traceback. If provided, then a summary of the error is added to the detail. reraise -- If provided with a true value, then the error given by error is reraised. """ warnings.warn('Using the zLOG module is deprecated (to be removed in ' 'Zope 2.12. Use the Python logging module instead.', DeprecationWarning, stacklevel=2) log_write(subsystem, severity, summary, detail, error) if reraise and error: raise error[0], error[1], error[2]
|
def LOG(subsystem, severity, summary, detail='', error=None, reraise=None): """Log some information The required arguments are: subsystem -- The subsystem generating the message (e.g. ZODB) severity -- The "severity" of the event. This may be an integer or a floating point number. Logging back ends may consider the int() of this value to be significant. For example, a backend may consider any severity whos integer value is WARNING to be a warning. summary -- A short summary of the event detail -- A detailed description error -- A three-element tuple consisting of an error type, value, and traceback. If provided, then a summary of the error is added to the detail. reraise -- If provided with a true value, then the error given by error is reraised. """ warnings.warn('The zLOG package is deprecated and will be removed in ' 'Zope 2.12. Use the Python logging module instead.', DeprecationWarning, stacklevel=2) log_write(subsystem, severity, summary, detail, error) if reraise and error: raise error[0], error[1], error[2]
| 2,977
|
def dav__source(self): vself=self.v_self() if hasattr(vself, 'meta_type') and vself.meta_type in \ ('Document', 'DTML Document', 'DTML Method'): url=vself.absolute_url() return '\n <n:src>%s</n:src>\n' \ ' <n:dst>%s/document_src</n:dst>\n ' % (url, url) return ''
|
def dav__source(self): vself=self.v_self() if hasattr(vself, 'meta_type') and vself.meta_type in \ ('Document', 'DTML Document', 'DTML Method'): url=vself.absolute_url() return '\n <n:link>\n' \ ' <n:src>%s</n:src>\n' \ ' <n:dst>%s/document_src</n:dst>\n' \ ' </n:link>\n ' % (url, url) return ''
| 2,978
|
def add(self, id, title='', smtp_host=None, smtp_port=25, REQUEST=None): ' add a MailHost into the system ' i=MailHost() #create new mail host i.id=id #give it id i.title=title #title i._init(smtpHost=smtp_host, smtpPort=smtp_port) self._setObject(id,i) #register it if REQUEST: return self.manage_main(self,REQUEST)
|
def add(self, id, title='', smtp_host=None, smtp_port=25, REQUEST=None): ' add a MailHost into the system ' i=MailHost() #create new mail host i.id=id #give it id i.title=title #title i._init(smtp_host=smtp_host, smtp_port=smtp_port) self._setObject(id,i) #register it if REQUEST: return self.manage_main(self,REQUEST)
| 2,979
|
def _init(self, smtpHost, smtpPort): self.smtpHost=smtpHost self.smtpPort=smtpPort
|
def _init(self, smtpHost, smtpPort): self.smtpHost=smtpHost self.smtpPort=smtpPort
| 2,980
|
def manage_makeChanges(self,title,smtpHost,smtpPort, REQUEST=None): 'make the changes' self.title=title self.smtpHost=smtpHost self.smtpPort=smtpPort if REQUEST: return MessageDialog( title ='Changed %s' % self.__name__, message='%s has been updated' % self.id, action =REQUEST['URL2']+'/manage_main', target ='manage_main')
|
def manage_makeChanges(self,title,smtpHost,smtpPort, REQUEST=None): 'make the changes' self.title=title self.smtp_host=smtp_host self.smtp_port=smtp_port if REQUEST: return MessageDialog( title ='Changed %s' % self.__name__, message='%s has been updated' % self.id, action =REQUEST['URL2']+'/manage_main', target ='manage_main')
| 2,981
|
def sendTemplate(trueself, self, messageTemplate, statusTemplate=None, mto=None, mfrom=None, encode=None, REQUEST=None): 'render a mail template, then send it...' mtemplate = getattr(self, messageTemplate) messageText = mtemplate(self, trueself.REQUEST) messageText=_encode(messageText, encode) headers = extractheaders(messageText) if mto: headers['to'] = mto if mfrom: headers['from'] = mfrom for requiredHeader in ('to', 'from'): if not headers.has_key(requiredHeader): raise MailHostError,"Message missing SMTP Header '%s'"\ % requiredHeader mailserver = SMTP(trueself.smtpHost, trueself.smtpPort) mailserver.sendmail(headers['from'], headers['to'], messageText)
|
def sendTemplate(trueself, self, messageTemplate, statusTemplate=None, mto=None, mfrom=None, encode=None, REQUEST=None): 'render a mail template, then send it...' mtemplate = getattr(self, messageTemplate) messageText = mtemplate(self, trueself.REQUEST) messageText=_encode(messageText, encode) headers = extractheaders(messageText) if mto: headers['to'] = mto if mfrom: headers['from'] = mfrom for requiredHeader in ('to', 'from'): if not headers.has_key(requiredHeader): raise MailHostError,"Message missing SMTP Header '%s'"\ % requiredHeader mailserver = SMTP(trueself.smtp_host, trueself.smtp_port) mailserver.sendmail(headers['from'], headers['to'], messageText)
| 2,982
|
def send(self, messageText, mto=None, mfrom=None, subject=None, encode=None): headers = extractheaders(messageText) if not headers['subject']: messageText="subject: %s\n%s" % (subject or '[No Subject]', messageText) if mto: if type(mto) is type('s'): mto=map(string.strip, string.split(mto,',')) headers['to'] = filter(truth, mto) if mfrom: headers['from'] = mfrom for requiredHeader in ('to', 'from'): if not headers.has_key(requiredHeader): raise MailHostError,"Message missing SMTP Header '%s'"\ % requiredHeader messageText=_encode(messageText, encode) smtpserver = SMTP(self.smtpHost, self.smtpPort) smtpserver.sendmail(headers['from'],headers['to'], messageText)
|
def send(self, messageText, mto=None, mfrom=None, subject=None, encode=None): headers = extractheaders(messageText) if not headers['subject']: messageText="subject: %s\n%s" % (subject or '[No Subject]', messageText) if mto: if type(mto) is type('s'): mto=map(string.strip, string.split(mto,',')) headers['to'] = filter(truth, mto) if mfrom: headers['from'] = mfrom for requiredHeader in ('to', 'from'): if not headers.has_key(requiredHeader): raise MailHostError,"Message missing SMTP Header '%s'"\ % requiredHeader messageText=_encode(messageText, encode) smtpserver = SMTP(self.smtp_host, self.smtp_port) smtpserver.sendmail(headers['from'],headers['to'], messageText)
| 2,983
|
def scheduledSend(self, messageText, mto=None, mfrom=None, subject=None, encode=None): headers = extractheaders(messageText)
|
def scheduledSend(self, messageText, mto=None, mfrom=None, subject=None, encode=None): headers = extractheaders(messageText)
| 2,984
|
def simple_send(self, mto, mfrom, subject, body): body="from: %s\nto: %s\nsubject: %s\n\n%s" % ( mfrom, mto, subject, body) mailserver = SMTP(self.smtphost, self.smtpport) mailserver.sendmail(mfrom, mto, body)
|
def simple_send(self, mto, mfrom, subject, body): body="from: %s\nto: %s\nsubject: %s\n\n%s" % ( mfrom, mto, subject, body) mailserver = SMTP(self.smtp_host, self.smtp_port) mailserver.sendmail(mfrom, mto, body)
| 2,985
|
def main(argv): short_options = ':u:p:e:d:' long_options = ['username=', 'password=', 'encoding=', 'domains='] usage = """%s [options] filename
|
def main(argv): short_options = ':u:p:e:d:' long_options = ['username=', 'password=', 'encoding=', 'domains='] usage = """%s [options] filename
| 2,986
|
def fancy_replace(a, alo, ahi, b, blo, bhi): if TRACE: print '*** fancy_replace', alo, ahi, blo, bhi dump('>', a, alo, ahi) dump('<', b, blo, bhi) # don't synch up unless the lines have a similarity score of at # least cutoff; best_ratio tracks the best score seen so far best_ratio, cutoff = 0.74, 0.75 cruncher = SequenceMatcher(IS_CHARACTER_JUNK) eqi, eqj = None, None # 1st indices of equal lines (if any) # search for the pair that matches best without being identical # (identical lines must be junk lines, & we don't want to synch up # on junk -- unless we have to) for j in xrange(blo, bhi): bj = b[j] cruncher.set_seq2(bj) for i in xrange(alo, ahi): ai = a[i] if ai == bj: if eqi is None: eqi, eqj = i, j continue cruncher.set_seq1(ai) # computing similarity is expensive, so use the quick # upper bounds first -- have seen this speed up messy # compares by a factor of 3. # note that ratio() is only expensive to compute the first # time it's called on a sequence pair; the expensive part # of the computation is cached by cruncher if cruncher.real_quick_ratio() > best_ratio and \ cruncher.quick_ratio() > best_ratio and \ cruncher.ratio() > best_ratio: best_ratio, best_i, best_j = cruncher.ratio(), i, j if best_ratio < cutoff: # no non-identical "pretty close" pair if eqi is None: # no identical pair either -- treat it as a straight replace plain_replace(a, alo, ahi, b, blo, bhi) return # no close pair, but an identical pair -- synch up on that best_i, best_j, best_ratio = eqi, eqj, 1.0 else: # there's a close pair, so forget the identical pair (if any) eqi = None # a[best_i] very similar to b[best_j]; eqi is None iff they're not # identical if TRACE: print '*** best_ratio', best_ratio, best_i, best_j dump('>', a, best_i, best_i+1) dump('<', b, best_j, best_j+1) # pump out diffs from before the synch point fancy_helper(a, alo, best_i, b, blo, best_j) # do intraline marking on the synch pair aelt, belt = a[best_i], b[best_j] if eqi is None: # pump out a '-', '+', '?' triple for the synched lines; atags = btags = "" cruncher.set_seqs(aelt, belt) for tag, ai1, ai2, bj1, bj2 in cruncher.get_opcodes(): la, lb = ai2 - ai1, bj2 - bj1 if tag == 'replace': atags = atags + '.' * la btags = btags + '.' * lb elif tag == 'delete': atags = atags + '.' * la elif tag == 'insert': btags = btags + '.' * lb elif tag == 'equal': atags = atags + ' ' * la btags = btags + ' ' * lb else: raise ValueError, 'unknown tag ' + `tag` la, lb = len(atags), len(btags) if la < lb: atags = atags + ' ' * (lb - la) elif lb < la: btags = btags + ' ' * (la - lb) combined = map(lambda x,y: _combine[x+y], atags, btags) print '-', aelt, '+', belt, '?', \ ''.string.join(combined).rstrip() else: # the synch pair is identical print ' ', aelt, # pump out diffs from after the synch point fancy_helper(a, best_i+1, ahi, b, best_j+1, bhi)
|
def fancy_replace(a, alo, ahi, b, blo, bhi): if TRACE: print '*** fancy_replace', alo, ahi, blo, bhi dump('>', a, alo, ahi) dump('<', b, blo, bhi) # don't synch up unless the lines have a similarity score of at # least cutoff; best_ratio tracks the best score seen so far best_ratio, cutoff = 0.74, 0.75 cruncher = SequenceMatcher(IS_CHARACTER_JUNK) eqi, eqj = None, None # 1st indices of equal lines (if any) # search for the pair that matches best without being identical # (identical lines must be junk lines, & we don't want to synch up # on junk -- unless we have to) for j in xrange(blo, bhi): bj = b[j] cruncher.set_seq2(bj) for i in xrange(alo, ahi): ai = a[i] if ai == bj: if eqi is None: eqi, eqj = i, j continue cruncher.set_seq1(ai) # computing similarity is expensive, so use the quick # upper bounds first -- have seen this speed up messy # compares by a factor of 3. # note that ratio() is only expensive to compute the first # time it's called on a sequence pair; the expensive part # of the computation is cached by cruncher if cruncher.real_quick_ratio() > best_ratio and \ cruncher.quick_ratio() > best_ratio and \ cruncher.ratio() > best_ratio: best_ratio, best_i, best_j = cruncher.ratio(), i, j if best_ratio < cutoff: # no non-identical "pretty close" pair if eqi is None: # no identical pair either -- treat it as a straight replace plain_replace(a, alo, ahi, b, blo, bhi) return # no close pair, but an identical pair -- synch up on that best_i, best_j, best_ratio = eqi, eqj, 1.0 else: # there's a close pair, so forget the identical pair (if any) eqi = None # a[best_i] very similar to b[best_j]; eqi is None iff they're not # identical if TRACE: print '*** best_ratio', best_ratio, best_i, best_j dump('>', a, best_i, best_i+1) dump('<', b, best_j, best_j+1) # pump out diffs from before the synch point fancy_helper(a, alo, best_i, b, blo, best_j) # do intraline marking on the synch pair aelt, belt = a[best_i], b[best_j] if eqi is None: # pump out a '-', '+', '?' triple for the synched lines; atags = btags = "" cruncher.set_seqs(aelt, belt) for tag, ai1, ai2, bj1, bj2 in cruncher.get_opcodes(): la, lb = ai2 - ai1, bj2 - bj1 if tag == 'replace': atags = atags + '.' * la btags = btags + '.' * lb elif tag == 'delete': atags = atags + '.' * la elif tag == 'insert': btags = btags + '.' * lb elif tag == 'equal': atags = atags + ' ' * la btags = btags + ' ' * lb else: raise ValueError, 'unknown tag ' + `tag` la, lb = len(atags), len(btags) if la < lb: atags = atags + ' ' * (lb - la) elif lb < la: btags = btags + ' ' * (la - lb) combined = map(lambda x,y: _combine[x+y], atags, btags) print '-', aelt, '+', belt, '?', \ ''.join(combined).rstrip() else: # the synch pair is identical print ' ', aelt, # pump out diffs from after the synch point fancy_helper(a, best_i+1, ahi, b, best_j+1, bhi)
| 2,987
|
def v_self(self): return self.aq_parent.aq_parent
|
def v_self(self): return self.aq_parent.aq_parent
| 2,988
|
def dav__getlastmodified(self): vself=self.v_self() if hasattr(vself, '_p_mtime'): return rfc1123_date(vself._p_mtime) return ''
|
def dav__getlastmodified(self): vself=self.v_self() if hasattr(vself, '_p_mtime'): return rfc1123_date(vself._p_mtime) return ''
| 2,989
|
def finish_starttag(self, tag, attrs): self.scan_xmlns(attrs) if tag in EMPTY_HTML_TAGS: print "<%s>" % tag self.pop_xmlns() elif tag in CLOSING_BLOCK_LEVEL_HTML_TAGS: close_to = -1 for i in range(len(self.tagstack)): t = self.tagstack[i] if t in CLOSING_BLOCK_LEVEL_HTML_TAGS: close_to = i elif t in BLOCK_LEVEL_HTML_TAGS: close_to = -1 self._close_to_level(close_to) self.tagstack.append(tag) elif tag in PARA_LEVEL_HTML_TAGS + BLOCK_LEVEL_HTML_TAGS: close_to = -1 for i in range(len(self.tagstack)): if self.tagstack[i] in BLOCK_LEVEL_HTML_TAGS: close_to = -1 elif self.tagstack[i] in PARA_LEVEL_HTML_TAGS: if close_to == -1: close_to = i self.tagstack.append(tag) self._close_to_level(close_to) else: self.tagstack.append(tag) self.gen.emitStartTag(tag, attrs)
|
def finish_starttag(self, tag, attrs): self.scan_xmlns(attrs) if tag in EMPTY_HTML_TAGS: self.pop_xmlns() elif tag in CLOSING_BLOCK_LEVEL_HTML_TAGS: close_to = -1 for i in range(len(self.tagstack)): t = self.tagstack[i] if t in CLOSING_BLOCK_LEVEL_HTML_TAGS: close_to = i elif t in BLOCK_LEVEL_HTML_TAGS: close_to = -1 self._close_to_level(close_to) self.tagstack.append(tag) elif tag in PARA_LEVEL_HTML_TAGS + BLOCK_LEVEL_HTML_TAGS: close_to = -1 for i in range(len(self.tagstack)): if self.tagstack[i] in BLOCK_LEVEL_HTML_TAGS: close_to = -1 elif self.tagstack[i] in PARA_LEVEL_HTML_TAGS: if close_to == -1: close_to = i self.tagstack.append(tag) self._close_to_level(close_to) else: self.tagstack.append(tag) self.gen.emitStartTag(tag, attrs)
| 2,990
|
def finish_starttag(self, tag, attrs): self.scan_xmlns(attrs) if tag in EMPTY_HTML_TAGS: print "<%s>" % tag self.pop_xmlns() elif tag in CLOSING_BLOCK_LEVEL_HTML_TAGS: close_to = -1 for i in range(len(self.tagstack)): t = self.tagstack[i] if t in CLOSING_BLOCK_LEVEL_HTML_TAGS: close_to = i elif t in BLOCK_LEVEL_HTML_TAGS: close_to = -1 self._close_to_level(close_to) self.tagstack.append(tag) elif tag in PARA_LEVEL_HTML_TAGS + BLOCK_LEVEL_HTML_TAGS: close_to = -1 for i in range(len(self.tagstack)): if self.tagstack[i] in BLOCK_LEVEL_HTML_TAGS: close_to = -1 elif self.tagstack[i] in PARA_LEVEL_HTML_TAGS: if close_to == -1: close_to = i self.tagstack.append(tag) self._close_to_level(close_to) else: self.tagstack.append(tag) self.gen.emitStartTag(tag, attrs)
|
def finish_starttag(self, tag, attrs): self.scan_xmlns(attrs) if tag in EMPTY_HTML_TAGS: print "<%s>" % tag self.pop_xmlns() elif tag in CLOSING_BLOCK_LEVEL_HTML_TAGS: close_to = -1 for i in range(len(self.tagstack)): t = self.tagstack[i] if t in CLOSING_BLOCK_LEVEL_HTML_TAGS: close_to = i elif t in BLOCK_LEVEL_HTML_TAGS: close_to = -1 self.tagstack.append(tag) elif tag in PARA_LEVEL_HTML_TAGS + BLOCK_LEVEL_HTML_TAGS: close_to = -1 for i in range(len(self.tagstack)): if self.tagstack[i] in BLOCK_LEVEL_HTML_TAGS: close_to = -1 elif self.tagstack[i] in PARA_LEVEL_HTML_TAGS: if close_to == -1: close_to = i self.tagstack.append(tag) else: self.tagstack.append(tag) self.gen.emitStartTag(tag, attrs)
| 2,991
|
def _close_to_level(self, close_to): if close_to > -1: closing = self.tagstack[close_to:] closing.reverse() for t in closing: self.finish_endtag(t)
|
def _close_to_level(self, close_to): if close_to > -1: closing = self.tagstack[close_to:] closing.reverse() for t in closing: self.finish_endtag(t)
| 2,992
|
def finish_endtag(self, tag): if tag not in EMPTY_HTML_TAGS: assert tag in self.tagstack while self.tagstack[-1] != tag: self.finish_endtag(self.tagstack[-1]) self.tagstack.pop() self.pop_xmlns() self.gen.emitEndTag(tag)
|
def finish_endtag(self, tag): if tag not in EMPTY_HTML_TAGS: assert tag in self.tagstack while self.tagstack[-1] != tag: self.finish_endtag(self.tagstack[-1]) self.tagstack.pop() self.pop_xmlns() self.gen.emitEndTag(tag)
| 2,993
|
def raise_standardErrorMessage( self, client=None, REQUEST={}, error_type=None, error_value=None, tb=None, error_tb=None, error_message='', tagSearch=regex.compile('[a-zA-Z]>').search):
|
def raise_standardErrorMessage( self, client=None, REQUEST={}, error_type=None, error_value=None, tb=None, error_tb=None, error_message='', tagSearch=regex.compile('[a-zA-Z]>').search):
| 2,994
|
def test(*args, **kw): return apply(ZPublisher.test,('Zope',)+args, kw)
|
def debug(*args, **kw): return apply(ZPublisher.test,('Zope',)+args, kw)
| 2,995
|
def appendCookie(self, name, value):
|
def appendCookie(self, name, value):
| 2,996
|
def expireCookie(self, name):
|
def expireCookie(self, name):
| 2,997
|
def setCookie(self,name,value,**kw):
|
def setCookie(self,name,value,**kw):
| 2,998
|
def setCookie(self,name,value,**kw):
|
def setCookie(self,name,value,**kw):
| 2,999
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.