app/django/contrib/gis/db/backend/base.py
author Mario Ferraro <fadinlight@gmail.com>
Sun, 15 Nov 2009 22:12:20 +0100
changeset 3093 d1be59b6b627
parent 323 ff1a9aa48cfd
permissions -rw-r--r--
GMaps related JS changed to use new google namespace. Google is going to change permanently in the future the way to load its services, so better stay safe. Also this commit shows uses of the new melange.js module. Fixes Issue 634.

"""
 This module holds the base `SpatialBackend` object, which is
 instantiated by each spatial backend with the features it has.
"""
# TODO: Create a `Geometry` protocol and allow user to use
# different Geometry objects -- for now we just use GEOSGeometry.
from django.contrib.gis.geos import GEOSGeometry, GEOSException

class BaseSpatialBackend(object):
    Geometry = GEOSGeometry
    GeometryException = GEOSException

    def __init__(self, **kwargs):
        kwargs.setdefault('distance_functions', {})
        kwargs.setdefault('limited_where', {})
        for k, v in kwargs.iteritems(): setattr(self, k, v)
 
    def __getattr__(self, name):
        """
        All attributes of the spatial backend return False by default.
        """
        try:
            return self.__dict__[name]
        except KeyError:
            return False