本文整理汇总了Python中pyasm.biz.Project.get_default_project方法的典型用法代码示例。如果您正苦于以下问题:Python Project.get_default_project方法的具体用法?Python Project.get_default_project怎么用?Python Project.get_default_project使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.biz.Project
的用法示例。
在下文中一共展示了Project.get_default_project方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_templates
# 需要导入模块: from pyasm.biz import Project [as 别名]
# 或者: from pyasm.biz.Project import get_default_project [as 别名]
def set_templates(self):
project_code = WebContainer.get_web().get_full_context_name()
if project_code == "default":
project_code = Project.get_default_project()
try:
SearchType.set_global_template("project", project_code)
except SecurityException as e:
print("WARNING: ", e)
示例2: set_templates
# 需要导入模块: from pyasm.biz import Project [as 别名]
# 或者: from pyasm.biz.Project import get_default_project [as 别名]
def set_templates(my):
#if my.project_code:
# project_code = my.project_code
#else:
# project_code = WebContainer.get_web().get_full_context_name()
project_code = WebContainer.get_web().get_full_context_name()
if project_code == "default":
project_code = Project.get_default_project()
#if not project_code:
# project_code = my.project_code
try:
SearchType.set_global_template("project", project_code)
except SecurityException, e:
print "WARNING: ", e
示例3: setup_sites
# 需要导入模块: from pyasm.biz import Project [as 别名]
# 或者: from pyasm.biz.Project import get_default_project [as 别名]
#.........这里部分代码省略.........
'tools.decode.encoding': 'utf-8',
#'encoding_filter.on': True,
#'decoding_filter.on': True
'tools.CORS.on': True
},
'/context': {'tools.staticdir.on': True,
'tools.staticdir.dir': context_path,
# Need to do this because on windows servers, jar files
# are served as text/html
'tools.staticdir.content_types': {
'jar': 'application/java-archive'
}
},
'/assets': {'tools.staticdir.on': True,
'tools.staticdir.dir': Environment.get_asset_dir()
},
'/doc': {'tools.staticdir.on': True,
'tools.staticdir.dir': doc_dir,
'tools.staticdir.index': "index.html"
},
# NOTE: expose the entire plugins directory
'/tactic/plugins': {
'tools.staticdir.on': True,
'tools.staticdir.dir': plugin_dir,
},
'/tactic/builtin_plugins': {
'tools.staticdir.on': True,
'tools.staticdir.dir': builtin_plugin_dir,
},
'/tactic/dist': {
'tools.staticdir.on': True,
'tools.staticdir.dir': dist_dir,
},
'/plugins': {
'tools.staticdir.on': True,
'tools.staticdir.dir': plugin_dir,
},
'/builtin_plugins': {
'tools.staticdir.on': True,
'tools.staticdir.dir': builtin_plugin_dir,
},
'/dist': {
'tools.staticdir.on': True,
'tools.staticdir.dir': dist_dir,
},
}
# set up the root directory
cherrypy.root = Root()
cherrypy.tree.mount( cherrypy.root, config=config)
from pyasm.search import Search
search = Search("sthpw/project")
search.add_filter("type", "resource", op="!=")
projects = search.get_sobjects()
# find out if one of the projects is the root
root_initialized = False
if not root_initialized:
project_code = Project.get_default_project()
if project_code and project_code !='default':
from tactic.ui.app import SitePage
cherrypy.root.tactic = SitePage(project_code)
cherrypy.root.projects = SitePage(project_code)
root_initialized = True
if not root_initialized:
# load in the base site at root
from tactic_sites.default.context.Index import Index
cherrypy.root.tactic = Index()
cherrypy.root.projects = Index()
for project in projects:
project_code = project.get_code()
my.register_project(project_code, config)
my.register_project("default", config)
print
from pyasm.security import Site
site_obj = Site.get()
site_obj.register_sites(my, config)
#my.register_project("vfx", config, site="vfx_demo")
#my.register_project("default", config, site="vfx_demo")
return config
示例4: Sudo
# 需要导入模块: from pyasm.biz import Project [as 别名]
# 或者: from pyasm.biz.Project import get_default_project [as 别名]
sudo = Sudo()
try:
# get the project from the url because we are still
# in the admin project at this stage
current_project = web.get_context_name()
try:
if current_project != "default":
project = Project.get_by_code(current_project)
assert project
except Exception, e:
web_wdg = None
else:
# custom login widget
if not current_project or current_project == "default":
current_project = Project.get_default_project()
if current_project and current_project != "default":
Project.set_project(current_project)
try:
web_wdg = HashPanelWdg.get_widget_from_hash("/login", return_none=True)
except Exception, e:
print "WARNING: ", e
raise
from pyasm.widget import ExceptionMinimalWdg
web_wdg = ExceptionMinimalWdg(e)
web_wdg.add_style("margin: 50px auto")
if web_wdg:
web_wdg = web_wdg.get_buffer_display()
示例5: setup_sites
# 需要导入模块: from pyasm.biz import Project [as 别名]
# 或者: from pyasm.biz.Project import get_default_project [as 别名]
def setup_sites(my):
context_path = "%s/src/context" % my.install_dir
doc_dir = "%s/doc" % my.install_dir
plugin_dir = Environment.get_plugin_dir()
builtin_plugin_dir = Environment.get_builtin_plugin_dir()
dist_dir = Environment.get_dist_dir()
log_dir = "%s/log" % Environment.get_tmp_dir()
config = {
'global': {
'server.socket_host': '127.0.0.1',
'server.socket_port': 80,
'log.screen': False,
'request.show_tracebacks': True,
'tools.log_headers.on': True,
'server.log_file': "%s/tactic_log" % log_dir,
'server.max_request_body_size': 0,
#'server.socket_timeout': 60,
'response.timeout': 3600,
'tools.encode.on': True,
'tools.encode.encoding': 'utf-8',
'tools.decode.on': True,
'tools.decode.encoding': 'utf-8',
#'encoding_filter.on': True,
#'decoding_filter.on': True
}
,
'/context': {'tools.staticdir.on': True,
'tools.staticdir.dir': context_path,
# Need to do this because on windows servers, jar files
# are served as text/html
'tools.staticdir.content_types': {
'jar': 'application/java-archive'
}
},
'/assets': {'tools.staticdir.on': True,
'tools.staticdir.dir': Environment.get_asset_dir()
},
'/doc': {'tools.staticdir.on': True,
'tools.staticdir.dir': doc_dir,
'tools.staticdir.index': "index.html"
},
# NOTE: expose the entire plugins directory
'/tactic/plugins': {
'tools.staticdir.on': True,
'tools.staticdir.dir': plugin_dir,
},
'/tactic/builtin_plugins': {
'tools.staticdir.on': True,
'tools.staticdir.dir': builtin_plugin_dir,
},
'/tactic/dist': {
'tools.staticdir.on': True,
'tools.staticdir.dir': dist_dir,
}
}
# set up the root directory
cherrypy.root = Root()
cherrypy.tree.mount( cherrypy.root, config=config)
from pyasm.search import Search
search = Search("sthpw/project")
search.add_filter("type", "resource", op="!=")
projects = search.get_sobjects()
# find out if one of the projects is the root
root_initialized = False
"""
for project in projects:
project_code = project.get_code()
if False:
from tactic.ui.app import SitePage
cherrypy.root.tactic = SitePage(project_code)
cherrypy.root.projects = SitePage(project_code)
root_initialized = True
break
"""
if not root_initialized:
project_code = Project.get_default_project()
if project_code and project_code !='default':
from tactic.ui.app import SitePage
cherrypy.root.tactic = SitePage(project_code)
cherrypy.root.projects = SitePage(project_code)
root_initialized = True
if not root_initialized:
#.........这里部分代码省略.........
示例6: _get_display
# 需要导入模块: from pyasm.biz import Project [as 别名]
# 或者: from pyasm.biz.Project import get_default_project [as 别名]
def _get_display(self):
# set up the security object
from pyasm.security import Security, Sudo
from pyasm.biz import Project
from pyasm.web import WebContainer
web = WebContainer.get_web()
# guest mode
#
allow_guest = Config.get_value("security", "allow_guest")
if allow_guest == 'true':
allow_guest = True
else:
allow_guest = False
site_obj = Site.get()
site_allow_guest = site_obj.allow_guest()
if site_allow_guest != None:
allow_guest = site_allow_guest
security = Security()
try:
security = self.handle_security(security)
is_logged_in = security.is_logged_in()
except Exception as e:
print("AppServer Exception: ", e)
return self.handle_not_logged_in()
guest_mode = Config.get_value("security", "guest_mode")
if not guest_mode:
guest_mode = 'restricted'
# Test
#allow_guest = True
#guest_mode = "full"
# if not logged in, then log in as guest
if not is_logged_in:
if not allow_guest:
return self.handle_not_logged_in()
else:
# login as guest
security = Security()
self.handle_guest_security(security)
# for here on, the user is logged in
login_name = Environment.get_user_name()
is_upload = '/UploadServer' in web.get_request_url().to_string()
# check if the user has permission to see this project
project = web.get_context_name()
if project == 'default':
override_default = Project.get_default_project()
if override_default:
project = override_default
if is_upload:
print("IS UPLOAD")
access = True
elif project != 'default':
# make sure the security check is done on the appropriate site
path_info = site_obj.get_request_path_info()
if path_info:
site = path_info.get("site")
Site.set_site(site)
s = Environment.get_security()
has_site = True
else:
s = security
has_site = False
try:
security_version = get_security_version()
if security_version == 1:
default = "view"
access = s.check_access("project", project, "view", default="view")
else:
default = "deny"
key = { "code": project }
key2 = { "code": "*" }
keys = [key, key2]
access = s.check_access("project", keys, "allow", default=default)
finally:
if has_site:
Site.pop_site()
else:
# you always have access to the default project
access = True
#.........这里部分代码省略.........
示例7: handle_not_logged_in
# 需要导入模块: from pyasm.biz import Project [as 别名]
# 或者: from pyasm.biz.Project import get_default_project [as 别名]
def handle_not_logged_in(self, allow_change_admin=True):
site_obj = Site.get()
site_obj.set_site("default")
DbResource.clear_cache()
from pyasm.widget import WebLoginWdg, BottomWdg
from tactic.ui.app import TitleTopWdg
from pyasm.biz import Project
from tactic.ui.panel import HashPanelWdg
web = WebContainer.get_web()
widget = Widget()
top = TitleTopWdg()
widget.add(top)
body = top.get_body()
#body.add_gradient("background", "background", 5, -20)
body.add_color("background", "background")
body.add_color("color", "color")
reset_request = web.get_form_value('reset_request') =='true'
if reset_request:
from tactic.ui.widget import ResetPasswordWdg
top.add(ResetPasswordWdg())
else:
reset_msg = web.get_form_value('reset_msg')
if reset_msg:
web.set_form_value(WebLoginWdg.LOGIN_MSG, reset_msg)
web_wdg = None
sudo = Sudo()
try:
# get the project from the url because we are still
# in the admin project at this stage
current_project = web.get_context_name()
try:
if current_project != "default":
project = Project.get_by_code(current_project)
assert project
except Exception as e:
pass
else:
# custom global site login widget
if not current_project or current_project == "default":
current_project = Project.get_default_project()
if current_project and current_project != "default":
try:
Project.set_project(current_project)
except SecurityException as e:
print(e)
if 'is not permitted to view project' not in e.__str__():
raise
if not web_wdg:
web_wdg = site_obj.get_login_wdg()
if web_wdg:
if not isinstance(web_wdg, basestring):
web_wdg = web_wdg.get_buffer_display()
top.add(web_wdg)
else:
web_wdg = None
# display default web login
if not web_wdg:
# get login screen from Site
link = "/%s" % "/".join(self.hash)
web_wdg = site_obj.get_login_wdg(link)
if not web_wdg:
# else get the default one
web_wdg = WebLoginWdg(allow_change_admin=allow_change_admin)
top.add(web_wdg)
finally:
# sudo out of scope here
sudo.exit()
pass
# create a web app and run it through the pipeline
web_app = WebApp()
web_app.get_display(widget)
return