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 __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()
# This is to get admin project working if project in ['admin', 'default', 'template', 'unittest']: base = "tactic_sites" else: base = "sites" # get the contexts: if project in ("admin", "default", "template", "unittest"): context_dir = Environment.get_install_dir().replace("\\", "/") context_dir = "%s/src/tactic_sites/%s/context" % (context_dir, project) else: context_dir = Environment.get_site_dir().replace("\\", "/") context_dir = "%s/sites/%s/context" % (context_dir, project) if not os.path.exists(context_dir): return contexts = [] for context_dir in os.listdir(context_dir): if not context_dir.endswith(".py"): continue if context_dir == "__init__.py": continue if context_dir.startswith("."): continue
def register_site(my, site, config): print "Registering project ... %s" % site # if there happend to be . in the site name, convert to _ # NOTE: not sure what the implication of that is??? site = site.replace(".", "_") if site == "template": return # BIG HACK to get admin site working if site in ['admin', 'default', 'template', 'unittest']: base = "tactic_sites" else: base = "sites" try: #exec("from %s.%s.context.Index import Index" % (base,site) ) #exec("cherrypy.root.tactic.%s = Index()" % site) #exec("cherrypy.root.projects.%s = Index()" % site) from tactic.ui.app import SitePage exec("cherrypy.root.tactic.%s = SitePage()" % site) exec("cherrypy.root.projects.%s = SitePage()" % site) except ImportError: #print "... WARNING: Index not found" exec("cherrypy.root.tactic.%s = TacticIndex()" % site) exec("cherrypy.root.projects.%s = TacticIndex()" % site) # get the contexts: if site in ("admin", "default", "template", "unittest"): context_dir = Environment.get_install_dir().replace("\\", "/") context_dir = "%s/src/tactic_sites/%s/context" % (context_dir, site) else: context_dir = Environment.get_site_dir().replace("\\", "/") context_dir = "%s/sites/%s/context" % (context_dir, site) if not os.path.exists(context_dir): #print "WARNING: context directory not found" return contexts = [] for context_dir in os.listdir(context_dir): if not context_dir.endswith(".py"): continue if context_dir == "__init__.py": continue if context_dir.startswith("."): continue if os.path.isdir(context_dir): continue context = context_dir.replace(".py", "") contexts.append(context) for context in contexts: try: exec("from %s.%s.context.%s import %s" % (base, site, context, context)) exec("cherrypy.root.tactic.%s.%s = %s()" % (site, context, context)) except ImportError, e: print str(e) print "... failed to import '%s.%s.%s'" % (base, site, context) raise #return path = "/tactic/%s/%s" % (site, context) settings = {} config[path] = settings if context in ["XMLRPC", "Api"]: settings['xmlrpc_filter.on'] = True # NOTE: is this needed anymore? if context in ["UploadServer"]: settings['flashwrapper.on'] = True
def setup_sites(my): context_path = "%s/src/context" % my.install_dir doc_dir = "%s/doc" % my.install_dir log_dir = "%s/log" % Environment.get_tmp_dir() config = { 'global': { 'server.socket_host': 'localhost', 'server.socket_port': 80, 'server.log_to_screen': False, 'server.environment': 'production', 'server.show_tracebacks': True, 'server.log_request_headers': True, 'server.log_file': "%s/tactic_log" % log_dir, 'server.max_request_body_size': 0, #'server.socket_timeout': 60, 'response.timeout': 3600, 'log_debug_info_filter.on': False, #'encoding_filter.on': True, #'decoding_filter.on': True, }, '/context': { 'static_filter.on': True, 'static_filter.dir': context_path }, '/assets': { 'static_filter.on': True, 'static_filter.dir': Environment.get_asset_dir() }, '/doc': { 'static_filter.on': True, 'static_filter.dir': doc_dir }, '/doc/': { 'static_filter.on': True, 'static_filter.file': "%s/index.html" % doc_dir }, } # set up the root directory cherrypy.root = Root() from tactic_sites.default.context.TitlePage import TitlePage cherrypy.root.tactic = TitlePage() cherrypy.root.projects = TitlePage() sites = [] # add the tactic projects install_dir = Environment.get_install_dir().replace("\\", "/") site_dir = "%s/src/tactic_sites" % install_dir for context_dir in os.listdir(site_dir): if context_dir.startswith(".svn"): continue full_path = "%s/%s" % (site_dir, context_dir) if os.path.isdir(full_path): sites.append(context_dir) # add all the custom projects site_dir = Environment.get_site_dir().replace("\\", "/") site_dir = "%s/sites" % site_dir for context_dir in os.listdir(site_dir): if context_dir.startswith(".svn"): continue full_path = "%s/%s" % (site_dir, context_dir) if os.path.isdir(full_path): sites.append(context_dir) for site in sites: my.register_site(site, config) # set up the images directory for subdir in ['images', 'doc']: config["/tactic/%s/%s/" % (site,subdir)] = { 'static_filter.on': True, 'static_filter.dir': '%s/sites/%s/context/%s/' % \ (site_dir,site, subdir) } return config
def register_site(my, site, config): # if there happend to be . in the site name, convert to _ site = site.replace(".", "_") if site == "template": return print "Registering project ... %s" % site try: from tactic.ui.app import SitePage exec("cherrypy.root.tactic.%s = SitePage()" % site) exec("cherrypy.root.projects.%s = SitePage()" % site) except ImportError: #print "... WARNING: SitePage not found" exec("cherrypy.root.tactic.%s = TacticIndex()" % site) exec("cherrypy.root.projects.%s = TacticIndex()" % site) except SyntaxError: print "WARNING: skipping project [%s]" % site # The rest is only ever executed on the "default" site # This is to get admin site working if site in ['admin', 'default', 'template', 'unittest']: base = "tactic_sites" else: base = "sites" # get the contexts: if site in ("admin", "default", "template", "unittest"): context_dir = Environment.get_install_dir().replace("\\", "/") context_dir = "%s/src/tactic_sites/%s/context" % (context_dir, site) else: context_dir = Environment.get_site_dir().replace("\\", "/") context_dir = "%s/sites/%s/context" % (context_dir, site) if not os.path.exists(context_dir): return contexts = [] for context_dir in os.listdir(context_dir): if not context_dir.endswith(".py"): continue if context_dir == "__init__.py": continue if context_dir.startswith("."): continue if os.path.isdir(context_dir): continue context = context_dir.replace(".py", "") contexts.append(context) for context in contexts: try: exec("from %s.%s.context.%s import %s" % (base, site, context, context)) exec("cherrypy.root.tactic.%s.%s = %s()" % (site, context, context)) except ImportError, e: print str(e) print "... failed to import '%s.%s.%s'" % (base, site, context) raise #return path = "/tactic/%s/%s" % (site, context) settings = {} config[path] = settings if context in ["XMLRPC", "Api"]: #settings['request.dispatch'] = cherrypy.dispatch.XMLRPCDispatcher(), settings['tools.xmlrpc.on'] = True settings['tools.xmlrpc.encoding'] = 'utf-8' settings['tools.xmlrpc.allow_none'] = True
def register_project(my, site, config): print "Registering project ... %s" % site # if there happend to be . in the site name, convert to _ # NOTE: not sure what the implication of that is??? site = site.replace(".", "_") if site == "template": return # BIG HACK to get admin site working if site in ['admin', 'default', 'template', 'unittest']: base = "tactic_sites" else: base = "sites" try: #exec("from %s.%s.context.Index import Index" % (base,site) ) #exec("cherrypy.root.tactic.%s = Index()" % site) #exec("cherrypy.root.projects.%s = Index()" % site) from tactic.ui.app import SitePage exec("cherrypy.root.tactic.%s = SitePage()" % site) exec("cherrypy.root.projects.%s = SitePage()" % site) except ImportError: #print "... WARNING: Index not found" exec("cherrypy.root.tactic.%s = TacticIndex()" % site) exec("cherrypy.root.projects.%s = TacticIndex()" % site) # get the contexts: if site in ("admin", "default", "template", "unittest"): context_dir = Environment.get_install_dir().replace("\\", "/") context_dir = "%s/src/tactic_sites/%s/context" % (context_dir, site) else: context_dir = Environment.get_site_dir().replace("\\", "/") context_dir = "%s/sites/%s/context" % (context_dir, site) if not os.path.exists(context_dir): #print "WARNING: context directory not found" return contexts = [] for context_dir in os.listdir(context_dir): if not context_dir.endswith(".py"): continue if context_dir == "__init__.py": continue if context_dir.startswith("."): continue if os.path.isdir(context_dir): continue context = context_dir.replace(".py", "") contexts.append(context) for context in contexts: try: exec("from %s.%s.context.%s import %s" % (base,site,context,context)) exec("cherrypy.root.tactic.%s.%s = %s()" % (site,context,context) ) except ImportError, e: print str(e) print "... failed to import '%s.%s.%s'" % (base, site, context) raise #return path = "/tactic/%s/%s" % (site, context) settings = {} config[path] = settings if context in ["XMLRPC", "Api"]: settings['xmlrpc_filter.on'] = True # NOTE: is this needed anymore? if context in ["UploadServer"]: settings['flashwrapper.on'] = True
def setup_sites(my): context_path = "%s/src/context" % my.install_dir doc_dir = "%s/doc" % my.install_dir log_dir = "%s/log" % Environment.get_tmp_dir() config = { 'global': {'server.socket_host': 'localhost', 'server.socket_port': 80, 'server.log_to_screen': False, 'server.environment': 'production', 'server.show_tracebacks': True, 'server.log_request_headers': True, 'server.log_file': "%s/tactic_log" % log_dir, 'server.max_request_body_size': 0, #'server.socket_timeout': 60, 'response.timeout': 3600, 'log_debug_info_filter.on': False, #'encoding_filter.on': True, #'decoding_filter.on': True, }, '/context': {'static_filter.on': True, 'static_filter.dir': context_path }, '/assets': {'static_filter.on': True, 'static_filter.dir': Environment.get_asset_dir() }, '/doc': {'static_filter.on': True, 'static_filter.dir': doc_dir }, '/doc/': {'static_filter.on': True, 'static_filter.file': "%s/index.html" % doc_dir }, } # set up the root directory cherrypy.root = Root() from tactic_sites.default.context.TitlePage import TitlePage cherrypy.root.tactic = TitlePage() cherrypy.root.projects = TitlePage() sites = [] # add the tactic projects install_dir = Environment.get_install_dir().replace("\\", "/") site_dir = "%s/src/tactic_sites" % install_dir for context_dir in os.listdir(site_dir): if context_dir.startswith(".svn"): continue full_path = "%s/%s" % (site_dir, context_dir) if os.path.isdir(full_path): sites.append(context_dir) # add all the custom projects site_dir = Environment.get_site_dir().replace("\\", "/") site_dir = "%s/sites" % site_dir for context_dir in os.listdir(site_dir): if context_dir.startswith(".svn"): continue full_path = "%s/%s" % (site_dir, context_dir) if os.path.isdir(full_path): sites.append(context_dir) for site in sites: my.register_project(site, config) # set up the images directory for subdir in ['images', 'doc']: config["/tactic/%s/%s/" % (site,subdir)] = { 'static_filter.on': True, 'static_filter.dir': '%s/sites/%s/context/%s/' % \ (site_dir,site, subdir) } return config
def register_site(my, site, config): # if there happend to be . in the site name, convert to _ site = site.replace(".", "_") if site == "template": return print "Registering project ... %s" % site try: from tactic.ui.app import SitePage exec("cherrypy.root.tactic.%s = SitePage()" % site) exec("cherrypy.root.projects.%s = SitePage()" % site) except ImportError: #print "... WARNING: SitePage not found" exec("cherrypy.root.tactic.%s = TacticIndex()" % site) exec("cherrypy.root.projects.%s = TacticIndex()" % site) except SyntaxError: print "WARNING: skipping project [%s]" % site # The rest is only ever executed on the "default" site # This is to get admin site working if site in ['admin', 'default', 'template', 'unittest']: base = "tactic_sites" else: base = "sites" # get the contexts: if site in ("admin", "default", "template", "unittest"): context_dir = Environment.get_install_dir().replace("\\", "/") context_dir = "%s/src/tactic_sites/%s/context" % (context_dir, site) else: context_dir = Environment.get_site_dir().replace("\\", "/") context_dir = "%s/sites/%s/context" % (context_dir, site) if not os.path.exists(context_dir): return contexts = [] for context_dir in os.listdir(context_dir): if not context_dir.endswith(".py"): continue if context_dir == "__init__.py": continue if context_dir.startswith("."): continue if os.path.isdir(context_dir): continue context = context_dir.replace(".py", "") contexts.append(context) for context in contexts: try: exec("from %s.%s.context.%s import %s" % (base,site,context,context)) exec("cherrypy.root.tactic.%s.%s = %s()" % (site,context,context) ) except ImportError, e: print str(e) print "... failed to import '%s.%s.%s'" % (base, site, context) raise #return path = "/tactic/%s/%s" % (site, context) settings = {} config[path] = settings if context in ["XMLRPC", "Api"]: #settings['request.dispatch'] = cherrypy.dispatch.XMLRPCDispatcher(), settings['tools.xmlrpc.on'] = True settings['tools.xmlrpc.encoding'] = 'utf-8' settings['tools.xmlrpc.allow_none'] = True