[Checkins] SVN: grok/branches/timte-json/src/grok/ Added handling
for arguments to the json method.
Tim TerlegÃÂ¥rd
tim.terlegard at lovelysystems.com
Mon Mar 19 16:54:59 EDT 2007
Log message for revision 73358:
Added handling for arguments to the json method.
Changed:
U grok/branches/timte-json/src/grok/components.py
U grok/branches/timte-json/src/grok/meta.py
-=-
Modified: grok/branches/timte-json/src/grok/components.py
===================================================================
--- grok/branches/timte-json/src/grok/components.py 2007-03-19 20:24:14 UTC (rev 73357)
+++ grok/branches/timte-json/src/grok/components.py 2007-03-19 20:54:58 UTC (rev 73358)
@@ -17,6 +17,7 @@
import os
import persistent
import urllib
+import simplejson
from zope import component
from zope import interface
@@ -221,8 +222,13 @@
pass
class JSON(BrowserPage):
- pass
+ def __call__(self, *args):
+ view_name = self.__view_name__
+ method = getattr(self, view_name)
+ method_result = mapply(method, (), self.request)
+ return simplejson.dumps(method_result)
+
class GrokPageTemplate(object):
def __repr__(self):
Modified: grok/branches/timte-json/src/grok/meta.py
===================================================================
--- grok/branches/timte-json/src/grok/meta.py 2007-03-19 20:24:14 UTC (rev 73357)
+++ grok/branches/timte-json/src/grok/meta.py 2007-03-19 20:54:58 UTC (rev 73358)
@@ -235,7 +235,7 @@
for method in methods:
method_view = type(
factory.__name__, (factory,),
- {'__call__': method}
+ {'__view_name__': method.__name__}
)
component.provideAdapter(
method_view, (view_context, IDefaultBrowserLayer),
More information about the Checkins
mailing list