<s> import os <EOL> from django . db import connection <EOL> from django . contrib . gis . db . models import GeoManager <EOL> from django . contrib . gis . db . models . sql import GeoQuery <EOL> from django . contrib . gis . db . models . query import GeoQuerySet <EOL> from timeit import time <EOL> from djmapnik . adapter import PostgisLayer <EOL> class MapnikQuerySet ( GeoQuerySet ) : <EOL> def __init__ ( self , model = None , query = None , using = None ) : <EOL> super ( MapnikQuerySet , self ) . __init__ ( model = model , query = query , using = using ) <EOL> try : <EOL> self . query = query or GeoQuery ( self . model ) <EOL> except TypeError : <EOL> self . query = query or GeoQuery ( self . model , connection ) <EOL> def show ( self , ** kwargs ) : <EOL> timeit = kwargs . get ( '<STR_LIT>' ) <EOL> if timeit : <EOL> start = time . time ( ) <EOL> lyr_adapter = PostgisLayer ( self ) <EOL> lyr_adapter . show ( ** kwargs ) <EOL> if timeit : <EOL> elapsed = ( time . time ( ) - start ) / <NUM_LIT> <EOL> print '<STR_LIT>' % elapsed <EOL> class MapnikManager ( GeoManager ) : <EOL> def get_query_set ( self ) : <EOL> qs = MapnikQuerySet ( model = self . model ) <EOL> if self . _db is not None : <EOL> qs = qs . using ( self . _db ) <EOL> return qs <EOL> def show ( self , ** kwargs ) : <EOL> return self . get_query_set ( ) . show ( ** kwargs ) </s>
