"""Helper functions Consists of functions to typically be used within templates, but also available to Controllers. This module is available to templates as 'h'. """ # Import helpers as desired, or define your own, ie: #from webhelpers.html.tags import checkbox, password from pylons import url import wrpylib.wrvalidators from webhelpers.html.tags import file, form, end_form, submit def wiki(page_title=None): "Creates a link to the specified page in the www.winterrodeln.org wiki" if page_title is None: page_title = 'Hauptseite' return 'http://www.winterrodeln.org/wiki/' + page_title def forum(forum=None): "Creates a link to the specified forum. If no id is given, a general link is created." if forum is None: return 'http://winterrodeln-forum.org/' return 'http://winterrodeln-forum.org/viewforum.php?f=%d' % forum def google_maps(latitude, longitude): "Builds an URL like http://maps.google.at/maps?q=47.200607,11.260007" return "http://maps.google.at/maps?q=%.6f,%.6f" % (latitude, longitude) def bool(value): "Takes a bool value and creates a German representation" return wrpylib.wrvalidators.GermanBoolNone().from_python(value) def tristate_tuple(yes, no): "Takes a German representation of a tristate value" return wrpylib.wrvalidators.GermanTristateTuple().from_python((yes, no)) def tristate_float(value): "Takes a German representation of a tristate value" return wrpylib.wrvalidators.GermanTristateFloat().from_python(value) def public_transport(value): if isinstance(value, int): value = int(value) return wrpylib.wrvalidators.GermanPublicTransport().from_python(value)