gaetk2.helpers module

gaetk2.helpers provides support for writing more concise, elegant code for gaetk2.

Module contents

gaetk2.helpers.check404(obj, message='Object not found.')[source]

Raises 404 if bool(obj) is False.

The major usecase is to replace:

def post(self, kundennr):
    kunde = m_api.get_kunde(kundennr)
    if not kunde:
        raise HTTP404_NotFound
    do_some_work()

with:

def post(self, kundennr):
    kunde = check404(m_api.get_kunde(kundennr))
    do_some_work()

This has the potential to make view-Functions much more readable.

gaetk2.helpers.abs_url(url)[source]

Convert a relative URL to an absolute URL.

You really should prefer gaetk2.handler.base.BasicHandler.abs_url() because it has better information about the request and host.