cleaning things up a bit

This commit is contained in:
Blake Eggleston
2012-11-11 22:14:40 -08:00
parent 142ceb184c
commit 83cf23da7c
5 changed files with 24 additions and 11 deletions

View File

@@ -1,22 +1,21 @@
cassandraengine cassandraengine
=============== ===============
Python Cassandra ORM in the style of django / mongoengine Cassandra ORM for Python in the style of the Django orm and mongoengine
In it's current state you can define column families, create and delete column families In it's current state you can define column families, create and delete column families
based on your model definiteions, save models and retrieve models by their primary keys. based on your model definiteions, save models and retrieve models by their primary keys.
That's about it. Also, the CQL stuff is pretty simple at this point. That's about it. Also, the CQL stuff is very basic at this point.
##TODO ##TODO
* Complex queries (class Q(object)) * Real querying
* Match column names to mongoengine field names?
* mongoengine fields? URLField, EmbeddedDocument, ListField, DictField * mongoengine fields? URLField, EmbeddedDocument, ListField, DictField
* column ttl? * column ttl?
* ForeignKey/DBRef fields? * ForeignKey/DBRef fields?
* dynamic column support * dynamic column support
* tests
* query functionality * query functionality
* Match column names to mongoengine field names?
* nice column and model class __repr__ * nice column and model class __repr__

View File

@@ -197,11 +197,16 @@ class Counter(BaseColumn):
#TODO: research supercolumns #TODO: research supercolumns
#http://wiki.apache.org/cassandra/DataModel #http://wiki.apache.org/cassandra/DataModel
class List(BaseColumn): class List(BaseColumn):
#checkout cql.cqltypes.ListType
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(DateTime, self).__init__(**kwargs) super(DateTime, self).__init__(**kwargs)
raise NotImplementedError raise NotImplementedError
class Dict(BaseColumn): class Dict(BaseColumn):
#checkout cql.cqltypes.MapType
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(DateTime, self).__init__(**kwargs) super(DateTime, self).__init__(**kwargs)
raise NotImplementedError raise NotImplementedError
#checkout cql.cqltypes.SetType
#checkout cql.cqltypes.CompositeType

View File

@@ -23,9 +23,7 @@ class Manager(object):
return cf_name return cf_name
def __call__(self, **kwargs): def __call__(self, **kwargs):
""" """ filter shortcut """
filter shortcut
"""
return self.filter(**kwargs) return self.filter(**kwargs)
def find(self, pk): def find(self, pk):
@@ -71,9 +69,7 @@ class Manager(object):
QuerySet(self.model).save(instance) QuerySet(self.model).save(instance)
def _delete_instance(self, instance): def _delete_instance(self, instance):
""" """ Deletes a single instance """
Deletes a single instance
"""
QuerySet(self.model).delete_instance(instance) QuerySet(self.model).delete_instance(instance)
#----column family create/delete---- #----column family create/delete----

View File

@@ -119,11 +119,13 @@ class ModelMetaClass(type):
for name, col in _columns.items(): for name, col in _columns.items():
db_map[col.db_field] = name db_map[col.db_field] = name
#add management members to the class
attrs['_columns'] = _columns attrs['_columns'] = _columns
attrs['_db_map'] = db_map attrs['_db_map'] = db_map
attrs['_pk_name'] = pk_name attrs['_pk_name'] = pk_name
attrs['_dynamic_columns'] = {} attrs['_dynamic_columns'] = {}
#create the class and add a manager to it
klass = super(ModelMetaClass, cls).__new__(cls, name, bases, attrs) klass = super(ModelMetaClass, cls).__new__(cls, name, bases, attrs)
klass.objects = Manager(klass) klass.objects = Manager(klass)
return klass return klass

View File

@@ -2,11 +2,22 @@ import copy
from cassandraengine.connection import get_connection from cassandraengine.connection import get_connection
#CQL 3 reference:
#http://www.datastax.com/docs/1.1/references/cql/index
class Query(object):
pass
class QuerySet(object): class QuerySet(object):
#TODO: querysets should be immutable #TODO: querysets should be immutable
#TODO: querysets should be executed lazily #TODO: querysets should be executed lazily
#TODO: conflicting filter args should raise exception unless a force kwarg is supplied #TODO: conflicting filter args should raise exception unless a force kwarg is supplied
#CQL supports ==, >, >=, <, <=, IN (a,b,c,..n)
#REVERSE, LIMIT
#ORDER BY
def __init__(self, model, query_args={}): def __init__(self, model, query_args={}):
super(QuerySet, self).__init__() super(QuerySet, self).__init__()
self.model = model self.model = model