source: products/qPloneGoogleMaps/tags/0.1.0/skins/qPloneGoogleMaps/getMapKey.py

Last change on this file was 1, checked in by myroslav, 18 years ago

Building directory structure

  • Property svn:eol-style set to native
File size: 853 bytes
Line 
1## Script (Python) "getMapKey"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10
11from Products.CMFCore.utils import getToolByName
12from Products.qPloneGoogleMaps.config import PROPERTY_SHEET, PROPERTY_FIELD, MAP_API_KEYS
13
14s = MAP_API_KEYS[0]
15
16res = {s[:s.index('|')]:s[s.index('|')+1:],}
17
18portal_props = getToolByName(context, 'portal_properties')
19
20if not hasattr(portal_props, PROPERTY_SHEET):
21    return res.values()[0]
22
23property_sheet = getattr(portal_props, PROPERTY_SHEET)
24
25if not hasattr(property_sheet, PROPERTY_FIELD):
26    return res.values()[0]
27
28map_api_keys = getattr(property_sheet, PROPERTY_FIELD)
29
30for el in map_api_keys:
31    res[el[:el.index('|')]] = el[el.index('|')+1:]
32
33try: return res[context.portal_url()]
34except: return res.values()[0]
Note: See TracBrowser for help on using the repository browser.