renamed some exceptions

This commit is contained in:
Blake Eggleston
2012-11-10 19:33:22 -08:00
parent 2aaf1650f3
commit 18f52886e7
4 changed files with 10 additions and 8 deletions

View File

@@ -0,0 +1,3 @@
from cassandraengine.columns import *
from cassandraengine.models import Model

View File

@@ -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

View File

@@ -1,4 +1,4 @@
#cassandraengine exceptions
class ColumnFamilyException(BaseException): pass
class ModelException(BaseException): pass
class ValidationError(BaseException): pass

View File

@@ -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