diff --git a/cassandraengine/__init__.py b/cassandraengine/__init__.py index e69de29b..af95d0b0 100644 --- a/cassandraengine/__init__.py +++ b/cassandraengine/__init__.py @@ -0,0 +1,3 @@ +from cassandraengine.columns import * +from cassandraengine.models import Model + diff --git a/cassandraengine/columns.py b/cassandraengine/columns.py index 7c90f558..747cfba9 100644 --- a/cassandraengine/columns.py +++ b/cassandraengine/columns.py @@ -5,9 +5,6 @@ from uuid import uuid1, uuid4 from cassandraengine.exceptions import ValidationError class BaseColumn(object): - """ - The base column - """ #the cassandra type this column maps to db_type = None diff --git a/cassandraengine/exceptions.py b/cassandraengine/exceptions.py index a6851887..4b20f7a3 100644 --- a/cassandraengine/exceptions.py +++ b/cassandraengine/exceptions.py @@ -1,4 +1,4 @@ #cassandraengine exceptions -class ColumnFamilyException(BaseException): pass +class ModelException(BaseException): pass class ValidationError(BaseException): pass diff --git a/cassandraengine/models.py b/cassandraengine/models.py index c3fce738..4e5bd9d3 100644 --- a/cassandraengine/models.py +++ b/cassandraengine/models.py @@ -1,6 +1,6 @@ from cassandraengine import columns -from cassandraengine.exceptions import ColumnFamilyException +from cassandraengine.exceptions import ModelException from cassandraengine.manager import Manager class BaseModel(object): @@ -8,6 +8,8 @@ class BaseModel(object): The base model class, don't inherit from this, inherit from Model, defined below """ + #table names will be generated automatically from it's model name and package + #however, you can alse define them manually here db_name = None def __init__(self, **values): @@ -75,7 +77,7 @@ class ModelMetaClass(type): if isinstance(v, columns.BaseColumn): if v.is_primary_key: if pk_name: - raise ColumnFamilyException("More than one primary key defined for {}".format(name)) + raise ModelException("More than one primary key defined for {}".format(name)) pk_name = k _columns[k] = attrs.pop(k) _columns[k].set_db_name(k) @@ -96,8 +98,8 @@ class ModelMetaClass(type): col_names = set() for k,v in _columns.items(): if v.db_field in col_names: - raise ColumnFamilyException("{} defines the column {} more than once".format(name, v.db_field)) - col_names.add(k) + raise ModelException("{} defines the column {} more than once".format(name, v.db_field)) + col_names.add(v.db_field) #get column family name cf_name = attrs.pop('db_name', None) or name