Back to index

plone3  3.1.7
remove_creation_mark.py
Go to the documentation of this file.
00001 ## Script (Python) "remove_creation_mark"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=id=None
00008 ##title=Clear __creation_flag__
00009 ##
00010 
00011 # XXX This script doesn't seem to be used anymore.
00012 
00013 from Products.CMFCore.utils import getToolByName
00014 
00015 # Avoid implicitly creating a session if one doesn't exists
00016 session = None
00017 sdm = getToolByName(context, 'session_data_manager', None)
00018 
00019 if sdm is not None:
00020     session = sdm.getSessionData(create=0)
00021 
00022 if session is None:
00023     return
00024 
00025 id = id and id or context.getId()
00026 
00027 cflag = session.get('__creation_flag__', {})
00028 
00029 if cflag.has_key(id):
00030     del cflag[id]
00031 
00032 if session.has_key(id):
00033     del session[id]
00034 
00035 session.set('__creation_flag__', cflag)