Exemple #1
0
def onContentSelectionLensModified(context, event):
    """
    Create Tag Namespaces folder if lens is an open lens

    params:
        context - the lens that has been modified
        event - not used but required by API

    return:
        None
    """
    if context.isTemporary():
        return
    id = 'tag-namespaces'
    if id not in context.objectIds():
        obj = ATFolder(id)
        # Create these attributes to work around a Plone indexing bug
        obj.start = DateTime()
        obj.end = DateTime()
        context._setObject(id, obj)
        obj = context._getOb(id)
        obj.setTitle("Tag vocabularies")
        obj.reindexObject()
        obj.notifyWorkflowCreated()

        # Constrain allowed types
        obj.setConstrainTypesMode(1)
        obj.setLocallyAllowedTypes(['TagNamespace'])

        # Set a template as default view
        obj.setLayout('lens_tagnamespaces_default_view')