本文整理汇总了Python中web_container.WebContainer类的典型用法代码示例。如果您正苦于以下问题:Python WebContainer类的具体用法?Python WebContainer怎么用?Python WebContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WebContainer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: execute
def execute(my):
my.buffer = cStringIO.StringIO()
try:
try:
# clear the main container for this thread
Container.create()
# clear the buffer
WebContainer.clear_buffer()
# initialize the web environment object and register it
adapter = my.get_adapter()
WebContainer.set_web(adapter)
# get the display
my._get_display()
except SetupException, e:
'''Display setup exception in the interface'''
print "Setup exception: ", e.__str__()
DbContainer.rollback_all()
ExceptionLog.log(e)
my.writeln("<h3>Tactic Setup Error</h3>" )
my.writeln("<pre>" )
my.writeln(e.__str__() )
my.writeln("</pre>" )
except DatabaseException, e:
from tactic.ui.startup import DbConfigPanelWdg
config_wdg = DbConfigPanelWdg()
my.writeln("<pre>")
my.writeln(config_wdg.get_buffer_display())
my.writeln("</pre>")
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:35,代码来源:app_server.py
示例2: _get_display
def _get_display(my):
WebContainer.set_security(FakeSecurity())
page = my.get_page_widget()
# create some singletons and store in container
cmd_delegator = WebContainer.get_cmd_delegator()
# add the event container
event_container = WebContainer.get_event_container()
from pyasm.widget import TopWdg, BottomWdg
top = TopWdg()
bottom = BottomWdg()
page = my.get_page_widget()
web = WebContainer.get_web()
from widget import Widget
widget = Widget()
widget.add(top)
widget.add(page)
# widget.add( my.get_form_wdg() )
widget.add(bottom)
# widget.add(warning_report)
widget.add(cmd_delegator)
# create a web app and run it through the pipeline
from web_app import WebApp
web_app = WebApp()
return web_app.get_display(widget)
开发者ID:hellios78,项目名称:TACTIC,代码行数:35,代码来源:simple_app_server.py
示例3: get_display
def get_display(my):
web = WebContainer.get_web()
# get the request uri
request_uri = web.get_env("REQUEST_URI")
security = WebContainer.get_security()
groups = security.get_groups()
# go through each group and find a redirect. Take the first one
for group in groups:
# find out if the person user has a redirect which confines them
# to a particular address
redirect = group.get_value("redirect_url")
# prevent mistaken infinte loops
redirect = redirect.strip()
if not redirect:
continue
if request_uri.find(redirect) == -1:
# draw the actual page
html = Html()
html.writeln('<HEAD>')
html.writeln('<META HTTP-EQUIV="Refresh" CONTENT="0; URL=%s"' % redirect)
html.writeln('</HEAD>')
return html
return None
开发者ID:0-T-0,项目名称:TACTIC,代码行数:31,代码来源:url_security.py
示例4: handle_guest_security
def handle_guest_security(self, security):
# skip storing current security since it failed
Site.set_site("default", store_security=False)
try:
WebContainer.set_security(security)
security.login_as_guest()
ticket_key = security.get_ticket_key()
web = WebContainer.get_web()
web.set_cookie("login_ticket", ticket_key)
access_manager = security.get_access_manager()
xml = Xml()
xml.read_string('''
<rules>
<rule column="login" value="{$LOGIN}" search_type="sthpw/login" access="deny" op="!=" group="search_filter"/>
</rules>
''')
access_manager.add_xml_rules(xml)
finally:
Site.pop_site(pop_security=False)
开发者ID:mincau,项目名称:TACTIC,代码行数:26,代码来源:app_server.py
示例5: handle_security
def handle_security(my, security):
# set the seucrity object
WebContainer.set_security(security)
# see if there is an override
web = WebContainer.get_web()
ticket_key = web.get_form_value("login_ticket")
# attempt to login in with a ticket
if not ticket_key:
ticket_key = web.get_cookie("login_ticket")
# We can define another place to look at ticket values and use
# that. ie: Drupal session key
session_key = Config.get_value("security", "session_key")
login = web.get_form_value("login")
password = web.get_form_value("password")
if session_key:
ticket_key = web.get_cookie(session_key)
if ticket_key:
security.login_with_session(ticket_key, add_access_rules=False)
elif login and password:
if login == "guest":
pass
else:
from pyasm.widget import WebLoginCmd
login_cmd = WebLoginCmd()
login_cmd.execute()
ticket_key = security.get_ticket_key()
# clear the password
web.set_form_value('password','')
elif ticket_key:
security.login_with_ticket(ticket_key, add_access_rules=False)
if not security.is_logged_in():
reset_password = web.get_form_value("reset_password") == 'true'
if reset_password:
from tactic.ui.widget import ResetPasswordCmd
reset_cmd = ResetPasswordCmd(reset=True)
try:
reset_cmd.execute()
except TacticException, e:
print "Reset failed. %s" %e.__str__()
else:
from pyasm.widget import WebLoginCmd
login_cmd = WebLoginCmd()
login_cmd.execute()
ticket_key = security.get_ticket_key()
开发者ID:hellios78,项目名称:TACTIC,代码行数:51,代码来源:app_server.py
示例6: _get_display
def _get_display(my):
# 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 = my.handle_security(security)
is_logged_in = security.is_logged_in()
except Exception, e:
print "AppServer Exception: ", e
return my.handle_not_logged_in()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:32,代码来源:app_server.py
示例7: get_skin
def get_skin(my):
# DEPRECATED: replaced by palettes
# TODO: prod setting shouldn't be in prod!!!
from pyasm.prod.biz import ProdSetting
web = WebContainer.get_web()
skin = web.get_form_value("skin")
# look at users preferences
if not skin:
skin = PrefSetting.get_value_by_key("skin")
# if skin isn't found in user preference settings then look for it
# in the projects/config XML file ...
if not skin:
skin = Config.get_value("look", "skin")
if not skin:
skin = "dark"
# MMS-TACTIC ... allow for 'MMS' skin to be returned for use in overriding some colors (MMS is a copy of
# 'dark' skin)
if skin == 'MMS':
return 'MMS'
return "dark"
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:26,代码来源:web_environment.py
示例8: gradient
def gradient(my, palette_key, modifier=0, range=-20, reverse=False, default=None):
if modifier == None:
modifier = 0
if range == None:
range = -20
from web_container import WebContainer
web = WebContainer.get_web()
palette = Palette.get()
if web.is_IE():
color = my.color(palette_key, (modifier+range)/2, default=default)
return color
else:
if not reverse:
color1 = my.color(palette_key, modifier, default=default)
color2 = my.color(palette_key, modifier+range, default=default)
else:
color2 = my.color(palette_key, modifier, default=default)
color1 = my.color(palette_key, modifier+range, default=default)
if web.get_browser() == 'Mozilla':
return "-moz-linear-gradient(top, %s, %s)" % (color1, color2)
else:
return "-webkit-gradient(linear, 0%% 0%%, 0%% 100%%, from(%s), to(%s))" % (color1, color2)
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:26,代码来源:palette.py
示例9: get_gradient
def get_gradient(my, palette_key, modifier=0, range=-20, reverse=False, default=None,angle=180):
from palette import Palette
from web_container import WebContainer
web = WebContainer.get_web()
palette = Palette.get()
if web.is_IE():
color = palette.color(palette_key, (modifier+range)/2, default=default)
return color
else:
if not reverse:
color1 = palette.color(palette_key, modifier, default=default)
color2 = palette.color(palette_key, modifier+range, default=default)
else:
color2 = palette.color(palette_key, modifier, default=default)
color1 = palette.color(palette_key, modifier+range, default=default)
"""
if web.get_browser() == 'Mozilla':
gradient = "-moz-linear-gradient(top, %s, %s)" % (color1, color2)
else:
gradient = "-webkit-gradient(linear, 0%% 0%%, 0%% 100%%, from(%s), to(%s))" % (color1, color2)
"""
gradient = "linear-gradient(%sdeg, %s, %s)" % (angle, color1, color2)
return gradient
开发者ID:nuxping,项目名称:TACTIC,代码行数:26,代码来源:html_wdg.py
示例10: get_content
def get_content(my, request_type):
web = WebContainer.get_web()
# NOTE: is this needed anymore?
if request_type in ["upload", "dynamic_file"]:
print "DEPRECATED: dynamic file in app_server.py"
widget = Widget()
page = my.get_page_widget()
widget.add(page)
return widget
# find hash of url
my.custom_url = None
if my.hash:
hash = "/".join(my.hash)
hash = "/%s" % hash
from tactic.ui.panel import HashPanelWdg
my.custom_url = HashPanelWdg.get_url_from_hash(hash)
if my.custom_url:
content_type = my.custom_url.get_value("content_type", no_exception=True)
# TODO: we may want to handle this differently for content types
# other that text/html
return my.get_application_wdg()
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:28,代码来源:app_server.py
示例11: start_basic_tasks
def start_basic_tasks(self, scheduler):
# close all extraneous database connections 15 minutes
class DatabaseCloseTask(SchedulerTask):
def execute(self):
#print "Closing all connections"
DbContainer.close_all_global_connections()
task = DatabaseCloseTask()
interval = 15*60
scheduler.add_interval_task(task, interval=interval, mode='threaded', delay=60)
# Kill cherrypy every interval. This overcomes some of the memory
# problems with long running Python processes. In order to
# use this properly, it is essential that a load balancer with
# proper failover is used
#
class KillTacticTask(SchedulerTask):
def execute(self):
# wait until KillThread is premitted
while GlobalContainer.get("KillThreadCmd:allow") == "false":
print "Kill locked ... waiting 5 seconds"
time.sleep(5)
continue
import cherrypy
print
print "Stopping TACTIC ..."
print
print " ... stopping Schduler"
scheduler = Scheduler.get()
scheduler.stop()
print " ... stopping Cherrypy"
cherrypy.engine.stop()
cherrypy.engine.exit()
print " ... closing DB connections"
DbContainer.close_all_global_connections()
print " ... kill current process"
Common.kill()
print "Done."
from web_container import WebContainer
if not WebContainer.is_dev_mode():
task = KillTacticTask()
config_delay = Config.get_value("services", "process_time_alive")
if config_delay:
import random
# put in a randomizer so that not all processes die at once
delay = int(config_delay)
offset = random.random()*delay - delay/2
delay += offset
seconds = int(delay * 60)
print "Process will exit in [%s] seconds" % seconds
scheduler.add_single_task(task, mode='sequential', delay=seconds)
开发者ID:mincau,项目名称:TACTIC,代码行数:59,代码来源:cache_startup.py
示例12: set_max_width
def set_max_width(my, use_css=False):
if use_css:
if WebContainer.get_web().is_IE():
my.add_style("width", "95%")
else:
my.add_style("width", "100%")
else:
# dynamic resizing doesn't work with css setting with %.
my.set_attr("width", "100%")
开发者ID:nuxping,项目名称:TACTIC,代码行数:9,代码来源:html_wdg.py
示例13: handle_guest_security
def handle_guest_security(my, security):
WebContainer.set_security(security)
security.login_as_guest()
ticket_key = security.get_ticket_key()
web = WebContainer.get_web()
web.set_cookie("login_ticket", ticket_key)
access_manager = security.get_access_manager()
xml = Xml()
xml.read_string('''
<rules>
<rule column="login" value="{$LOGIN}" search_type="sthpw/login" access="deny" op="!=" group="search_filter"/>
</rules>
''')
access_manager.add_xml_rules(xml)
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:18,代码来源:app_server.py
示例14: get_display
def get_display(my):
profile_flag = False
if profile_flag:
BaseAppServer.profile.object = my
if os.name == 'nt':
path = "C:/sthpw/profile"
else:
path = "/tmp/sthpw/temp/profile"
profile.run( "from pyasm.web.app_server import BaseAppServer; BaseAppServer.profile()", path)
p = pstats.Stats(path)
p.sort_stats('cumulative').print_stats(30)
print "*"*30
p.sort_stats('time').print_stats(30)
else:
my.execute()
value = WebContainer.get_buffer().getvalue()
WebContainer.clear_buffer()
return value
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:22,代码来源:app_server.py
示例15: handle_not_logged_in
def handle_not_logged_in(my, 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("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)
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:
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:49,代码来源:app_server.py
示例16: _get_display
def _get_display(my):
# 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()
security = Security()
try:
security = my.handle_security(security)
is_logged_in = security.is_logged_in()
except Exception, e:
site_obj = Site.get()
return my.handle_not_logged_in()
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:15,代码来源:app_server.py
示例17: set_round_corners
def set_round_corners(my, size=5, corners=[]):
browser = WebContainer.get_web().get_browser()
if browser == "Mozilla":
for corner in corners:
if corner in ["TL"]:
my.add_style("-moz-border-radius-topleft: %spx" % size)
my.add_style("border-top-left-radius: %spx" % size)
elif corner in ["TR"]:
my.add_style("-moz-border-radius-topright: %spx" % size)
my.add_style("border-top-right-radius: %spx" % size)
elif corner in ["BL"]:
my.add_style("-moz-border-radius-bottomleft: %spx" % size)
my.add_style("border-bottom-left-radius: %spx" % size)
elif corner in ["BR"]:
my.add_style("-moz-border-radius-bottomright: %spx" % size)
my.add_style("border-bottom-right-radius: %spx" % size)
if not corners:
my.add_style("-moz-border-radius: %spx" % size)
my.add_style("border-radius: %spx" % size)
elif browser in ["Webkit", "Qt"]:
for corner in corners:
if corner in ["TL"]:
my.add_style("border-top-left-radius: %spx" % size)
elif corner in ["TR"]:
my.add_style("border-top-right-radius: %spx" % size)
elif corner in ["BL"]:
my.add_style("border-bottom-left-radius: %spx" % size)
elif corner in ["BR"]:
my.add_style("border-bottom-right-radius: %spx" % size)
if not corners:
my.add_style("border-radius: %spx" % size)
elif browser == "IE":
if not corners:
corners = ["TL", "TR", "BL", "BR"]
for corner in corners:
if corner in ["TL"]:
my.add_style("border-top-left-radius: %spx" % size)
elif corner in ["TR"]:
my.add_style("border-top-right-radius: %spx" % size)
elif corner in ["BL"]:
my.add_style("border-bottom-left-radius: %spx" % size)
elif corner in ["BR"]:
my.add_style("border-bottom-right-radius: %spx" % size)
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:45,代码来源:html_wdg.py
示例18: set_round_corners
def set_round_corners(my, size=5, corners=[]):
browser = WebContainer.get_web().get_browser()
if browser == 'Mozilla':
for corner in corners:
if corner in ['TL']:
my.add_style("-moz-border-radius-topleft: %spx" % size)
my.add_style("border-top-left-radius: %spx" % size)
elif corner in ['TR']:
my.add_style("-moz-border-radius-topright: %spx" % size)
my.add_style("border-top-right-radius: %spx" % size)
elif corner in ['BL']:
my.add_style("-moz-border-radius-bottomleft: %spx" % size)
my.add_style("border-bottom-left-radius: %spx" % size)
elif corner in ['BR']:
my.add_style("-moz-border-radius-bottomright: %spx" % size)
my.add_style("border-bottom-right-radius: %spx" % size)
if not corners:
my.add_style("-moz-border-radius: %spx" % size)
my.add_style("border-radius: %spx" % size)
elif browser in ['Webkit','Qt']:
for corner in corners:
if corner in ['TL']:
my.add_style("border-top-left-radius: %spx" % size)
elif corner in ['TR']:
my.add_style("border-top-right-radius: %spx" % size)
elif corner in ['BL']:
my.add_style("border-bottom-left-radius: %spx" % size)
elif corner in ['BR']:
my.add_style("border-bottom-right-radius: %spx" % size)
if not corners:
my.add_style("border-radius: %spx" % size)
elif browser == 'IE':
if not corners:
corners = ['TL','TR','BL','BR']
for corner in corners:
if corner in ['TL']:
my.add_style("border-top-left-radius: %spx" % size)
elif corner in ['TR']:
my.add_style("border-top-right-radius: %spx" % size)
elif corner in ['BL']:
my.add_style("border-bottom-left-radius: %spx" % size)
elif corner in ['BR']:
my.add_style("border-bottom-right-radius: %spx" % size)
开发者ID:nuxping,项目名称:TACTIC,代码行数:45,代码来源:html_wdg.py
示例19: get_form_wdg
def get_form_wdg(self):
web = WebContainer.get_web()
from pyasm.web import Table
table = Table()
keys = web.get_form_keys()
keys.sort()
for key in keys:
# skipping the upload data
if not key:
continue
pat = re.compile(r'(\|files|\|images|\|snapshot|\|submission|\|publish_icon|\|publish_main)$')
if pat.search(key):
continue
table.add_row()
field = web.get_form_values(key)
table.add_cell(key)
table.add_cell(str(field))
return table
开发者ID:mincau,项目名称:TACTIC,代码行数:19,代码来源:simple_app_server.py
示例20: set_box_shadow
def set_box_shadow(my, value="0px 0px 15px", color=None):
if not color:
color = my.get_color("shadow")
if not color:
theme = my.get_theme()
if theme == "dark":
color = "#000000"
else:
color = "rgba(0,0,0,0.4)"
browser = WebContainer.get_web().get_browser()
if browser == 'Mozilla':
my.add_style("-moz-box-shadow: %s %s" % (value, color))
# This is needed for Mozilla 13
my.add_style("box-shadow: %s %s" % (value, color))
elif browser in ['Webkit', 'Qt']:
my.add_style("-webkit-box-shadow: %s %s" % (value, color))
else:
my.add_style("box-shadow: %s %s" % (value, color))
开发者ID:nuxping,项目名称:TACTIC,代码行数:20,代码来源:html_wdg.py
注:本文中的web_container.WebContainer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论