~canonical-django/canonical-django/project-template

« back to all changes in this revision

Viewing changes to trunk/python-packages/django/contrib/gis/db/backend/base.py

  • Committer: Matthew Nuzum
  • Date: 2008-11-13 05:46:03 UTC
  • Revision ID: matthew.nuzum@canonical.com-20081113054603-v0kvr6z6xyexvqt3
adding to version control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
            
 
27
        
 
28
        
 
29