source: products/geolocation/trunk/skins/geolocation/validate_location.vpy @ 3664

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

Building directory structure

  • Property svn:eol-style set to native
File size: 900 bytes
Line 
1## Controller Script Python "validate_location"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind state=state
7##bind subpath=traverse_subpath
8##parameters= latitude=None, longitude=None
9##title=
10
11from Products.CMFCore.utils import getToolByName
12from Products.CMFPlone import PloneMessageFactory as _
13
14plone_utils = getToolByName(context, 'plone_utils')
15
16try:
17    float(latitude)
18    float(longitude)
19except:
20    state.setError('latitude', _('For saving select your location point on the map'))
21    return state.set(status='failure')
22
23if  not (-90 <= float(latitude) <= 90):
24    state.setError('latitude', _('Latitude is not in bounds [-90, 90]'))
25
26if  not (-180 <= float(longitude) <= 180):
27    state.setError('longitude', _('Longitude is not in bounds [-180, 180]'))
28
29if state.getErrors():
30    return state.set(status='failure')
31else:
32    return state
33
Note: See TracBrowser for help on using the repository browser.