'Resolve INTERSECTS into a DAL expression;
will be ignored for non-spatial DBs
@param l: the left operand (Field)
@param r: the right operand'

def _query_intersects(self, l, r):

    if current.deployment_settings.get_gis_spatialdb():
        expr = None
        if (str(l.type)[:3] == 'geo'):
            if isinstance(r, basestring):
                from shapely.wkt import loads as wkt_loads
                try:
                    wkt_loads(r)
                except Exception:
                    current.log.error(('INTERSECTS:    %s' % sys.exc_info()[1]))
                else:
                    expr = l.st_intersects(r)
            elif (hasattr(r, type) and (str(r.type)[:3] == 'geo')):
                expr = l.st_intersects(r)
        if (expr is None):
            return l.belongs(set())
    else:
        expr = False
    return expr
