本文整理汇总了Python中pyasm.common.Container类的典型用法代码示例。如果您正苦于以下问题:Python Container类的具体用法?Python Container怎么用?Python Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Container类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_internal_config
def add_internal_config(cls, configs, views):
'''add an internal config based on project base type'''
project = Project.get()
project_type = project.get_base_type()
# catch potential invalid xpath error
try:
if project_type:
tmp_path = __file__
dir_name = os.path.dirname(tmp_path)
file_path="%s/../config/%s-conf.xml" % (dir_name, project_type)
if os.path.exists(file_path):
for view in views:
config = WidgetConfig.get(file_path=file_path, view=view)
if config.get_view_node():
configs.append(config)
# finally, just look at the DEFAULT config
tmp_path = __file__
dir_name = os.path.dirname(tmp_path)
file_path="%s/../config/%s-conf.xml" % (dir_name, "DEFAULT")
if os.path.exists(file_path):
for view in views:
config = WidgetConfig.get(file_path=file_path, view=view)
if config.get_view_node():
configs.append(config)
except XmlException, e:
msg = "Error with view [%s]"% ' '.join(views)
error_list = Container.get_seq(cls.ERR_MSG)
if msg not in error_list:
Container.append_seq(cls.ERR_MSG, msg)
print e.__str__()
示例2: get
def get():
key = 'CacheList'
cache_list = Container.get(key)
if not cache_list:
cache_list = CacheList()
Container.put(key, cache_list)
return cache_list
示例3: get_by_key
def get_by_key(cls, key, user=None, project_code=None, use_cache=True):
if not user:
user = Environment.get_user_name()
# ignore the project_code column for now
dict_key = '%s:%s:%s' %(cls.SEARCH_TYPE, project_code, user)
if use_cache:
settings_dict = Container.get(dict_key)
else:
settings_dict = None
# explicit check for None
if settings_dict == None:
settings_dict = {}
if use_cache:
Container.put(dict_key, settings_dict)
search = Search(cls.SEARCH_TYPE)
search.add_filter("login", user)
if project_code:
search.add_filter("project_code", project_code)
else:
search.add_null_filter("project_code")
# don't filter with the key in order to build a dict
pref_settings = search.get_sobjects()
for setting in pref_settings:
settings_dict[setting.get_value('key')] = setting
pref_setting = settings_dict.get(key)
return pref_setting
示例4: 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)
示例5: set_pipeline
def set_pipeline(my, pipeline_xml, cache=True):
'''set the pipeline externally'''
# cache according to pipeline code, which will share the same xml object
if my.is_insert():
cache = False
search_key = my.get_search_key()
xml_dict = Container.get("Pipeline:xml")
if xml_dict == None:
xml_dict = {}
Container.put("Pipeline:xml", xml_dict)
my.xml = xml_dict.get(search_key)
if my.xml == None:
my.xml = Xml()
if cache:
xml_dict[search_key] = my.xml
if not pipeline_xml:
pipeline_xml = "<pipeline/>"
try:
my.xml.read_string(pipeline_xml)
except XmlException, e:
my.xml.read_string("<pipeline/>")
示例6: __init__
def __init__(self, dynamic_load=0, tab_key="tab", css=REG):
self.tab_names = []
self.wdg_dict = {}
self.dynamic_load = dynamic_load
self.set_tab_key(tab_key)
self.tab_style = css
self.content_height = 0
self.mode = Container.get("tab_mode")
# setting tab path
self.tab_path = Container.get("tab_path")
if not self.tab_path:
self.tab_path = "Main"
self.error_wdg = None
self.div = DivWdg(css='left_content')
if Environment.has_tactic_database():
self.invisible_list = ProdSetting.get_seq_by_key('invisible_tabs')
else:
self.invisible_list = []
super(TabWdg,self).__init__()
示例7: init
def init(my):
help = HelpItemWdg('Loader', 'The Loader lets you load 3D assets into your 3D applications. Among many options, you can choose to either reference, import, or open the asset through http or the internal file system.')
my.add(help)
pref = PrefSetting.get_value_by_key("use_java_maya")
app = WebContainer.get_web().get_app_name_by_uri()
if app == "Maya":
if not Container.get('GeneralAppletWdg'):
my.add( GeneralAppletWdg() )
Container.put('GeneralAppletWdg', True)
site_menu = SiteMenuWdg()
site_menu.add_style("float", "right")
site_menu.add_style("margin-top", "-2px")
my.add(site_menu)
WebContainer.add_js('MayaWebTools.js')
WebContainer.add_js('PyMaya.js')
tab = MayaTabWdgImpl()
tab_value = tab.set_tab_key("maya_tab")
#my.handle_tab(tab)
#my.add(tab,"tab")
my.setup_tab("maya_tab", tab=tab)
my.add( ProgressWdg() )
示例8: get_resource
def get_resource(my):
key = "Project:resource:%s" % my
resource = Container.get(key)
if resource == None:
resource = ProjectResource(my)
Container.put(key, resource)
return resource
示例9: __init__
def __init__(self, data=[]):
if not data:
self.data = []
elif type(data) in types.StringTypes:
try:
# optimize the loading of json data
json_data = Container.get("json_data")
if json_data == None:
json_data = {}
Container.put("json_data", json_data)
self.data = json_data.get(data)
if self.data == None:
self.data = jsonloads(data)
json_data[data] = self.data
except ValueError, e:
if e.__str__().find('No JSON object') != -1:
raise SetupException('Data is not decodable as JSON.')
# try a straight eval
self.data = eval(data)
except Exception as e:
if e.__str__().find('cannot parse JSON description') != -1:
raise SetupException('Data is not valid JSON.')
示例10: get
def get():
key = "JsWrapper"
wrapper = Container.get(key)
if wrapper == None:
wrapper = JsWrapper()
Container.put(key, wrapper)
return wrapper
示例11: _test_add_drop_column
def _test_add_drop_column(my):
#Project.set_project('unittest')
from pyasm.command import ColumnAddCmd, ColumnDropCmd, Command
cmd = ColumnAddCmd('unittest/country','special_place','varchar(256)')
Command.execute_cmd(cmd)
search_type = 'unittest/country'
# clear cache
Container.put("SearchType:column_info:%s" % search_type, None)
DatabaseImpl.clear_table_cache()
exists = SearchType.column_exists(search_type, 'special_place')
my.assertEquals(exists, True)
# now drop the column
cmd = ColumnDropCmd(search_type,'special_place')
Command.execute_cmd(cmd)
# clear cache
Container.put("SearchType:column_info:%s" % search_type, None)
cache_dict = Container.get("DatabaseImpl:column_info")
# assume database is the same as sthpw
database_type = Project.get_by_code("unittest").get_database_type()
db_resource = DbResource.get_default('unittest')
table_info = cache_dict.get("%s:%s" % (db_resource, "country"))
#table_info = cache_dict.get('DbResource:PostgreSQL:localhost:5432:unittest:country')
my.assertEquals(table_info != None, True)
#key = "%s:%s" % ('DbResource:PostgreSQL:localhost:5432:unittest', 'country')
key = "%s:%s" % (db_resource, "country")
cache_dict[key] = None
exists = SearchType.column_exists(search_type, 'special_place')
my.assertEquals(exists, False)
示例12: get
def get():
# try getting from the web from
state = Container.get("WebState")
if not state:
state = WebState()
Container.put("WebState", state)
return state
示例13: push_palette
def push_palette(cls, palette):
palettes = Container.get("Palette:palettes")
if palettes == None:
palettes = []
Container.put("Palette:palettes", palettes)
palette = Palette(palette=palette)
palettes.append(palette)
示例14: install
def install(language=""):
# get from preferences
if not language:
from pyasm.biz import PrefSetting
language = PrefSetting.get_value_by_key("language")
# else get from project setting
#if not language:
# from pyasm.prod.biz import ProdSetting
# language = ProdSetting.get_by_key("language")
if os.environ.get("LC_MESSAGES"):
language = os.environ.get("LC_MESSAGES")
if os.environ.get("TACTIC_LANG"):
language = os.environ.get("TACTIC_LANG")
# else it is english
if not language:
language = "en"
Container.put("language", language)
# add some localization code
#gettext.install("messages", unicode=True)
#path = "%s/src/locale" % Environment.get_install_dir()
#lang = gettext.translation("messages", localedir=path, languages=[language])
#lang.install()
# override the _ function
import __builtin__
__builtin__._ = Translation._translate
示例15: execute
def execute(self):
search = Search("sthpw/snapshot")
self.person = Person.create( "Unit", "Test",
"ComputerWorld", "unittest/checkin_test")
self._test_checkin()
self._test_copycheckin()
self._test_groupcheckin()
self._test_inplace_checkin()
self._test_preallocation_checkin()
self._test_get_children()
self._test_file_owner()
self._test_symlink()
self._test_with_naming()
self._test_auto_checkin()
self._test_strict_checkin()
self._test_base_dir_alias()
# clear the xml and config cache introduced by test_base_dir_alias
data = {}
Container.put(Config.CONFIG_KEY, data)
Xml.XML_FILE_CACHE = {}
Xml.XML_FILE_MTIME = {}