def __init__(self, ticket, site=None): super(XmlRpcInit,self).__init__() if not site: # if not explicitly set, keep the current site site = Site.get_site() self.set_app_server("xmlrpc") self.ticket = ticket # clear the main container #Container.clear() Environment.set_env_object( self ) # set up the security object security = Security() Environment.set_security(security) if site: Site.set_site(site) self._do_login()
def __init__(self, project_code=None, login_code=None, site=None): self.set_app_server("batch") if not site: # if not explicitly set, keep the current site site = Site.get_site() plugin_dir = Environment.get_plugin_dir() if plugin_dir not in sys.path: sys.path.insert(0, plugin_dir) super(Batch,self).__init__() self.login_code = login_code # clear the main container Container.create() if site: Site.set_site(site) # set this as the environment if not project_code: self.context = self.get_default_context() else: self.context = project_code Environment.set_env_object( self ) # set up the security object security = Security() Environment.set_security(security) self._do_login() site_dir = Environment.get_site_dir() if site_dir not in sys.path: sys.path.insert(0, site_dir) # set the project from pyasm.biz import Project if self.context == "batch": Project.set_project("admin") else: Project.set_project(self.context) self.initialize_python_path() # start workflow engine #from pyasm.command import Workflow #Workflow().init() DbContainer.commit_thread_sql()
def _do_login(self): security = Environment.get_security() require_password = Config.get_value("security", "api_require_password") api_password = Config.get_value("security", "api_password") site = Site.get() allow_guest = site.allow_guest() # the xmlrpc login can be overridden to not require a password if require_password == "false" or (allow_guest and self.login_name == "guest"): security.login_user_without_password(self.login_name, expiry="NULL") elif api_password: if api_password == self.password: security.login_user_without_password(self.login_name, expiry="NULL") else: # if api password is incorrect, still try and authenticate with # user's password security.login_user(self.login_name, self.password, expiry="NULL") elif self.login_name == "guest": security.login_user_without_password(self.login_name) else: security.login_user(self.login_name, self.password, expiry="NULL") if not security.is_logged_in(): raise SecurityException("Cannot login as user: %s." % self.login_name)
def __init__(my, project_code=None, login_code=None, site=None): my.set_app_server("batch") plugin_dir = Environment.get_plugin_dir() if plugin_dir not in sys.path: sys.path.insert(0, plugin_dir) super(Batch, my).__init__() my.login_code = login_code # clear the main container Container.create() if site: Site.set_site(site) # set this as the environment if not project_code: my.context = my.get_default_context() else: my.context = project_code Environment.set_env_object(my) # set up the security object security = Security() Environment.set_security(security) my._do_login() site_dir = Environment.get_site_dir() if site_dir not in sys.path: sys.path.insert(0, site_dir) # set the project from pyasm.biz import Project if my.context == "batch": Project.set_project("admin") else: Project.set_project(my.context) my.initialize_python_path() DbContainer.commit_thread_sql()
def __init__(my, project_code=None, login_code=None, site=None): my.set_app_server("batch") plugin_dir = Environment.get_plugin_dir() if plugin_dir not in sys.path: sys.path.insert(0, plugin_dir) super(Batch,my).__init__() my.login_code = login_code # clear the main container Container.create() if site: Site.set_site(site) # set this as the environment if not project_code: my.context = my.get_default_context() else: my.context = project_code Environment.set_env_object( my ) # set up the security object security = Security() Environment.set_security(security) my._do_login() site_dir = Environment.get_site_dir() if site_dir not in sys.path: sys.path.insert(0, site_dir) # set the project from pyasm.biz import Project if my.context == "batch": Project.set_project("admin") else: Project.set_project(my.context) my.initialize_python_path() DbContainer.commit_thread_sql()