用于Plone设置处理器的各种简单函数
项目描述
collective.setuphelpers
此包提供了一些用于初始站点内容设置的常用任务的简单函数。
此包的目标不是尽可能通用,但它可能会加快速度。
>>> from collective.setuphelpers.structure import setupStructure >>> portal = layer['portal'] >>> STRUCTURE = [{'id':'example-id','title':'Example title','type':'Document'}] >>> setupStructure(portal, STRUCTURE) >>> portal['example-id'] <ATDocument at /plone/example-id> >>> portal.manage_delObjects(['example-id'])
您可以使用子文件夹等。
>>> setupStructure(portal, layer['test_structure']) >>> portal['testfolder']['item1'].getText() '<p>Text body</p>'
各种方法
def registerDisplayViews(portal, views): """ Register additional display views for content types based on "views" dictionary containing list of additional view ids for each content type. @example views dictionary: DISPLAY_VIEWS = { 'Folder': [ 'short-listing', 'extended-listing' ], 'Document': [ 'article-view', 'fancy-document-view' ] } @call from setup handler: from tools.sitesetup import registerDisplayViews registerDisplayViews(portal, DISPLAY_VIEWS) """ def unregisterDisplayViews(portal, views): """ Unregister additional display views for content types based on "views" dictionary containing list of additional view ids for each content type (the same as for registerDisplayViews method). """ def setupCatalog(portal, indexes={}, metadata=[]): """ Register portal catalog indexes and metadata columns. """ def hideActions(portal, actions): """ Hide actions given dict of action categories with values as list of action ids example actions: HIDE_ACTIONS = {'user':['dashboard'], 'object':['contentrules', 'local_roles']} """ def registerActions(portal, actions={}): """ Register new portal actions using dict of action attributes like in the following example: CUSTOM_ACTIONS = { '1': { # order in which will be action registered 'id': 'my-action', 'category': 'site_actions', 'title': 'My action', 'i18n_domain': 'myi18n.domain', 'url_expr': string:${globals_view/navigationRootUrl}/my-action-view', 'available_expr': 'python:member is not None' 'permissions': ('View',), 'visible': True } } """ def setupTinyMCE(portal, settings): """ Configures tinymce wysiwyg editor. Here is an example settings object: EDITOR_SETTINGS = { 'attributes': { 'contextmenu': False, 'link_using_uids': True, 'allow_captioned_images': True, '...': True }, 'commands': { 'install_transforms': True }, 'toolbar': { 'advhr':False, 'anchor':False, 'attribs':False, 'backcolor':False, 'bold':True, 'bullist':True, 'charmap':False, 'cleanup':False, 'code':True, 'copy':False, 'cut':False, 'definitionlist':False, 'emotions':False, 'external':False, 'forecolor':False, 'fullscreen':False, 'hr':False, 'iespell':False, 'image':True, 'indent':False, 'insertdate':False, 'inserttime':False, 'italic':True, 'justifycenter':False, 'justifyfull':False, 'justifyleft':False, 'justifyright':False, 'link':True, 'media':False, 'nonbreaking':False, 'numlist':True, 'outdent':False, 'pagebreak':False, 'paste':False, 'pastetext':False, 'pasteword':False, 'preview':False, 'print':False, 'redo':False, 'removeformat':False, 'replace':False, 'save':False, 'search':False, 'strikethrough':False, 'style':True, 'sub':False, 'sup':False, 'tablecontrols':True, 'underline':False, 'undo':False, 'unlink':True, 'visualaid':False, 'visualchars':False, 'width':u'440' }, 'styles': [ 'Subheading|h3', '...|..' ], 'tablestyles': [ 'Subdued grid|plain', '...|...' ], 'linkable': [ 'News Item', '...' ], 'containsanchors': [ 'Document', '...' ], 'containsobjects': [ 'Folder', '...' ], 'imageobjects': [ 'Image', '...' ], } """ def setupCTAvailability(portal, settings): """ Use this method to allow/disable content types to be globally or locally addable. All non listed content types will be automatically disabled. Here is example settings object (NOTE: "DISABLE" key is used to disable content types adding globally): CONTENT_TYPES_AVAILABILITY = { 'DISABLE': [ 'Event', 'Link' ], 'Plone Site': [ 'Folder', 'Document' ] } """ def setupHTMLFiltering(portal, settings): """ Update html filtering configlet settings, by passing dict of settings as in the following example for enabling embed html content in the richtext: HTML_FILTER = { 'remove': { 'nasty': ['embed', 'object'], 'stripped': ['object', 'param'], 'custom': [] }, 'add': { 'nasty': [], 'stripped': [], 'custom': ['embed'] } } NOTE: you can ommit empty lists """ def registerTransform(portal, name, module): """ Usage: registerTransform(portal, 'web_intelligent_plain_text_to_html', 'Products.intelligenttext.transforms.web_intelligent_plain_text_to_html') """ def unregisterTransform(portal, name): """ Usage: unregisterTransform(portal, 'web_intelligent_plain_text_to_html') """ def setHomePage(portal, view_name): """ Set default view for the site root. """ def setupNavigation(portal, settings): """ Use this method to exclude/include content types from navigation globally. Here is example settings object: NAVIGATION = { 'include': [ 'Folder', 'CustomFolder' ], 'exclude': [ 'Link', 'Document', 'Event' ] } """ def hidePortletTypes(portal, portlets=[]): """ Hides portlets from the portlet management pages. @param: portlets - list of portlet idenifiers used in portlets.xml to register them example: portlets=['portlets.Calendar', 'portlets.Classic'] """ def registerResourceBundle(portal, bundles={}): """ Register resource registry bundles for themes (skin layers). @param: bundles - dict of skin layers with list of bundles example: RESOURCE_BUNDLES = { 'MySkin': ['default', 'jquery', 'jquerytools'], 'OtherSkin': ['default'] } """ def unregisterResourceBundle(portal, layers=[]): """ Unregister custom resource registry bundles for themes (skin layers). @param: layers - list of layers for which will be custom bundles unregistered so the skin layer will use only 'default' bundle. example: BUNDLES_TO_REMOVE = ['MySkin', 'OtherSkin'] """
工具
def makeFieldsInvisible(schema=None, fields=[]): """ Makes schemata fields respective widgets invisible in the view page or edit form. @schema: Archetypes schema object @fields: list of field ids/names """ def changeFieldsSchemata(schema=None, fields=[]): """ Moves fields into different schemata parts like categorisation or settings etc. "fields" parameter is expected to be a list of dicts with key: (field) id and (schemata id) schemata """
贡献者
变更日志
0.6.3 (2013-03-12)
添加了class_blacklist和style_whitelist到setupHTMLFiltering [naro]
0.6.2 (2012-09-23)
setupStructure接受base_path参数,允许设置文件和图像的文件系统路径 [naro]
0.6.1 (2012-01-10)
修复了使用plone < 4.2.x时由于IResourceRegistriesSettings导入错误而损坏的包 [lzdych]
0.6 (2012-01-09)
添加了registerResourceBundle和unregisterResourceBundle [lzdych]
0.5 (2012-01-09)
添加了enableUserPwdChoice方法 [lzdych]
registerActions现在接受每个操作的available_expr属性 [lzdych]
修复:在尝试禁用未安装的内容类型时,setupCTAvailability 方法失败 [lzdych]
0.4 (2011-10-13)
添加了隐藏端口令牌从端口令牌管理页面的方法 [lzdych]
0.3 (2011-10-03)
修复:TinyMCE setuphandler 清除“资源类型”设置,如果从辅助方法参数中省略 [lzdych]
0.2.1 (2011-08-18)
添加了许多新的辅助方法并改进了readme ;-)
0.1 (2011-06-15)
初始版本
项目详情
下载文件
下载适合您平台的应用程序。如果您不确定选择哪个,请了解更多关于 安装包 的信息。
源代码分发
collective.setuphelpers-0.6.5.zip (36.3 kB 查看哈希值)
关闭
collective.setuphelpers-0.6.5.zip 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 78070b4bd3cadbfe733e6a4b39978082e41563b8ccf257dd0daf94aa830ff506 |
|
MD5 | acbef1c4aea368f559191941b50ec32b |
|
BLAKE2b-256 | 6d5f5117afe7e296e911cb4f6c51520e0ba5bc0fe8257f9ea91aafba0b56e864 |