本文整理汇总了Python中pyasm.security.Site类的典型用法代码示例。如果您正苦于以下问题:Python Site类的具体用法?Python Site怎么用?Python Site使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Site类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_db_resource_by_search_type
def get_db_resource_by_search_type(cls, search_type):
if search_type.startswith('sthpw/'):
# get the local db_resource
from pyasm.security import Site
site = Site.get_site()
db_resource = None
if site:
db_resource = Site.get_db_resource(site, "sthpw")
if not db_resource:
db_resource = DbResource.get_default("sthpw")
return db_resource
project_code = cls.get_database_by_search_type(search_type)
project = Project.get_by_code(project_code)
if not project:
raise Exception("Error: Project [%s] does not exist" % project_code)
if search_type.startswith("salesforce/"):
db_resource_code = "Salesforce"
db_resource = DbResource.get_by_code(db_resource_code, project_code)
return db_resource
db_resource = project.get_project_db_resource()
return db_resource
开发者ID:mincau,项目名称:TACTIC,代码行数:28,代码来源:project.py
示例2: _do_execute
def _do_execute(my):
# restablish the site
if my.site:
Site.set_site(my.site)
Environment.set_security(my.security)
my.execute()
开发者ID:asmboom,项目名称:TACTIC,代码行数:7,代码来源:scheduler.py
示例3: execute
def execute(self):
if not self.login_name:
self.login_name = self.kwargs.get('login');
# invalidate the ticket
security = Environment.get_security()
ticket = security.get_ticket()
if ticket == None:
return
login_name = ticket.get_value("login")
print "Signing out: ", login_name
# expire the ticket
from pyasm.security import Site
site = Site.get()
if site:
Site.set_site("default")
try:
from pyasm.search import Sql, DbContainer
sql = DbContainer.get("sthpw")
ticket.set_value("expiry", sql.get_timestamp_now(), quoted=False)
ticket.commit()
except:
if site:
Site.pop_site()
开发者ID:mincau,项目名称:TACTIC,代码行数:31,代码来源:sign_out_cmd.py
示例4: error_page
def error_page(my, status, message, traceback, version):
# check if this project exists
response = cherrypy.response
request = cherrypy.request
path = request.path_info
parts = path.split("/")
if len(parts) < 3:
cherrypy.response.body = '<meta http-equiv="refresh" content="0;url=/tactic" />'
return
from pyasm.security import Site
site_obj = Site.get()
path_info = site_obj.break_up_request_path(path)
if path_info:
site = path_info['site']
project_code = path_info['project_code']
else:
project_code = parts[2]
site = ""
# sites is already mapped in config for cherrypy
if site == "plugins":
return
print "WARNING:"
print " status: ", status
print " message: ", message
print " site: ", site
print " project_code: ", project_code
# Dump out the error
has_site = False
try:
from pyasm.security import TacticInit
TacticInit()
Site.set_site(site)
if site:
eval("cherrypy.root.tactic.%s.%s" % (site, project_code))
else:
eval("cherrypy.root.tactic.%s" % project_code)
# if project_code is empty , it raises SyntaxError
except (AttributeError, SyntaxError), e:
print "WARNING: ", e
has_project = False
has_site = True
开发者ID:asmboom,项目名称:TACTIC,代码行数:52,代码来源:cherrypy30_startup.py
示例5: get_default_project
def get_default_project(cls):
from pyasm.security import Site
project = Site.get().get_default_project()
if project:
return project
project = Config.get_value("install", "default_project")
return project
开发者ID:jayvdb,项目名称:TACTIC,代码行数:7,代码来源:project.py
示例6: execute
def execute(my):
if my.mode == 'basic':
return
# cache sthpw tables definitions
from pyasm.security import Site
site = Site.get_site()
if site:
key = "%s:sthpw_column_info" % site
else:
key = "sthpw_column_info"
data = CacheContainer.get(key)
if data == None:
tables = ['project', 'search_object', 'login', 'login_group', 'login_in_group','snapshot','file','trigger','notification','ticket']
kwargs = {
"key": key,
"database": 'sthpw',
"tables": tables,
}
cache = TableInfoCache( **kwargs )
# cache search object table
search_type_cache = SearchTypeCache.get("sthpw/search_object")
search_type_cache.build_cache_by_column("search_type")
# cache login table
search_type_cache = SearchTypeCache.get("sthpw/login")
search_type_cache.build_cache_by_column("login")
# cache login_group table
search_type_cache = SearchTypeCache.get("sthpw/login_group")
search_type_cache.build_cache_by_column("login_group")
开发者ID:0-T-0,项目名称:TACTIC,代码行数:35,代码来源:cache_startup.py
示例7: get_site_root
def get_site_root(self):
from pyasm.security import Site
site = Site.get().get_site_root()
if site:
return site
return "tactic"
开发者ID:mincau,项目名称:TACTIC,代码行数:7,代码来源:web_environment.py
示例8: get_asset_dir
def get_asset_dir(cls, file_object=None, alias=None):
'''get base asset directory'''
if file_object:
alias = file_object.get_value('base_dir_alias')
if not alias:
alias = "default"
from pyasm.security import Site
asset_dir = Site.get().get_asset_dir(file_object=file_object,alias=alias)
if asset_dir:
return asset_dir
alias_dict = cls.get_asset_dirs()
asset_dir = alias_dict.get(alias)
if not asset_dir:
data_dir = Environment.get_data_dir()
if data_dir:
asset_dir = "%s/assets" % data_dir
return asset_dir
开发者ID:mincau,项目名称:TACTIC,代码行数:26,代码来源:environment.py
示例9: get_db_triggers
def get_db_triggers(cls):
site_triggers = Container.get(cls.KEY)
if site_triggers == None:
# find all of the triggers
search = Search("sthpw/trigger")
search.add_project_filter()
site_triggers = search.get_sobjects()
Container.put(cls.KEY, site_triggers)
# find all of the project triggers
from pyasm.biz import Project
site = Site.get_site()
project_code = Project.get_project_code()
key = "%s:%s:%s" % (cls.KEY, project_code, site)
project_triggers = Container.get(key)
if project_triggers == None:
if project_code not in ['admin','sthpw']:
try:
search = Search("config/trigger")
project_triggers = search.get_sobjects()
except SearchException as e:
print("WARNING: ", e)
project_triggers = []
else:
project_triggers = []
Container.put(key, project_triggers)
triggers = []
triggers.extend(site_triggers)
triggers.extend(project_triggers)
return triggers
开发者ID:mincau,项目名称:TACTIC,代码行数:32,代码来源:trigger.py
示例10: set_project
def set_project(cls, project_code):
'''This is kept here because everybody is used to using this'''
security = Environment.get_security()
# FIXME:
# Because it is possible to call this before one is
# logged in. This is required to see the login screen.
from pyasm.security import get_security_version
security_version = get_security_version()
if security_version != 1 and not project_code == 'admin':
key = { 'code': project_code }
key2 = { 'code': "*" }
keys = [key, key2]
if not security.check_access("project", keys, access="allow", default="deny"):
user = Environment.get_login()
if user:
user = user.get_value("login")
raise SecurityException("User [%s] is not permitted to view project [%s]" % (user, project_code))
else:
raise SecurityException("User is not permitted to view project [%s]" % (project_code))
from pyasm.security import Site
site = Site.get_site()
PROJECT_KEY = "Project:global:%s:" % site
Container.put(PROJECT_KEY, project_code)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:25,代码来源:project.py
示例11: get_display
def get_display(self):
web = WebContainer.get_web()
response = web.get_response()
# get info from url
site_obj = Site.get()
path = web.get_request_path()
path_info = site_obj.break_up_request_path(path)
site = path_info.get("site")
project_code = path_info.get("project_code")
# find the relative path
hash = self.kwargs.get("hash")
parts = hash[1:]
rel_path = "/".join(parts)
#rel_path = "asset/Fantasy/Castle/54d45150c61251f65687d716cc3951f1_v001.jpg"
# construct all of the paths
asset_dir = web.get_asset_dir()
base_dir = "%s/%s" % (asset_dir, project_code)
path = "%s/%s" % (base_dir, rel_path)
filename = os.path.basename(rel_path)
print "path: ", path
# determine the mimetype automatically
import mimetypes
base, ext = os.path.splitext(path)
ext = ext.lower()
mimetype = mimetypes.types_map[ext]
headers = response.headers
response.headers['Content-Type'] = mimetype
response.headers['Content-Disposition'] = 'inline; filename={0}'.format(filename)
use_xsendfile = True
if use_xsendfile:
response.headers['X-Sendfile'] = path
return Widget(path)
else:
response.headers['Content-Transfer-Encoding'] = 'BINARY'
widget = Widget()
f = open(path, 'rb')
data = f.read()
f.close()
widget.add(data)
return widget
开发者ID:mincau,项目名称:TACTIC,代码行数:58,代码来源:top_wdg.py
示例12: clear_db_cache
def clear_db_cache(cls):
Container.put(cls.KEY, None)
site = Site.get_site()
from pyasm.biz import Project
project_code = Project.get_project_code()
key = "%s:%s:%s" % (cls.KEY, project_code, site)
Container.put(key, None)
开发者ID:mincau,项目名称:TACTIC,代码行数:9,代码来源:trigger.py
示例13: get_global_project_code
def get_global_project_code(cls):
from pyasm.security import Site
site = Site.get_site()
PROJECT_KEY = "Project:global:%s:" % site
project_code = Container.get(PROJECT_KEY)
if not project_code:
project_code = "admin"
Project.set_global_project_code(project_code)
return project_code
开发者ID:0-T-0,项目名称:TACTIC,代码行数:9,代码来源:project.py
示例14: get_display
def get_display(my):
top = DivWdg()
hash = my.kwargs.get("hash")
Container.put("url_hash", hash)
security = Environment.get_security()
is_admin = security.check_access("builtin", "view_site_admin", "allow")
if hash == "/admin" and not is_admin:
hash = "/index"
if not hash:
# NOTE: this really doesn't get call anymore because an empty
# hash gets remapped to "/index"
widget = my.get_default_wdg()
top.add(widget)
# This would provide a way to get the default index widget.
#elif hash == "/projects":
# widget = my.get_default_wdg()
# from tactic_sites.default.modules import IndexWdg
# top.add( IndexWdg() )
else:
from tactic.ui.panel import HashPanelWdg
project_code = Project.get_project_code()
if project_code == 'admin' and hash == '/index':
widget = my.get_default_wdg()
else:
print "HASH: ", hash
print "project: ", project_code
from pyasm.security import Site
print "site: ", Site.get_site()
widget = HashPanelWdg.get_widget_from_hash(hash, return_none=True)
if not widget:
if hash == "/index":
widget = my.get_default_wdg()
elif hash == '/admin':
widget = my.get_default_wdg()
else:
widget = HashPanelWdg.get_widget_from_hash("/index", return_none=True)
top.add(widget)
return top
开发者ID:asmboom,项目名称:TACTIC,代码行数:50,代码来源:top_container_wdg.py
示例15: __init__
def __init__(my, **kwargs):
my.kwargs = kwargs
user = my.kwargs.get('user')
project = my.kwargs.get('project')
my.site = my.kwargs.get('site')
if not my.site:
# if not explicitly set, keep the site that is current
my.site = Site.get_site()
if user and project:
from pyasm.security import Batch
Batch(site=my.site, login_code=user, project_code=project)
my.security = Environment.get_security()
开发者ID:asmboom,项目名称:TACTIC,代码行数:15,代码来源:scheduler.py
示例16: index
def index(my):
# check if this project exists
response = cherrypy.response
request = cherrypy.request
path = request.path_info
from pyasm.security import Site
default_project = Site.get().get_default_project()
if not default_project:
default_project = "admin"
path = path.rstrip("/")
path = "%s/%s" % (path, default_project)
return '''<META http-equiv="refresh" content="0;URL=%s">''' % path
开发者ID:asmboom,项目名称:TACTIC,代码行数:15,代码来源:cherrypy30_startup.py
示例17: get_context_name
def get_context_name(my):
'''this includes all of the subdirectories as well as the main
context'''
path = my.get_request_path()
p = re.compile( r"/(tactic|projects)/?(\w+)/")
m = p.search(path)
if not m:
return "default"
from pyasm.security import Site
site_obj = Site.get()
path_info = site_obj.break_up_request_path(path)
if path_info:
context = path_info.get("project_code")
else:
context = m.groups()[1]
return context
开发者ID:asmboom,项目名称:TACTIC,代码行数:18,代码来源:cherrypy30_adapter.py
示例18: get_web_dir
def get_web_dir(cls, file_object=None, alias=None):
'''get base web directory'''
if file_object:
alias = file_object.get_value('base_dir_alias')
if not alias:
alias = "default"
from pyasm.security import Site
site = Site.get()
web_dir = site.get_web_dir(file_object=file_object,alias=alias)
if web_dir:
return web_dir
alias_dict = cls.get_web_dirs()
web_dir = alias_dict.get(alias)
if not web_dir:
web_dir = "/assets"
return web_dir
开发者ID:mincau,项目名称:TACTIC,代码行数:23,代码来源:environment.py
示例19: get_by_key
def get_by_key(cls, key, search_type=None):
from pyasm.security import Site
site = Site.get_site()
Site.set_site( Site.get_first_site() )
project = Project.get_project_code()
dict_key = '%s:%s' %(key, search_type)
search = Search(cls.SEARCH_TYPE, project_code=project)
search.add_filter("key", key)
if search_type:
search.add_filter("search_type", search_type)
if Project.get_project_name() in ['admin', 'sthpw']:
return None
prod_setting = ProdSetting.get_by_search(search, dict_key)
Site.pop_site()
return prod_setting
开发者ID:jayvdb,项目名称:TACTIC,代码行数:20,代码来源:prod_setting.py
示例20: get_display
def get_display(my):
web = WebContainer.get_web()
widget = Widget()
html = HtmlElement("html")
is_xhtml = False
if is_xhtml:
web.set_content_type("application/xhtml+xml")
widget.add('''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
''')
html.add_attr("xmlns", "http://www.w3.org/1999/xhtml")
#html.add_attr("xmlns:svg", "http://www.w3.org/2000/svg")
# add the copyright
widget.add( my.get_copyright_wdg() )
widget.add(html)
# create the header
head = HtmlElement("head")
html.add(head)
head.add('<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>\n')
head.add('<meta http-equiv="X-UA-Compatible" content="IE=edge"/>\n')
# Add the tactic favicon
head.add('<link rel="shortcut icon" href="/context/favicon.ico" type="image/x-icon"/>')
# add the css styling
head.add(my.get_css_wdg())
# add the title in the header
project = Project.get()
project_code = project.get_code()
project_title = project.get_value("title")
if web.is_admin_page():
is_admin = " - Admin"
else:
is_admin = ""
if project_code == 'admin':
head.add("<title>TACTIC Site Admin</title>\n" )
else:
head.add("<title>%s%s</title>\n" % (project_title, is_admin) )
# add the javascript libraries
head.add( JavascriptImportWdg() )
# add the body
body = my.body
html.add( body )
body.add_event('onload', 'spt.onload_startup(this)')
top = my.top
# Add a NOSCRIPT tag block here to provide a warning message on browsers where 'Enable JavaScript'
# is not checked ... TODO: clean up and re-style to make look nicer
top.add( """
<NOSCRIPT>
<div style="border: 2px solid black; background-color: #FFFF99; color: black; width: 600px; height: 70px; padding: 20px;">
<img src="%s" style="border: none;" /> <b>Javascript is not enabled on your browser!</b>
<p>This TACTIC powered, web-based application requires JavaScript to be enabled in order to function. In your browser's options/preferences, please make sure that the 'Enable JavaScript' option is checked on, click OK to accept the settings change, and then refresh this web page.</p>
</div>
</NOSCRIPT>
""" % ( IconWdg.get_icon_path("ERROR") ) )
# add the content
content_div = DivWdg()
top.add(content_div)
Container.put("TopWdg::content", content_div)
# add a dummy button for global behaviors
from tactic.ui.widget import ButtonNewWdg, IconButtonWdg
ButtonNewWdg(title="DUMMY", icon=IconWdg.FILM)
IconButtonWdg(title="DUMMY", icon=IconWdg.FILM)
# NOTE: it does not need to be in the DOM. Just needs to be
# instantiated
#content_div.add(button)
if my.widgets:
content_wdg = my.get_widget('content')
else:
content_wdg = Widget()
#.........这里部分代码省略.........
开发者ID:asmboom,项目名称:TACTIC,代码行数:101,代码来源:top_wdg.py
注:本文中的pyasm.security.Site类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论