当前位置: 首页>>代码示例>>Python>>正文


Python Environment.get_site_dir方法代码示例

本文整理汇总了Python中pyasm.common.Environment.get_site_dir方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.get_site_dir方法的具体用法?Python Environment.get_site_dir怎么用?Python Environment.get_site_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasm.common.Environment的用法示例。


在下文中一共展示了Environment.get_site_dir方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_site_dir [as 别名]
    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()
开发者ID:mincau,项目名称:TACTIC,代码行数:57,代码来源:batch.py

示例2: __init__

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_site_dir [as 别名]
    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()
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:47,代码来源:batch.py

示例3: in

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_site_dir [as 别名]

        # 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
开发者ID:asmboom,项目名称:TACTIC,代码行数:32,代码来源:cherrypy30_startup.py

示例4: register_project

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_site_dir [as 别名]
    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
开发者ID:0-T-0,项目名称:TACTIC,代码行数:84,代码来源:cherrypy_startup.py

示例5: setup_sites

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_site_dir [as 别名]
    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
开发者ID:0-T-0,项目名称:TACTIC,代码行数:88,代码来源:cherrypy_startup.py

示例6: register_site

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_site_dir [as 别名]
    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 
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:88,代码来源:cherrypy30_startup.py


注:本文中的pyasm.common.Environment.get_site_dir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。