本文整理汇总了Python中pyasm.biz.Schema.get_admin_schema方法的典型用法代码示例。如果您正苦于以下问题:Python Schema.get_admin_schema方法的具体用法?Python Schema.get_admin_schema怎么用?Python Schema.get_admin_schema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.biz.Schema
的用法示例。
在下文中一共展示了Schema.get_admin_schema方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_predefined_url
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get_admin_schema [as 别名]
def _get_predefined_url(cls, key, hash):
# make some predefined fake urls
if key in ["link", "tab", "admin"]:
# this is called by PageNav
if key == "admin":
expression = "/admin/link/{link}"
else:
expression = "/%s/{link}" % key
options = Common.extract_dict(hash, expression)
link = options.get("link")
if not link:
return None
# test link security
project_code = Project.get_project_code()
security = Environment.get_security()
keys = [
{ "element": link },
{ "element": "*" },
{ "element": link, "project": project_code },
{ "element": "*", "project": project_code }
]
if not security.check_access("link", keys, "allow", default="deny"):
return None
from tactic.ui.panel import SideBarBookmarkMenuWdg
personal = False
if '.' in link:
personal = True
config = SideBarBookmarkMenuWdg.get_config("SideBarWdg", link, personal=personal)
options = config.get_display_options(link)
if not options:
from pyasm.biz import Schema
config_xml = []
config_xml.append( '''
<config>
''')
config_schema = Schema.get_predefined_schema('config')
SideBarBookmarkMenuWdg.get_schema_snippet("_config_schema", config_schema, config_xml)
schema = Schema.get_admin_schema()
SideBarBookmarkMenuWdg.get_schema_snippet("_admin_schema", schema, config_xml)
config_xml.append( '''
</config>
''')
xml = "".join(config_xml)
from pyasm.widget import WidgetConfig
schema_config = WidgetConfig.get(view="_admin_schema", xml=xml)
options = schema_config.get_display_options(link)
if not options:
schema_config.set_view("_config_schema")
options = schema_config.get_display_options(link)
if not options:
return None
class_name = options.get("class_name")
widget_key = options.get("widget_key")
if widget_key:
class_name = WidgetClassHandler().get_display_handler(widget_key)
elif not class_name:
class_name = 'tactic.ui.panel.ViewPanelWdg'
if key in ["admin", "tab"]:
use_index = "false"
else:
use_index = "true"
if key in ['admin']:
use_admin = "true"
else:
use_admin = "false"
xml = []
xml.append('''<element admin="%s" index="%s">''' % (use_admin, use_index))
xml.append(''' <display class="%s">''' % class_name)
for name, value in options.items():
xml.append("<%s>%s</%s>" % (name, value, name) )
xml.append(''' </display>''')
xml.append('''</element>''')
xml = "\n".join(xml)
sobject = SearchType.create("config/url")
#.........这里部分代码省略.........
示例2: _get_predefined_url
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get_admin_schema [as 别名]
def _get_predefined_url(cls, key, hash):
# only allow people with site admin
security = Environment.get_security()
is_admin = security.is_admin()
if not is_admin and key == "admin":
return None
# make some predefined fake urls
if key in ["link", "tab", "admin"]:
# this is called by PageNav
if key == "admin":
expression = "/admin/link/{link}"
else:
expression = "/%s/{link}" % key
options = Common.extract_dict(hash, expression)
link = options.get("link")
if not link:
return None
from tactic.ui.panel import SideBarBookmarkMenuWdg
personal = False
if '.' in link:
# put in a check to ensure this is a user
parts = link.split(".")
user = Environment.get_user_name()
def is_personal(user, parts):
'''See if parts contains period
seperated form of username.'''
acc = ""
for part in parts:
if acc == "":
acc = part
else:
acc = "%s.%s" % (acc, part)
if user == acc:
return True
return False
personal = is_personal(user, parts)
# test link security
project_code = Project.get_project_code()
security = Environment.get_security()
keys = [
{ "element": link },
{ "element": "*" },
{ "element": link, "project": project_code },
{ "element": "*", "project": project_code }
]
if not personal and not security.check_access("link", keys, "allow", default="deny"):
print "Not allowed"
return None
# This is used to find a sub menu (?)
#view = link
view = "definition"
config = SideBarBookmarkMenuWdg.get_config("SideBarWdg", view, personal=personal)
view = config.get_element_attribute(link, 'view')
if view:
options['widget_key'] = 'custom_layout'
options['view'] = view
class_name = None
else:
options = config.get_display_options(link)
class_name = config.get_display_handler(link)
if not options:
from pyasm.biz import Schema
config_xml = []
config_xml.append( '''
<config>
''')
config_schema = Schema.get_predefined_schema('config')
SideBarBookmarkMenuWdg.get_schema_snippet("_config_schema", config_schema, config_xml)
schema = Schema.get_admin_schema()
SideBarBookmarkMenuWdg.get_schema_snippet("_admin_schema", schema, config_xml)
config_xml.append( '''
</config>
''')
xml = "".join(config_xml)
from pyasm.widget import WidgetConfig
schema_config = WidgetConfig.get(view="_admin_schema", xml=xml)
options = schema_config.get_display_options(link)
if not options:
schema_config.set_view("_config_schema")
#.........这里部分代码省略.........
示例3: get_display
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get_admin_schema [as 别名]
def get_display(my):
from pyasm.biz import Project
security = Environment.get_security()
if not security.check_access("builtin", "side_bar_schema", "allow", default="deny"):
return DivWdg()
section_div = LabeledHidableWdg(label="Schema Views")
section_div.set_attr('spt_class_name', Common.get_full_class_name(my) )
palette = Palette.get()
color = palette.color("background3")
project_div = RoundedCornerDivWdg(hex_color_code=color,corner_size="10")
project_div.set_dimensions( width_str='175px', content_height_str='100px' )
project = Project.get()
project_code = project.get_code()
project_type = project.get_type()
div = DivWdg()
section_div.add(project_div)
project_div.add(div)
# get project type schema
schema = Schema.get_by_code(project_code)
if schema:
div.add( my.get_schema_wdg(schema) )
#if not project_type:
# raise SetupException("Project type not found for this [%s]" %project_code)
if project_type:
schema = Schema.get_predefined_schema(project_type)
if schema:
div.add( my.get_schema_wdg(schema) )
schema = Schema.get_predefined_schema('config')
div.add( my.get_schema_wdg(schema) )
schema = Schema.get_admin_schema()
div.add( my.get_schema_wdg(schema) )
return section_div
# create a fake schema
project = Project.get()
db_name = project.get_database()
sql = DbContainer.get(db_name)
tables = sql.get_tables()
tables.sort()
tables_str = "\n".join( ['<search_type name="%s"/>'%x for x in tables] )
# look at all of the search objects for mapped tables
search = Search("sthpw/search_object")
#search.add_where('''"namespace" = 'MMS' or namespace = '{project}' ''')
search.add_filter("namespace", 'MMS')
search.add_filter("namespace", '{project}')
search.add_where("or")
search_types = search.get_sobjects()
#for search_type in search_types:
# print "hhhh: ", search_type
schema_xml = '''
<schema>
%s
</schema>
''' % tables_str
schema = SearchType.create("sthpw/schema")
schema.set_value("code", "table")
schema.set_value("schema", schema_xml)
#div.add( my.get_schema_wdg(schema) )
return section_div
示例4: _get_predefined_url
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get_admin_schema [as 别名]
def _get_predefined_url(cls, key, hash):
# make some predefined fake urls
if key in ["link", "tab", "admin"]:
# this is called by PageNav
if key == "admin":
expression = "/admin/link/{link}"
else:
expression = "/%s/{link}" % key
options = Common.extract_dict(hash, expression)
link = options.get("link")
if not link:
return None
from tactic.ui.panel import SideBarBookmarkMenuWdg
personal = False
if "." in link:
# put in a check to ensure this is a user
parts = link.split(".")
user = Environment.get_user_name()
def is_personal(user, parts):
"""See if parts contains period
seperated form of username."""
acc = ""
for part in parts:
if acc == "":
acc = part
else:
acc = "%s.%s" % (acc, part)
if user == acc:
return True
return False
personal = is_personal(user, parts)
# test link security
project_code = Project.get_project_code()
security = Environment.get_security()
keys = [
{"element": link},
{"element": "*"},
{"element": link, "project": project_code},
{"element": "*", "project": project_code},
]
if not personal and not security.check_access("link", keys, "allow", default="deny"):
print "Not allowed"
return None
config = SideBarBookmarkMenuWdg.get_config("SideBarWdg", link, personal=personal)
options = config.get_display_options(link)
if not options:
from pyasm.biz import Schema
config_xml = []
config_xml.append(
"""
<config>
"""
)
config_schema = Schema.get_predefined_schema("config")
SideBarBookmarkMenuWdg.get_schema_snippet("_config_schema", config_schema, config_xml)
schema = Schema.get_admin_schema()
SideBarBookmarkMenuWdg.get_schema_snippet("_admin_schema", schema, config_xml)
config_xml.append(
"""
</config>
"""
)
xml = "".join(config_xml)
from pyasm.widget import WidgetConfig
schema_config = WidgetConfig.get(view="_admin_schema", xml=xml)
options = schema_config.get_display_options(link)
if not options:
schema_config.set_view("_config_schema")
options = schema_config.get_display_options(link)
if not options:
return None
class_name = options.get("class_name")
widget_key = options.get("widget_key")
if widget_key:
class_name = WidgetClassHandler().get_display_handler(widget_key)
elif not class_name:
class_name = "tactic.ui.panel.ViewPanelWdg"
if key in ["admin", "tab"]:
use_index = "false"
else:
#.........这里部分代码省略.........