本文整理汇总了Python中pyasm.common.Common.create_from_class_path方法的典型用法代码示例。如果您正苦于以下问题:Python Common.create_from_class_path方法的具体用法?Python Common.create_from_class_path怎么用?Python Common.create_from_class_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.common.Common
的用法示例。
在下文中一共展示了Common.create_from_class_path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: verify
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import create_from_class_path [as 别名]
def verify(my, login_name, password):
# replace cn=attribute with cn={login} in the config ldap_path
# e.g. cn={login},o=organization,ou=server,dc=domain
path = Config.get_value("security", "ldap_path")
server = Config.get_value("security", "ldap_server")
assert path, server
my.login_name = login_name
my.internal = True
path = path.replace("{login}", login_name)
#import ldap
try:
l = ldap.open(server)
l.simple_bind_s(path, password)
l.unbind()
return True
except:
login = Login.get_by_login(login_name)
# check if it's an external account and verify with standard approach
if login and login.get_value('location', no_exception=True) == 'external':
auth_class = "pyasm.security.TacticAuthenticate"
authenticate = Common.create_from_class_path(auth_class)
is_authenticated = authenticate.verify(login_name, password)
if is_authenticated == True:
my.internal = False
return True
elif login:
auth_class = "pyasm.security.TacticAuthenticate"
authenticate = Common.create_from_class_path(auth_class)
is_authenticated = authenticate.verify(login_name, password)
if is_authenticated == True:
my.internal = False
return True
raise SecurityException("Login/Password combination incorrect")
示例2: init
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import create_from_class_path [as 别名]
def init(my):
my.widget_class = my.xml.get_value("widget/display/@class")
my.draw = my.xml.get_value("widget/display/@draw")
my.title = my.xml.get_value("widget/@name")
my.name = my.title
# convert the widget data
options = {}
nodes = my.xml.get_nodes("widget/display/*")
for node in nodes:
name = node.nodeName
value = Xml.get_node_value(node)
if options.has_key(name):
# turn this into an array
array = []
array.append(options.get(name))
array.append(value)
options[name] = array
else:
options[name] = value
my.options = options
my.widget = Common.create_from_class_path(my.widget_class, [my.title])
示例3: get_display
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import create_from_class_path [as 别名]
def get_display(my):
top = my.top
class_name = my.kwargs.get("display_class_name")
kwargs = my.kwargs.get("display_kwargs")
top.add_style("border: solid 1px #777")
top.add_style("position: absolute")
top.add_style("z-index: 100")
top.add_style("box-shadow: 2px 2px 4px 4px #aaa")
top.add_style("background: #FFF")
top.add_style("margin-right: 200px")
top.add_style("margin-top: -20px")
top.add_style("overflow: hidden")
#widget_html = "<div style='border: solid 1px #777; position: absolute; z-index: 100; box-shadow: 2px 2px 4px 4px #aaa; background: #FFF; margin-right: 20px; margin-top: -20px; overflow: hidden'>" + widget_html + "</div>";
widget = Common.create_from_class_path(class_name, kwargs)
top.add(widget)
show_pointer = my.kwargs.get("show_pointer")
if show_pointer not in [False, 'false']:
my.get_arrow_wdg()
return top
示例4: get_naming
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import create_from_class_path [as 别名]
def get_naming(cls, naming_type, sobject=None, project=None):
'''get a certain type of naming determined by type of naming'''
naming_cls = ""
# this import statement is needed for running Batch
from pyasm.biz import Project
if not project:
if sobject:
project = sobject.get_project()
else:
project = Project.get()
if project:
naming_cls = project.get_value("%s_naming_cls" % naming_type, no_exception=True)
if not naming_cls and project.get_project_type():
naming_cls = project.get_project_type().get_value("%s_naming_cls" % naming_type, no_exception=True)
# if none is defined, use defaults
if not naming_cls:
# TODO: this should probably be stored somewhere else
if naming_type == "file":
naming_cls = "pyasm.biz.FileNaming"
elif naming_type == "dir":
naming_cls = "pyasm.biz.DirNaming"
elif naming_type == "node":
naming_cls = "pyasm.prod.biz.ProdNodeNaming"
naming = Common.create_from_class_path(naming_cls)
return naming
示例5: execute
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import create_from_class_path [as 别名]
def execute(my):
#protocol = 'xmlrpc'
protocol = 'local'
if protocol == 'local':
server = TacticServerStub.get()
else:
server = TacticServerStub(protocol=protocol,setup=False)
TacticServerStub.set(server)
project = my.data.get("project")
ticket = my.data.get("ticket")
assert project
assert ticket
server.set_server("localhost")
server.set_project(project)
server.set_ticket(ticket)
my.class_name = my.data.get('class_name')
assert my.class_name
my.kwargs = my.data.get('kwargs')
if not my.kwargs:
my.kwags = {}
#trigger = eval("%s(**my.kwargs)" % my.class_name)
trigger = Common.create_from_class_path(my.class_name, kwargs=my.kwargs)
input_data = my.get_input_data()
trigger.set_input(input_data)
trigger.execute()
示例6: execute_python_cmd
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import create_from_class_path [as 别名]
def execute_python_cmd(my, class_name, kwargs):
import sys
exec_class_name = 'tactic_client_lib.scm.CmdWrapper'
kwargs = json.loads(kwargs)
kwargs['class_name'] = class_name
cmd = Common.create_from_class_path(exec_class_name, [], kwargs)
ret_val = cmd.execute()
return json.dumps(ret_val)
示例7: build_widget
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import create_from_class_path [as 别名]
def build_widget(cls, options):
class_name = options.get('class_name')
if not class_name:
class_name = 'tactic.ui.panel.ViewPanelWdg'
else:
del(options['class_name'])
widget = Common.create_from_class_path(class_name, kwargs=options)
return widget
示例8: get_code_naming
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import create_from_class_path [as 别名]
def get_code_naming(sobject,code):
'''Gets the code naming object for the current project'''
project = Project.get()
code_naming_cls = project.get_value("code_naming_cls")
if code_naming_cls == "":
code_naming_cls = "pyasm.biz.CodeNaming"
naming = Common.create_from_class_path(code_naming_cls, \
[sobject,code] )
return naming
示例9: run_batch
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import create_from_class_path [as 别名]
def run_batch(kwargs):
command = k.get("command")
kwargs = k.get("kwargs")
login = k.get("login")
project_code = k.get("project_code")
from pyasm.security import Batch
Batch(project_code=project_code, login_code=login)
cmd = Common.create_from_class_path(command, kwargs=kwargs)
Command.execute_cmd(cmd)
示例10: init
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import create_from_class_path [as 别名]
def init(my):
web = WebContainer.get_web()
widget_class = web.get_form_value("dynamic_widget")
widget_args = web.get_form_values("args")
if widget_class == "":
raise DynamicLoaderException("Widget class [%s] is not defined" % widget_class)
widget = Common.create_from_class_path( widget_class, widget_args )
my.add_widget(widget)
示例11: get_title
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import create_from_class_path [as 别名]
def get_title(my):
my.widget = Common.create_from_class_path(my.widget_class, [my.title])
my.widget.options = my.options
my.widget.set_title(my.title)
my.widget.set_name(my.title)
Container.put_dict("widgets", my.title, my.widget)
index = my.get_current_index()
my.widget.set_sobjects(my.sobjects)
my.widget.set_current_index(index)
if my.draw == "false":
return ""
else:
return my.widget.get_title()
示例12: get_title
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import create_from_class_path [as 别名]
def get_title(self):
self.widget = Common.create_from_class_path(self.widget_class, [self.title])
self.widget.options = self.options
self.widget.set_title(self.title)
self.widget.set_name(self.title)
Container.put_dict("widgets", self.title, self.widget)
index = self.get_current_index()
self.widget.set_sobjects(self.sobjects)
self.widget.set_current_index(index)
if self.draw == "false":
return ""
else:
return self.widget.get_title()
示例13: query_EditWdg
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import create_from_class_path [as 别名]
def query_EditWdg(args=None, search_type=''):
import json
from pyasm.widget.widget_config import WidgetConfigView
def pop_classes(in_dict):
out_dict = {}
for key, val in in_dict.iteritems():
if not (hasattr(val, '__dict__') or key.startswith('_')):
out_dict[key] = val
return out_dict
class_name = 'tactic.ui.panel.EditWdg'
args_array = []
from pyasm.common import Common
# from pyasm.common import Container
widget = Common.create_from_class_path(class_name, args_array, args)
widget.explicit_display()
result_dict = {
'EditWdg': {
'element_descriptions': widget.element_descriptions,
'element_names': widget.element_names,
'element_titles': widget.element_titles,
'input_prefix': widget.input_prefix,
'kwargs': widget.kwargs,
'mode': widget.mode,
'security_denied': widget.security_denied,
'title': widget.title,
},
'InputWidgets': [],
'sobject': '',
}
input_widgets = widget.get_widgets()
wdg_config = WidgetConfigView.get_by_element_names(search_type, widget.element_names, base_view=args['view'])
for i_widget in input_widgets:
widget_dict = pop_classes(i_widget.__dict__)
widget_dict['action_options'] = wdg_config.get_action_options(widget_dict.get('name'))
widget_dict['class_name'] = i_widget.get_class_name()
item_values = i_widget.get_values()
if item_values:
widget_dict['values'] = item_values
result_dict['InputWidgets'].append(widget_dict)
return json.dumps(result_dict, separators=(',', ':'))
示例14: get_project_repo_handler
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import create_from_class_path [as 别名]
def get_project_repo_handler(project_code=None):
if not project_code:
project = Project.get()
else:
project = Project.get_by_code(project_code)
repo_handler_cls = project.get_value("repo_handler_cls", no_exception=True)
if not repo_handler_cls and project.get_project_type():
repo_handler_cls = project.get_project_type().get_value("repo_handler_cls", no_exception=True)
if not repo_handler_cls:
repo_handler_cls = "pyasm.biz.BaseRepoHandler"
repo_handler = Common.create_from_class_path(repo_handler_cls)
return repo_handler
示例15: add
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import create_from_class_path [as 别名]
def add(self,widget,title=None):
if title == None:
title = widget.__class__.__name__
# determine the url and check security
request_url = WebContainer.get_web().get_request_url()
base = request_url.get_base()
if base.endswith("/"):
base = "%sIndex" % base
check = "%s|%s" % (base,title)
security = WebContainer.get_security()
if not security.check_access("url", check, "view"):
return
if not security.check_access("tab", title, "view"):
return
self.tab_names.append(title)
# for tabs, the widget passed in can be None. Only the
# title is added
assert widget != None
# only the selected one really gets added
try:
# if a method was passed in, then execute it
if type(widget) == types.MethodType:
widget = MethodWdg(widget)
elif isinstance(widget, basestring):
widget = Common.create_from_class_path(widget)
elif not isinstance(widget, Widget):
widget = ClassWdg(widget)
# catch all exceptions and log them
except Exception as e:
self.handle_exception(e)
super(DynTabWdg,self)._add_widget(widget, title)