aboutsummaryrefslogtreecommitdiff
path: root/tagging/.svn/text-base/__init__.py.svn-base
diff options
context:
space:
mode:
authorSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 11:51:46 -0700
committerSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 11:51:46 -0700
commitd03c8d2d2efaf848b01e96863c29f46ce3a0db21 (patch)
tree2c4ed69f5ad989074264c6dc66b14770664fa9cb /tagging/.svn/text-base/__init__.py.svn-base
parent3b9f21a55fed735652716e63fedabad87899be81 (diff)
downloadpython-django-tagging-d03c8d2d2efaf848b01e96863c29f46ce3a0db21.tar
python-django-tagging-d03c8d2d2efaf848b01e96863c29f46ce3a0db21.tar.gz
Imported Upstream version 0.2.1+svn147upstream/0.2.1+svn147
Diffstat (limited to 'tagging/.svn/text-base/__init__.py.svn-base')
-rw-r--r--tagging/.svn/text-base/__init__.py.svn-base30
1 files changed, 30 insertions, 0 deletions
diff --git a/tagging/.svn/text-base/__init__.py.svn-base b/tagging/.svn/text-base/__init__.py.svn-base
new file mode 100644
index 0000000..9241c20
--- /dev/null
+++ b/tagging/.svn/text-base/__init__.py.svn-base
@@ -0,0 +1,30 @@
+from django.utils.translation import ugettext as _
+
+from tagging.managers import ModelTaggedItemManager, TagDescriptor
+
+VERSION = (0, 3, 'pre')
+
+class AlreadyRegistered(Exception):
+ """
+ An attempt was made to register a model more than once.
+ """
+ pass
+
+registry = []
+
+def register(model, tag_descriptor_attr='tags',
+ tagged_item_manager_attr='tagged'):
+ """
+ Sets the given model class up for working with tags.
+ """
+ if model in registry:
+ raise AlreadyRegistered(
+ _('The model %s has already been registered.') % model.__name__)
+ registry.append(model)
+
+ # Add tag descriptor
+ setattr(model, tag_descriptor_attr, TagDescriptor())
+
+ # Add custom manager
+ ModelTaggedItemManager().contribute_to_class(model,
+ tagged_item_manager_attr)