Last change
on this file since 1 was
1,
checked in by myroslav, 19 years ago
|
Building directory structure
|
-
Property svn:eol-style set to
native
|
File size:
900 bytes
|
Rev | Line | |
---|
[1] | 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 | |
---|
| 11 | from Products.CMFCore.utils import getToolByName |
---|
| 12 | from Products.CMFPlone import PloneMessageFactory as _ |
---|
| 13 | |
---|
| 14 | plone_utils = getToolByName(context, 'plone_utils') |
---|
| 15 | |
---|
| 16 | try: |
---|
| 17 | float(latitude) |
---|
| 18 | float(longitude) |
---|
| 19 | except: |
---|
| 20 | state.setError('latitude', _('For saving select your location point on the map')) |
---|
| 21 | return state.set(status='failure') |
---|
| 22 | |
---|
| 23 | if not (-90 <= float(latitude) <= 90): |
---|
| 24 | state.setError('latitude', _('Latitude is not in bounds [-90, 90]')) |
---|
| 25 | |
---|
| 26 | if not (-180 <= float(longitude) <= 180): |
---|
| 27 | state.setError('longitude', _('Longitude is not in bounds [-180, 180]')) |
---|
| 28 | |
---|
| 29 | if state.getErrors(): |
---|
| 30 | return state.set(status='failure') |
---|
| 31 | else: |
---|
| 32 | return state |
---|
| 33 | |
---|
Note: See
TracBrowser
for help on using the repository browser.