[Twisted-web] Revamped ContextSerializer/TagSerializer and other contextish stuff

James Y Knight twisted-web@twistedmatrix.com
Fri, 6 Feb 2004 17:58:20 -0500


--Apple-Mail-4--983146798
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

Fixes directive() used as a render function, which the previous broke. 
Apparently there are no tests for that.

Also adjusts components.wsv which I forgot in the last patch.

James


--Apple-Mail-4--983146798
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name="nevow3-fix.patch"
Content-Disposition: attachment;
	filename=nevow3-fix.patch

Index: accessors.py
===================================================================
RCS file: /cvs/Quotient/nevow/accessors.py,v
retrieving revision 1.4
diff -u -r1.4 accessors.py
--- accessors.py	13 Dec 2003 00:40:25 -0000	1.4
+++ accessors.py	6 Feb 2004 22:52:06 -0000
@@ -31,7 +31,7 @@
         container = IContainer(data, None, persist=False)
         if container is None:
             raise NoAccessor, "%s does not implement IContainer, and there is no registered adapter." % data
-        child = container.child(context, self.original)
+        child = container.child(context, self.original.name)
         return convertToData(context, child)
 
     def child(self, context, name):
Index: stan.py
===================================================================
RCS file: /cvs/Quotient/nevow/stan.py,v
retrieving revision 1.19
diff -u -r1.19 stan.py
--- stan.py	6 Feb 2004 21:21:51 -0000	1.19
+++ stan.py	6 Feb 2004 22:52:06 -0000
@@ -27,13 +27,15 @@
     __slots__ = []
 
 
-class directive(str):
+class directive(object):
     """Marker for a directive in a template
     """
-    __slots__ = []
-
+    __slots__ = ['name']
+    def __init__(self, name):
+        self.name = name
+        
     def __repr__(self):
-        return "directive('%s')" % self
+        return "directive('%s')" % self.name
 
 
 class Tag(object):
Index: components.wsv
===================================================================
RCS file: /cvs/Quotient/nevow/components.wsv,v
retrieving revision 1.25
diff -u -r1.25 components.wsv
--- components.wsv	13 Jan 2004 01:46:40 -0000	1.25
+++ components.wsv	6 Feb 2004 22:52:06 -0000
@@ -23,7 +23,7 @@
 nevow.serial.flatstan.TagSerializer                 nevow.stan.Tag                  nevow.iwoven.ISerializable
 nevow.serial.flatstan.CommentSerializer             nevow.stan.Comment              nevow.iwoven.ISerializable
 nevow.serial.flatstan.StringSerializer              types.StringType                nevow.iwoven.ISerializable
-nevow.serial.flatstan.StringSerializer              types.UnicodeType               nevow.iwoven.ISerializable
+nevow.serial.flatstan.UTF8Serializer                types.UnicodeType               nevow.iwoven.ISerializable
 nevow.serial.flatstan.NoneWarningSerializer         types.NoneType                  nevow.iwoven.ISerializable
 nevow.serial.flatstan.StringCastSerializer          types.FloatType                 nevow.iwoven.ISerializable
 nevow.serial.flatstan.StringCastSerializer          types.LongType                  nevow.iwoven.ISerializable
Index: serial/flatstan.py
===================================================================
RCS file: /cvs/Quotient/nevow/serial/flatstan.py,v
retrieving revision 1.24
diff -u -r1.24 flatstan.py
--- serial/flatstan.py	6 Feb 2004 21:21:51 -0000	1.24
+++ serial/flatstan.py	6 Feb 2004 22:52:06 -0000
@@ -169,8 +169,10 @@
     return FunctionSerializer(original, context, nocontext)
 
 def DirectiveSerializer(original, context):
+    if context.precompile:
+        return original
     rendererFactory = context.locate(IRendererFactory)
-    renderer = rendererFactory.renderer(context, original)
+    renderer = rendererFactory.renderer(context, original.name)
     return serialize(renderer, context)
 
 
return serialize(renderer, context)
 
 

--Apple-Mail-4--983146798--