diff MoinMoin/items/content.py @ 1648:1a2c53092ea1

items/content.py: Implement Content.create.
author Cheer Xiao <xiaqqaix@gmail.com>
date Wed, 08 Aug 2012 22:48:14 +0800
parents 8f0a17a04e60
children 5dc142ab43d2
line wrap: on
line diff
--- a/MoinMoin/items/content.py	Wed Aug 08 22:46:42 2012 +0800
+++ b/MoinMoin/items/content.py	Wed Aug 08 22:48:14 2012 +0800
@@ -120,6 +120,12 @@
     def _factory(cls, *args, **kw):
         return cls(*args, **kw)
 
+    @classmethod
+    def create(cls, contenttype, item=None):
+        content = content_registry.get(contenttype, item)
+        logging.debug("Content class {0!r} handles {1!r}".format(content.__class__, contenttype))
+        return content
+
     def __init__(self, contenttype, item=None):
         # We need to keep the exact contenttype since contents may be handled
         # by a Content subclass with wildcard contenttype (eg. an unknown