source: products/qPloneGoogleMaps/tags/0.1.0/field.py

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

Building directory structure

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1from ZPublisher import HTTPRequest
2from AccessControl import ClassSecurityInfo
3from Products.Archetypes import atapi
4from Products.Archetypes.Widget import TypesWidget
5from Products.Archetypes.Registry import registerField, registerWidget
6
7
8class MapWidget(TypesWidget):
9
10    _properties = TypesWidget._properties.copy()
11    _properties.update({
12        'type': 'map',
13        'macro': 'map_widget',
14    })
15
16    security = ClassSecurityInfo()
17
18    security.declarePublic('process_form')
19    def process_form(self, instance, field, form, empty_marker=None, emptyReturnsMarker=False):
20        """ create tuple from latitude and longitude """
21        latitude = form.get('%s_latitude' % field.getName(), empty_marker)
22        longitude = form.get('%s_longitude' % field.getName(), empty_marker)
23        try:
24            latitude = float(latitude)
25            longitude = float(longitude)
26        except: pass
27        return (latitude, longitude),  {}
28
29
30class MapField(atapi.ObjectField):
31
32    _properties = atapi.ObjectField._properties.copy()
33    _properties.update({
34        'widget'  : MapWidget,
35        'default' : None,
36    })
37
38registerWidget(
39    MapWidget,
40    title='Map Coordinates',
41    used_for=('Products.field.MapField',)
42    )
43
44registerField(
45    MapField,
46    title="MapField",
47    description=("Field that can store coordinate information (longitude, latitude)"
48                 "on the map")
49    )
Note: See TracBrowser for help on using the repository browser.