Back to index

plone3  3.1.7
externalEditorEnabled.py
Go to the documentation of this file.
00001 ## Script (Python) "externalEditorEnabled" 
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=
00008 ##title=Can an object be changed with the external editor and by the user
00009 ##
00010 #
00011 from Products.CMFCore.utils import getToolByName
00012 from Products.CMFPlone.utils import webdav_enabled
00013 
00014 portal = getToolByName(context, 'portal_url').getPortalObject()
00015 mtool = getToolByName(portal, 'portal_membership')
00016 
00017 if mtool.isAnonymousUser():
00018     return False
00019 
00020 # Temporary content cannot be changed through EE (raises AttributeError)
00021 portal_factory = getToolByName(portal, 'portal_factory')
00022 if portal_factory.isTemporary(context):
00023     return False
00024 
00025 # Check if the member property
00026 member = mtool.getAuthenticatedMember()
00027 if not member.getProperty('ext_editor', False):
00028     return False
00029 
00030 if not webdav_enabled(context, container):
00031     return False
00032 
00033 # Object not locked ?
00034 # note: you may comment out those two lines if you prefer to let the user to borrow the lock
00035 if context.wl_isLocked():
00036     return False
00037 
00038 # Content may provide data to the external editor ?
00039 return not not portal.externalEditLink_(context)