changeset 1819:38632887ca57

Make RegistryContent.register accept an Entry and group name for slightly cleaner code.
author Cheer Xiao <xiaqqaix@gmail.com>
date Mon, 01 Oct 2012 23:38:17 +0800
parents a38ad19c9e7c
children 243ce99c0e32 8231bca193ef
files MoinMoin/items/content.py
diffstat 1 files changed, 4 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/items/content.py	Mon Oct 01 15:33:12 2012 +0800
+++ b/MoinMoin/items/content.py	Mon Oct 01 23:38:17 2012 +0800
@@ -94,15 +94,12 @@
         self.group_names = group_names
         self.groups = dict([(g, []) for g in group_names])
 
-    def register(self, factory, contenttype, default_contenttype_params, display_name, group, ingroup_order, priority=RegistryBase.PRIORITY_MIDDLE):
+    def register(self, e, group):
         """
-        Register a factory
-
-        :param factory: Factory to register. Callable, must return an object.
+        Register a contenttype entry and optionally add it to a specific group.
         """
-        e = self.Entry(factory, contenttype, default_contenttype_params, display_name, ingroup_order, priority)
         # If group is specified and contenttype is not a wildcard one
-        if group and contenttype.type and contenttype.subtype:
+        if group and e.content_type.type and e.content_type.subtype:
             if group not in self.groups:
                 raise ValueError('Unknown group name: {0}'.format(group))
             self.groups[group].append(e)
@@ -121,7 +118,7 @@
 ])
 
 def register(cls):
-    content_registry.register(cls._factory, Type(cls.contenttype), cls.default_contenttype_params, cls.display_name, cls.group, cls.ingroup_order)
+    content_registry.register(RegistryContent.Entry(cls._factory, Type(cls.contenttype), cls.default_contenttype_params, cls.display_name, cls.ingroup_order, RegistryContent.PRIORITY_MIDDLE), cls.group)
     return cls