Back to index

plone3  3.1.7
getMainGlobals.py
Go to the documentation of this file.
00001 ##parameters=
00002 ##
00003 from Products.CMFCore.utils import getUtilityByInterfaceName
00004 from Products.CMFCore.utils import getToolByName
00005 from Products.CMFDefault.utils import decode
00006 from Products.CMFDefault.utils import getBrowserCharset
00007 
00008 atool = getToolByName(script, 'portal_actions')
00009 caltool = getToolByName(script, 'portal_calendar', None)
00010 mtool = getToolByName(script, 'portal_membership')
00011 ptool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
00012 utool = getToolByName(script, 'portal_url')
00013 wtool = getToolByName(script, 'portal_workflow')
00014 portal_object = utool.getPortalObject()
00015 
00016 if not 'charset' in (context.REQUEST.RESPONSE.getHeader('content-type') or ''):
00017     # Some newstyle views set a different charset - don't override it.
00018     # Oldstyle views need the default_charset.
00019     default_charset = ptool.getProperty('default_charset', None)
00020     if default_charset:
00021         context.REQUEST.RESPONSE.setHeader('content-type',
00022                                     'text/html; charset=%s' % default_charset)
00023 
00024 message = context.REQUEST.get('portal_status_message')
00025 if message and isinstance(message, str):
00026     # portal_status_message uses always the browser charset.
00027     message = message.decode(getBrowserCharset(context.REQUEST))
00028 
00029 globals = {'utool': utool,
00030            'mtool': mtool,
00031            'atool': atool,
00032            'wtool': wtool,
00033            'caltool_installed': caltool is not None,
00034            'portal_object': portal_object,
00035            'portal_title': portal_object.Title(),
00036            'object_title': context.Title(),
00037            'object_description': context.Description(),
00038            'portal_url': utool(),
00039            'member': mtool.getAuthenticatedMember(),
00040            'membersfolder': mtool.getMembersFolder(),
00041            'isAnon': mtool.isAnonymousUser(),
00042            'wf_state': wtool.getInfoFor(context, 'review_state', ''),
00043            'status_message': message}
00044 
00045 return decode(globals, context)