AlterEgo
old web2py blog
Useful Links
List all entries
Book
Interactive Examples
F.A.Q.
Free Applications
Plugins
Recipes
Demo of Admin Interface
Semantic web extension
Some of the information here may be outdated, please check the book instead
Edit page
Title:
Security Code:
Body:
(use
this
wiki markup)
From Fran. validators for LATITUDE and LONGITUDE class IS_LAT(object): """ example: INPUT(_type='text',_name='name',requires=IS_LAT()) latitude has to be in degrees between -90 & 90 """ def __init__(self, error_message='Latitude/Northing should be between -90 & 90!'): self.minimum=-90 self.maximum=90 self.error_message = error_message def __call__(self, value): try: value = float(value) if self.minimum <= value <= self.maximum: return (value,None) except ValueError: pass return (value, self.error_message) class IS_LON(object): """ example: INPUT(_type='text',_name='name',requires=IS_LON()) longitude has to be in degrees between -180 & 180 """ def __init__(self, error_message='Longitude/Easting should be between -180 & 180!'): self.minimum=-180 self.maximum=180 self.error_message = error_message def __call__(self, value): try: value = float(value) if self.minimum <= value <= self.maximum: return (value,None) except ValueError: pass return (value, self.error_message)
© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by
web2py
- design derived from a theme by
the earlybird
The content of this book is released under the
Artistic License 2.0
- Modified content cannot be reproduced.