Example #1
0
    def hkeys(self, attr):
        return self.get_query_set().hkeys(attr)

    def hpeek(self, attr, key):
        return self.get_query_set().hpeek(attr, key)

    def hslice(self, attr, keys, **params):
        return self.get_query_set().hslice(attr, keys)


class HStoreManager(HStoreManagerMixin, ExpressionManagerMixin, models.Manager):
    def get_query_set(self):
        return HStoreQueryset(self.model, using=self._db)


# Signal attaching
from psycopg2.extras import register_hstore


def register_hstore_handler(connection, **kwargs):
    if sys.version_info[0] < 3:
        register_hstore(connection.cursor(), globally=True, unicode=True)
    else:
        register_hstore(connection.cursor(), globally=True)


from djorm_core.models import connection_handler

connection_handler.attach_handler(register_hstore_handler, vendor="postgresql", unique=True)
Example #2
0
# -*- coding: utf-8 -*-

def register_geometric_types(connection, **kwargs):
    from . import objects

    for objectname in objects.__all__:
        obj_class = getattr(objects, objectname)
        obj_class.register_cast(connection)
        obj_class.register_adapter()
        print "Registering:", obj_class.__name__


from djorm_core.models import connection_handler
connection_handler.attach_handler(register_geometric_types, vendor="postgresql", unique=True)
Example #3
0
    use_for_related_fields = True

    def hkeys(self, attr):
        return self.get_query_set().hkeys(attr)

    def hpeek(self, attr, key):
        return self.get_query_set().hpeek(attr, key)

    def hslice(self, attr, keys, **params):
        return self.get_query_set().hslice(attr, keys)


class HStoreManager(HStoreManagerMixin, ExpressionManagerMixin, models.Manager):
    def get_query_set(self):
        return HStoreQueryset(self.model, using=self._db)


# Signal attaching
from psycopg2.extras import register_hstore

def register_hstore_handler(connection, **kwargs):
    if not connection.settings_dict.get('HAS_HSTORE', True):
        return
    if sys.version_info[0] < 3:
        register_hstore(connection.connection, globally=True, unicode=True)
    else:
        register_hstore(connection.connection, globally=True)

from djorm_core.models import connection_handler
connection_handler.attach_handler(register_hstore_handler, vendor="postgresql", unique=True)
Example #4
0
# -*- coding: utf-8 -*-


def register_geometric_types(connection, **kwargs):
    from . import objects

    for objectname in objects.__all__:
        obj_class = getattr(objects, objectname)
        obj_class.register_cast(connection)
        obj_class.register_adapter()
        print "Registering:", obj_class.__name__


from djorm_core.models import connection_handler
connection_handler.attach_handler(register_geometric_types,
                                  vendor="postgresql",
                                  unique=True)