Permalink
Browse files

moved exceptions into common module

  • Loading branch information...
1 parent e59010a commit c2ec37c838d37fb4d609e8f926c7cf23b8db96b8 @piquadrat piquadrat committed Mar 20, 2012
Showing with 12 additions and 9 deletions.
  1. +8 −0 cmsplugin_text_ng/exceptions.py
  2. +4 −9 cmsplugin_text_ng/type_registry.py
@@ -0,0 +1,8 @@
+# -*- coding: utf-8 -*-
+
+class VariableTypeAlreadyRegistered(Exception):
+ pass
+
+
+class InvalidType(Exception):
+ pass
@@ -1,13 +1,8 @@
# -*- coding: utf-8 -*-
-_registry = {}
-
-class VariableTypeAlreadyRegistered(Exception):
- pass
+from cmsplugin_text_ng import exceptions
-
-class InvalidType(Exception):
- pass
+_registry = {}
def register_type(type_name, model_class):
from cmsplugin_text_ng.models import TextNGVariableBase
@@ -16,11 +11,11 @@ def register_type(type_name, model_class):
# already registered
return
else:
- raise VariableTypeAlreadyRegistered(
+ raise exceptions.VariableTypeAlreadyRegistered(
'The type "%s" is already registered by %s' % (type_name, _registry[type_name].__name__)
)
if not issubclass(model_class, TextNGVariableBase):
- raise InvalidType('%s is not a subclass of TextNGVariableBase' % model_class.__name__)
+ raise exceptions.InvalidType('%s is not a subclass of TextNGVariableBase' % model_class.__name__)
# TODO: validate that there is a "value" field that is nullable
_registry[type_name] = model_class

0 comments on commit c2ec37c

Please sign in to comment.