Changeset 369

Show
Ignore:
Timestamp:
07/05/06 03:41:54
Author:
chervol
Message:

added geolocation edit tab for content types

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • geolocation/trunk/Extensions/Install.py

    r368 r369  
    33from Products.CMFCore.utils import getToolByName 
    44 
     5PORTAL_TYPES = ['Document', 'News Item', 'Event', 'Link', 'Image'] 
    56 
     7def installGEOLocationAction(self): 
     8    """ add geoLocation edit tab for content types """ 
     9    ptypes = getToolByName(self, 'portal_types') 
     10    for tname in PORTAL_TYPES: 
     11        type = ptypes.getTypeInfo(tname) 
     12        type.addAction('edit_location', 
     13                      name='GEO Location', 
     14                      action='string:edit_location', 
     15                      condition='', 
     16                      permission='Modify portal content', 
     17                      category='object') 
     18 
     19def uninstallGEOLocationAction(self): 
     20    """ remove geoLocation edit tab for content types """ 
     21    ptypes = getToolByName(self, 'portal_types') 
     22    for tname in PORTAL_TYPES: 
     23        type = ptypes.getTypeInfo(tname) 
     24        actions = type._cloneActions() 
     25        actions = [a for a in actions if a.id != 'edit_location'] 
     26        type._actions = tuple(actions) 
    627 
    728def install(self): 
     
    930    out = StringIO() 
    1031    catalog = getToolByName(self, 'portal_catalog') 
    11     catalog.addIndex('geoLocation','FieldIndex') 
    12     catalog.addColumn('geoLocation') 
     32    if 'geoLocation' not in catalog.indexes: 
     33        catalog.addIndex('geoLocation','FieldIndex') 
     34    if 'geoLocation' not in catalog.schema: 
     35        catalog.addColumn('geoLocation') 
    1336    out.write('geoLocation index created') 
     37    installGEOLocationAction(self) 
     38    out.write('Added geolocation edit for content types') 
    1439    return out.getvalue() 
    1540 
     41def uninstall(self): 
     42    out = StringIO() 
     43    uninstallGEOLocationAction(self) 
     44    out.write('Removed geolocation edit for content types') 
  • geolocation/trunk/adapter.py

    r368 r369  
    3232    def setLongitude(self, value): 
    3333        """ set longtitude """ 
    34         self.geolocation['longitude'] = value 
     34        self.geolocation['longitude'] = float(value) 
    3535   
    3636    def setLatitude(self, value): 
    3737        """ set latitutde """ 
    38         self.geolocation['latitude'] = value 
     38        self.geolocation['latitude'] = float(value) 
    3939     
    4040    def setLocation(self, longitude, latitude): 
    4141        """ set location """ 
    42         self.geolocation['longitude'] = longitude 
    43         self.geolocation['latitude'] = latitude 
     42        self.geolocation['longitude'] = float(longitude) 
     43        self.geolocation['latitude'] = float(latitude) 
    4444         
    4545default = None