| 3 |
|
|
| 4 |
from StringIO import StringIO |
from StringIO import StringIO |
| 5 |
|
|
| 6 |
country_langs = ('en', 'fr') |
countries_langs = ('en', 'fr') |
| 7 |
|
us_state_langs = ('en',) |
| 8 |
|
|
| 9 |
def install(self): |
def install(self): |
| 10 |
out = StringIO() |
out = StringIO() |
| 14 |
|
|
| 15 |
geo_tool = self.geographic_properties |
geo_tool = self.geographic_properties |
| 16 |
|
|
| 17 |
|
## |
| 18 |
|
# countries |
| 19 |
|
## |
| 20 |
if 'countries' not in geo_tool.objectIds(): |
if 'countries' not in geo_tool.objectIds(): |
| 21 |
geo_tool.manage_addPropertySheet('countries', 'Countries') |
geo_tool.manage_addPropertySheet('countries', 'Countries') |
| 22 |
|
|
| 23 |
country_properties = geo_tool.countries |
countries_properties = geo_tool.countries |
| 24 |
|
|
| 25 |
for item in Properties.buildProperties('countries', country_langs, 'country-codes.txt'): |
for item in Properties.buildProperties('countries', countries_langs, 'countries-codes.txt'): |
| 26 |
if country_properties.hasProperty(item[0]): |
if countries_properties.hasProperty(item[0]): |
| 27 |
country_properties._updateProperty(item[0], item[1]) |
countries_properties._updateProperty(item[0], item[1]) |
| 28 |
else: |
else: |
| 29 |
country_properties._setProperty(item[0], item[1], item[2]) |
countries_properties._setProperty(item[0], item[1], item[2]) |
| 30 |
|
|
| 31 |
|
## |
| 32 |
|
# us_states |
| 33 |
|
## |
| 34 |
|
if 'us_states' not in geo_tool.objectIds(): |
| 35 |
|
geo_tool.manage_addPropertySheet('us_states', 'US States') |
| 36 |
|
|
| 37 |
|
us_state_properties = geo_tool.us_states |
| 38 |
|
|
| 39 |
|
for item in Properties.buildProperties('us_states', us_state_langs, 'us_states-codes.txt'): |
| 40 |
|
if us_state_properties.hasProperty(item[0]): |
| 41 |
|
us_state_properties._updateProperty(item[0], item[1]) |
| 42 |
|
else: |
| 43 |
|
us_state_properties._setProperty(item[0], item[1], item[2]) |
| 44 |
|
|
| 45 |
print >> out, "Successfully installed %s." % PROJECTNAME |
print >> out, "Successfully installed %s." % PROJECTNAME |
| 46 |
return out.getvalue() |
return out.getvalue() |