當前位置: 首頁>>代碼示例>>Python>>正文


Python tools.PluginManager方法代碼示例

本文整理匯總了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) 
開發者ID:ybenitezf,項目名稱:nstock,代碼行數:41,代碼來源:plugin_package.py

示例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 
開發者ID:ybenitezf,項目名稱:nstock,代碼行數:28,代碼來源:plugin_text.py

示例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) 
開發者ID:ybenitezf,項目名稱:nstock,代碼行數:56,代碼來源:plugin_photoset.py

示例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) 
開發者ID:ybenitezf,項目名稱:nstock,代碼行數:62,代碼來源:plugin_audio.py


注:本文中的gluon.tools.PluginManager方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。