本文整理汇总了Python中web_container.WebContainer.get_buffer方法的典型用法代码示例。如果您正苦于以下问题:Python WebContainer.get_buffer方法的具体用法?Python WebContainer.get_buffer怎么用?Python WebContainer.get_buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类web_container.WebContainer
的用法示例。
在下文中一共展示了WebContainer.get_buffer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from web_container import WebContainer [as 别名]
# 或者: from web_container.WebContainer import get_buffer [as 别名]
def execute(my):
my.buffer = cStringIO.StringIO()
try:
# clear the main containers
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()
finally:
WebContainer.get_buffer().write(my.buffer.getvalue())
示例2: get_display
# 需要导入模块: from web_container import WebContainer [as 别名]
# 或者: from web_container.WebContainer import get_buffer [as 别名]
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
示例3: get_display
# 需要导入模块: from web_container import WebContainer [as 别名]
# 或者: from web_container.WebContainer import get_buffer [as 别名]
def get_display(my):
'''override the get display function of Widget. This is the function
that actually draws the html element to the buffer'''
html = WebContainer.get_buffer()
buffer = html.get_buffer()
buffer.write("<%s" % my.type)
attrs = []
if my.attrs:
for x,y in my.attrs.items():
if type(x) == types.UnicodeType:
x = Common.process_unicode_string(x)
if type(y) == types.UnicodeType:
y = Common.process_unicode_string(y)
attrs.append( ' %s="%s"' % (x,y) )
attr = " ".join( attrs )
"""
attr = " ".join( [' %s="%s"' % (x,y) for x,y in my.attrs.items()] )
if type(attr) == types.UnicodeType:
attr = Common.process_unicode_string(attr)
"""
buffer.write(attr)
attr = None
# now process behaviors and, if there are any, construct the SPT_BVR_LIST attribute and write it out.
# also add the SPT_BVR class to the element if it does have behaviors.
if my.behaviors:
my.add_class('SPT_BVR')
bvr_str_list = [ ' SPT_BVR_LIST="[' ]
bvr_type_list = [ ' SPT_BVR_TYPE_LIST="[' ]
#for c in range(len(my.behaviors)):
for c, behavior in enumerate(my.behaviors):
if c:
bvr_str_list.append(',')
bvr_type_list.append(',')
bvr_spec_str = HtmlElement.get_json_string(behavior)
# NOTE: this is to make the HTML be XML compliant
#bvr_spec_str = bvr_spec_str.replace("<", "<")
#bvr_spec_str = bvr_spec_str.replace(">", ">")
#bvr_spec_str = bvr_spec_str.replace("&", "&")
bvr_str_list.append( bvr_spec_str )
bvr_info = {
'type': behavior.get("type"),
}
if behavior.get("_handoff_"):
bvr_info['_handoff_'] = behavior.get("_handoff_")
bvr_info_str = HtmlElement.get_json_string(bvr_info)
bvr_type_list.append( bvr_info_str )
bvr_str_list.append( ']"' )
bvr_type_list.append( ']"' )
buffer.write( "".join( bvr_str_list ) )
buffer.write( "".join( bvr_type_list ) )
bvr_str_list = None
bvr_type_list = None
# handle the style
if my.styles:
styles = []
for name, value in my.styles.items():
styles.append( "%s: %s" % (name,value) )
buffer.write( " style='%s'" % ";".join(styles) )
styles = None
# handle relay styles
if my.relay_styles:
for relay_style in my.relay_styles:
my.add(relay_style)
# handle the class
if my.classes:
classes = my.classes.keys()
buffer.write(" class='%s'" % " ".join(classes))
classes = None
# handle events
if my.events:
for key in my.events.keys():
functions = my.events.get(key)
function = "javascript:%s" % ";".join(functions)
buffer.write( ' %s="%s"' % (key,function) )
functions = None
self_close = False
if my.type in ["img", "br"] or (my.type == "input" and not my.widgets):
self_close = True
else:
buffer.write(">")
super(HtmlElement,my).get_display()
#.........这里部分代码省略.........
示例4: handle_not_logged_in
# 需要导入模块: from web_container import WebContainer [as 别名]
# 或者: from web_container.WebContainer import get_buffer [as 别名]
return
my.writeln("<pre>")
my.writeln("An Error has occurred. Please see your Tactic Administrator<br/>")
my.writeln( "Error Message: %s" % log.get_value("message") )
my.writeln("Error Id: %s" % log.get_id() )
my.writeln( log.get_value("stack_trace") )
my.writeln("</pre>")
finally:
# ensure that database connections are always closed
DbContainer.close_all()
# clear the container
Container.delete()
WebContainer.get_buffer().write( my.buffer.getvalue() )
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
示例5: execute
# 需要导入模块: from web_container import WebContainer [as 别名]
# 或者: from web_container.WebContainer import get_buffer [as 别名]
def execute(self):
self.buffer = cStringIO.StringIO()
error = None
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 = self.get_adapter()
WebContainer.set_web(adapter)
# get the display
self._get_display()
except SetupException as e:
'''Display setup exception in the interface'''
print("Setup exception: ", e.__str__())
DbContainer.rollback_all()
ExceptionLog.log(e)
self.writeln("<h3>Tactic Setup Error</h3>" )
self.writeln("<pre>" )
self.writeln(e.__str__() )
self.writeln("</pre>" )
error = "405: TACTIC Setup Error"
except DatabaseException as e:
from tactic.ui.startup import DbConfigPanelWdg
config_wdg = DbConfigPanelWdg()
self.writeln("<pre>")
self.writeln(config_wdg.get_buffer_display())
self.writeln("</pre>")
error = "405: TACTIC Database Error"
except Exception as e:
stack_trace = ExceptionLog.get_stack_trace(e)
#print(stack_trace)
self.writeln("<pre>")
self.writeln(stack_trace)
self.writeln("</pre>")
error = "405 %s" % str(e)
# it is possible that the security object was not set
security = Environment.get_security()
if not security:
security = Security()
WebContainer.set_security(security)
log = None
# ensure that database connections are rolled back
try:
DbContainer.rollback_all()
except Exception as e2:
print("Error: Could not rollback: ", e2.__str__())
self.writeln("Error: Could not rollback: '%s'" % e2.__str__() )
stack_trace = ExceptionLog.get_stack_trace(e2)
print(stack_trace)
self.writeln("<pre>")
self.writeln(stack_trace)
self.writeln("</pre>")
raise e
#return
try:
# WARNING: if this call causes an exception, the error
# will be obscure
log = ExceptionLog.log(e)
except Exception as e2:
print("Error: Could not log exception: ", e2.__str__())
self.writeln("Error '%s': Could not log exception" % e2.__str__() )
stack_trace = ExceptionLog.get_stack_trace(e2)
print(stack_trace)
self.writeln("<pre>")
self.writeln(stack_trace)
self.writeln("</pre>")
return
self.writeln("<pre>")
self.writeln("An Error has occurred. Please see your Tactic Administrator<br/>")
self.writeln( "Error Message: %s" % log.get_value("message") )
self.writeln("Error Id: %s" % log.get_id() )
#self.writeln( log.get_value("stack_trace") )
self.writeln("</pre>")
finally:
# ensure that database connections are always closed
DbContainer.close_all()
# clear the container
Container.delete()
WebContainer.get_buffer().write( self.buffer.getvalue() )
#.........这里部分代码省略.........