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
===============
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
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
* Complex queries (class Q(object))
* Match column names to mongoengine field names?
* Real querying
* mongoengine fields? URLField, EmbeddedDocument, ListField, DictField
* column ttl?
* ForeignKey/DBRef fields?
* dynamic column support
* tests
* query functionality
* Match column names to mongoengine field names?
* nice column and model class __repr__

View File

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

View File

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

View File

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

View File

@@ -2,11 +2,22 @@ import copy
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):
#TODO: querysets should be immutable
#TODO: querysets should be executed lazily
#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={}):
super(QuerySet, self).__init__()
self.model = model