本文整理汇总了Python中gluon.tools.PluginManager方法的典型用法代码示例。如果您正苦于以下问题:Python tools.PluginManager方法的具体用法?Python tools.PluginManager怎么用?Python tools.PluginManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gluon.tools
的用法示例。
在下文中一共展示了tools.PluginManager方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _
# 需要导入模块: from gluon import tools [as 别名]
# 或者: from gluon.tools import PluginManager [as 别名]
def _():
plugins = PluginManager('package', app=None)
if plugins.package.app is not None:
# this will register the the application on content/type
plugins.package.app.registerContentType('package', ContentPackage())
if not hasattr(db, 'plugin_package_content'):
editor = CKEditor(db=db)
tbl = db.define_table(
'plugin_package_content',
Field('item_list', 'list:string'),
Field('description', 'text'),
Field('item_id', 'string', length=64),
auth.signature,
)
tbl.item_id.writable = False
tbl.item_id.readable = False
tbl.item_list.writable = False
tbl.item_list.readable = False
tbl.description.label = T('Description')
tbl.description.widget = editor.widget
tbl._enable_record_versioning()
# add a callback to the item table for updating the item list of
# the package on item deletion.
def plugin_package_callback(s):
item = s.select().first()
# this are the packages with contains the item to delete
pkgs = db(
db.plugin_package_content.item_list.contains(
item.unique_id)
).select()
for pkg in pkgs:
# remove the item from the package
pkg.item_list.remove(item.unique_id)
pkg.update_record()
return False
db.item._before_delete.insert(0, plugin_package_callback)
示例2: _
# 需要导入模块: from gluon import tools [as 别名]
# 或者: from gluon.tools import PluginManager [as 别名]
def _():
plugins = PluginManager('text', app=None)
if plugins.text.app is not None:
# this will register the content/type on the application
plugins.text.app.registerContentType('text', ContentText())
if not hasattr(db, 'plugin_text_text'):
# configure ckeditor
editor = CKEditor(db=db)
# definimos la BD
tbl = db.define_table(
'plugin_text_text',
Field('byline', 'string', length=250, default=''),
Field('body', 'text', label=T('Content'), default=''),
Field('item_id', 'string', length=64),
auth.signature,
)
tbl.byline.label = T('By line')
tbl.item_id.readable = False
tbl.item_id.writable = False
tbl.body.requires = IS_NOT_EMPTY()
tbl.body.widget = editor.widget
# enable record versioning
tbl._enable_record_versioning()
return
示例3: _
# 需要导入模块: from gluon import tools [as 别名]
# 或者: from gluon.tools import PluginManager [as 别名]
def _():
plugins = PluginManager('photoset', app=None)
if plugins.photoset.app is not None:
plugins.photoset.app.registerContentType('photoset', ContentPhotoset())
editor = CKEditor(db=db)
if not hasattr(db, 'plugin_photoset_photo'):
db.define_table(
'plugin_photoset_photo',
Field(
'thumbnail', 'upload',
uploadseparate=True,
autodelete=True,
default=None
),
Field(
'picture', 'upload',
uploadseparate=True,
autodelete=True
),
)
if not hasattr(db, 'plugin_photoset_content'):
tbl = db.define_table(
'plugin_photoset_content',
Field('credit_line', 'string', length=250, default=''),
Field(
'description', 'text',
label=T('Description'),
default=''
),
Field('photoset', 'list:reference plugin_photoset_photo'),
Field('item_id', 'string', length=64),
auth.signature,
)
tbl.credit_line.label = T("Credit line")
tbl.description.label = T('Description')
tbl.description.widget = editor.widget
tbl._enable_record_versioning()
# add callback for item cleanup on delete.
def __plugin_photoset_item_on_delete(s):
item = s.select().first()
if item.item_type == 'photoset':
# cleanup here
cnt = db.plugin_photoset_content(item_id=item.unique_id)
db(
db.plugin_photoset_photo.id.belongs(
cnt.photoset)).delete()
db(
db.plugin_photoset_content.item_id == item.unique_id
).delete()
return False # remember to procced
db.item._before_delete.insert(0, __plugin_photoset_item_on_delete)
示例4: _
# 需要导入模块: from gluon import tools [as 别名]
# 或者: from gluon.tools import PluginManager [as 别名]
def _():
plugins = PluginManager('audio', app=None)
if plugins.audio.app is not None:
plugins.audio.app.registerContentType('audio', ContentAudio())
# the audio rendentions
tbl = db.define_table(
# register my content type plugin
'plugin_audio_rendition',
Field('purpose', 'string', length=50, default='web'),
Field(
'audio', 'upload', uploadseparate=True, autodelete=True
),
)
tbl.purpose.comment = T('''
Descrive the purpose of this rendition of the video, e.g.:
web, social networks, etc.
''')
tbl.purpose.label = T('Purpose')
tbl.audio.label = T('Audio File')
tbl.audio.requires = IS_NOT_EMPTY()
# configure ckeditor
editor = CKEditor(db=db)
# content table
tbl = db.define_table(
'plugin_audio_content',
Field('credit_line', 'string', length=150, default=''),
Field(
'description', 'text',
label=T('Description'),
default=''
),
Field('renditions', 'list:reference plugin_audio_rendition'),
Field('item_id', 'string', length=64),
auth.signature,
)
tbl.item_id.readable = False
tbl.item_id.writable = False
tbl.credit_line.label = T("Credit line")
tbl.description.label = T('Description')
tbl.description.widget = editor.widget
tbl.renditions.label = T("Renditions")
tbl.renditions.default = []
tbl.renditions.writable = False
tbl.renditions.readable = False
tbl._enable_record_versioning()
# add callback for item cleanup on delete.
def __plugin_audio_item_on_delete(s):
item = s.select().first()
if item.item_type == 'audio':
# cleanup here
cnt = db.plugin_audio_content(item_id=item.unique_id)
db(
db.plugin_audio_rendition.id.belongs(
cnt.renditions)).delete()
db(
db.plugin_audio_content.item_id == item.unique_id
).delete()
return False # remember to procced
db.item._before_delete.insert(0, __plugin_audio_item_on_delete)