web/lib/django/contrib/gis/db/backend/base.py
changeset 29 cc9b7e14412b
parent 28 b758351d191f
child 30 239f9bcae806
equal deleted inserted replaced
28:b758351d191f 29:cc9b7e14412b
     1 """
       
     2  This module holds the base `SpatialBackend` object, which is
       
     3  instantiated by each spatial backend with the features it has.
       
     4 """
       
     5 # TODO: Create a `Geometry` protocol and allow user to use
       
     6 # different Geometry objects -- for now we just use GEOSGeometry.
       
     7 from django.contrib.gis.geos import GEOSGeometry, GEOSException
       
     8 
       
     9 class BaseSpatialBackend(object):
       
    10     Geometry = GEOSGeometry
       
    11     GeometryException = GEOSException
       
    12 
       
    13     def __init__(self, **kwargs):
       
    14         kwargs.setdefault('distance_functions', {})
       
    15         kwargs.setdefault('limited_where', {})
       
    16         for k, v in kwargs.iteritems(): setattr(self, k, v)
       
    17  
       
    18     def __getattr__(self, name):
       
    19         """
       
    20         All attributes of the spatial backend return False by default.
       
    21         """
       
    22         try:
       
    23             return self.__dict__[name]
       
    24         except KeyError:
       
    25             return False
       
    26