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
|
Rev | Line | |
---|
[1] | 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 | |
---|
| 11 | from Products.CMFCore.utils import getToolByName |
---|
| 12 | from Products.qPloneGoogleMaps.config import PROPERTY_SHEET, PROPERTY_FIELD, MAP_API_KEYS |
---|
| 13 | |
---|
| 14 | s = MAP_API_KEYS[0] |
---|
| 15 | |
---|
| 16 | res = {s[:s.index('|')]:s[s.index('|')+1:],} |
---|
| 17 | |
---|
| 18 | portal_props = getToolByName(context, 'portal_properties') |
---|
| 19 | |
---|
| 20 | if not hasattr(portal_props, PROPERTY_SHEET): |
---|
| 21 | return res.values()[0] |
---|
| 22 | |
---|
| 23 | property_sheet = getattr(portal_props, PROPERTY_SHEET) |
---|
| 24 | |
---|
| 25 | if not hasattr(property_sheet, PROPERTY_FIELD): |
---|
| 26 | return res.values()[0] |
---|
| 27 | |
---|
| 28 | map_api_keys = getattr(property_sheet, PROPERTY_FIELD) |
---|
| 29 | |
---|
| 30 | for el in map_api_keys: |
---|
| 31 | res[el[:el.index('|')]] = el[el.index('|')+1:] |
---|
| 32 | |
---|
| 33 | try: return res[context.portal_url()] |
---|
| 34 | except: return res.values()[0] |
---|
Note: See
TracBrowser
for help on using the repository browser.