本文整理汇总了Python中OFS.Folder.Folder._getOb方法的典型用法代码示例。如果您正苦于以下问题:Python Folder._getOb方法的具体用法?Python Folder._getOb怎么用?Python Folder._getOb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OFS.Folder.Folder
的用法示例。
在下文中一共展示了Folder._getOb方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addWikiFromFs
# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import _getOb [as 别名]
def addWikiFromFs(self, new_id, title='', wiki_type='zwikidotorg',
REQUEST=None):
"""
Create a new zwiki web from the specified template on the filesystem.
"""
parent = self.Destination()
# Go with a BTreeFolder from the start to avoid hassle with large
# wikis on low-memory hosted servers ?
#parent.manage_addProduct['BTreeFolder2'].manage_addBTreeFolder(
#str(new_id),str(title))
# No - the standard folder's UI is more useful for small wikis,
# and more importantly BTreeFolder2 isn't standard until 2.8.0b2
f = Folder()
f.id, f.title = str(new_id), str(title)
new_id = parent._setObject(f.id, f)
f = parent[new_id]
# add objects from wiki template
# cataloging really slows this down!
dir = os.path.join(package_home(globals()),'wikis',wiki_type)
filenames = os.listdir(dir)
for filename in filenames:
if re.match(r'(?:\..*|CVS|_darcs)', filename): continue
m = re.search(r'(.+)\.(.+)',filename)
id, type = filename, ''
if m: id, type = m.groups()
text = open(dir + os.sep + filename, 'r').read()
if type == 'dtml':
addDTMLMethod(f, filename[:-5], title='', file=text)
elif re.match(r'(?:(?:stx|html|latex)(?:dtml)?|txt)', type):
addZWikiPage(f,id,title='',page_type=type,file=text)
elif type == 'pt':
f._setObject(id, ZopePageTemplate(id, text, 'text/html'))
elif type == 'py':
f._setObject(id, PythonScript(id))
f._getOb(id).write(text)
elif type == 'zexp' or type == 'xml':
connection = self.getPhysicalRoot()._p_jar
f._setObject(id, connection.importFile(dir + os.sep + filename,
customImporters=customImporters))
#self._getOb(id).manage_changeOwnershipType(explicit=0)
elif re.match(r'(?:jpe?g|gif|png)', type):
f._setObject(filename, Image(filename, '', text))
else:
id = f._setObject(filename, File(filename, '', text))
if type == 'css': f[filename].content_type = 'text/css'
f.objectValues(spec='ZWiki Page')[0].updatecontents()
示例2: _initPAS
# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import _getOb [as 别名]
def _initPAS(self, plugin_type_info=(), plugins={}):
from OFS.Folder import Folder
from Products.PluggableAuthService.PluggableAuthService import addPluggableAuthService
app = Folder()
app.getPhysicalPath = lambda: ()
app.getPhysicalRoot = lambda: app
addPluggableAuthService(app)
pas = app._getOb("acl_users")
return app, pas
示例3: _initRegistry
# 需要导入模块: from OFS.Folder import Folder [as 别名]
# 或者: from OFS.Folder.Folder import _getOb [as 别名]
def _initRegistry(self, plugin_type_info=(), plugins={}):
from OFS.Folder import Folder
from OFS.SimpleItem import SimpleItem
from Products.PluginRegistry.PluginRegistry import PluginRegistry
app = Folder()
app.getPhysicalPath = lambda: ()
app.getPhysicalRoot = lambda: app
app._setObject('foo_plugin_1', SimpleItem())
app._setObject('foo_plugin_2', SimpleItem())
registry = PluginRegistry(plugin_type_info)
registry._plugins = {} # it is usually lazy
for plugin_type, registered in plugins.items():
for obj_id in registered:
obj = app._getOb(obj_id)
directlyProvides(obj, plugin_type)
registry._plugins[plugin_type] = registered
app._setObject('plugin_registry', registry)
registry = app._getOb('plugin_registry')
return app, registry