'Helper routine for calling PostGIS functions and returning their result.'

def _get_postgis_func(self, func):

    cursor = self.connection._cursor()
    try:
        cursor.execute(('SELECT    %s()' % func))
        row = cursor.fetchone()
    except:
        raise
    finally:
        self.connection.close()
    return row[0]
