Re: [Zope] Experiment: Pyjamas with Zope
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jim Washington wrote: > Quick note. > > I found that The "fix pyjamas" question in my previous note could be > handled with a ~100 line python module that makes a new class descending > from pyjamas.HTTPRequest.HTTPRequest, but overriding asyncPostImpl with > a supported content-type, e.g., "application/json". > > The module is mostly copy-paste from pyjamas.JSONService and > pyjamas.HTTPRequest, but I'll provide it to anyone interested. It was > really simple to do. Kudos to pyjamas for making fixes easy. > Please post your findings to the pyjamas ml too http://groups.google.com/group/pyjamas-dev There are already posts related to webpy and django. Would be interesting to add Zope material too. Regards Michael - -- http://blog.d2m.at http://planetzope.org -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFJT5phl0uAvQJUKVYRAt4nAJ9rKAIEt1Mn5gWOfgoZdEK2vQ+nUgCeMWDs T+6CtHvCF+f95isZw7QA2cU= =nbig -END PGP SIGNATURE- ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Experiment: Pyjamas with Zope
Quick note. I found that The "fix pyjamas" question in my previous note could be handled with a ~100 line python module that makes a new class descending from pyjamas.HTTPRequest.HTTPRequest, but overriding asyncPostImpl with a supported content-type, e.g., "application/json". The module is mostly copy-paste from pyjamas.JSONService and pyjamas.HTTPRequest, but I'll provide it to anyone interested. It was really simple to do. Kudos to pyjamas for making fixes easy. - Jim Washington ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Experiment: Pyjamas with Zope
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jim Washington wrote: > So, I have a need to put together a more elaborate web page. Lots of > pop-up dialog boxes and dynamically-updated choice lists. How to do that? > > I take a look at Pyjamas http://pyjs.org. Pretty cool. > > Here's the theory. Write fancy application web page in python using the > Pyjamas/GWT API, then "compile" it to javascript. Serve it through > zope, which will handle auth/auth. Client-server communication flows > through json-rpc calls. What could possibly go wrong? > > First-off, just a simple test-of-concept. Edit the JSONRPCExample.py > file in the examples/jsonrpc folder that came with pyjamas. > > I'll locate the jsonrpc service in zope's containment root, so I change > the uri in EchoServicePython from "/services/EchoService.py" to "/". > That's all I need to change. Compile it using the handy "build.sh" > that's in the same folder. Look in the "output" folder and see what we got. > > Wow. a bunch of files. > > JSONRPCExample.IE6.cache.html > Mozilla.cache.html > OldMoz.cache.html > Opera.cache.html > Safari.cache.html > JSONRPCExample.html > JSONRPCExample.nocache.html > corner_dialog_bottomleft.png > corner_dialog_bottomleft_black.png > corner_dialog_bottomright.png > corner_dialog_bottomright_black.png > corner_dialog_edge.png > corner_dialog_edge_black.png > corner_dialog_topleft.png > corner_dialog_topleft_black.png > corner_dialog_topright.png > corner_dialog_topright_black.png > history.html > pygwt.js > tree_closed.gif > tree_open.gif > tree_white.gif > > I'm lazy, so instead of doing a bunch of resource or view directives in > ZCML, I let my paste.ini do the handling. > > [app:pyjs1] > use=egg:Paste#static > document_root=/home/jwashin/projects/pyjamas/pyjamas-0.4/examples/jsonrpc/output > > then, I link that in with the composite app. > > [composite:Paste.Main] > use = egg:Paste#urlmap > / = zope > /images = images > /pyjs1 = pyjs1 > > Now, to get to JSONRPCExample.html, I need to go to > http://website/pyjs1/JSONRPCExample.html > > But first, I need to actually handle the json-rpc requests in zope. > > Make a servicetest.py. Almost exactly similar to EchoService.py in the > output/services folder. > > from zif.jsonserver.jsonrpc import MethodPublisher > class Services(MethodPublisher): > def echo(self, msg): > return msg > def reverse(self, msg): > return msg[::-1] > def uppercase(self, msg): > return msg.upper() > def lowercase(self, msg): > return msg.lower() > > Now, a ZCML incantation. > > for="zope.app.folder.interfaces.IRootFolder" > permission="zope.Public" > methods="echo reverse uppercase lowercase" > class = ".servicetest.Services" > /> > > Start zope, and go to http://website/pyjs1/JSONRPCExample.html > > Nice page. Click the "Send to Python Service" button. > > Server Error or Invalid Response: ERROR 0 - Server Error or Invalid Response > > Damn. > > Pull up tcpwatch and see what we are getting. Aha. pyjamas app is > sending jsonrpc with a content-type of > application/x-www-form-urlencoded, so zope is not handing it off to > zif.jsonserver for handling. > > Fix pyjamas or let zif.jsonserver handle this content-type? > > In zif.jsonserver's configure.zcml, in the "publisher" directive, add > application/x-www-form-urlencoded to mimetypes. > > Restart zope. Go to http://website/pyjs1/JSONRPCExample.html > > It works. > > Change permissions in the jsonrpc:view directive. Restart zope. > > Go to the page. Page loads. Push the button, and I get a Basic HTTP > Authentication dialog. Nice. > > Overall Results: So far, so good. :) Thanks for the tour. I've been meaning to look at Pyjamas. Tres. - -- === Tres Seaver +1 540-429-0999 tsea...@palladion.com Palladion Software "Excellence by Design"http://palladion.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFJTPQc+gerLs4ltQ4RAn7VAJ93BFtVweq7gYzUT5MddY8os2t6IQCeNyZc fPZjWcVLWSAml/SJI6QerYU= =nGR+ -END PGP SIGNATURE- ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Experiment: Pyjamas with Zope
So, I have a need to put together a more elaborate web page. Lots of pop-up dialog boxes and dynamically-updated choice lists. How to do that? I take a look at Pyjamas http://pyjs.org. Pretty cool. Here's the theory. Write fancy application web page in python using the Pyjamas/GWT API, then "compile" it to javascript. Serve it through zope, which will handle auth/auth. Client-server communication flows through json-rpc calls. What could possibly go wrong? First-off, just a simple test-of-concept. Edit the JSONRPCExample.py file in the examples/jsonrpc folder that came with pyjamas. I'll locate the jsonrpc service in zope's containment root, so I change the uri in EchoServicePython from "/services/EchoService.py" to "/". That's all I need to change. Compile it using the handy "build.sh" that's in the same folder. Look in the "output" folder and see what we got. Wow. a bunch of files. JSONRPCExample.IE6.cache.html Mozilla.cache.html OldMoz.cache.html Opera.cache.html Safari.cache.html JSONRPCExample.html JSONRPCExample.nocache.html corner_dialog_bottomleft.png corner_dialog_bottomleft_black.png corner_dialog_bottomright.png corner_dialog_bottomright_black.png corner_dialog_edge.png corner_dialog_edge_black.png corner_dialog_topleft.png corner_dialog_topleft_black.png corner_dialog_topright.png corner_dialog_topright_black.png history.html pygwt.js tree_closed.gif tree_open.gif tree_white.gif I'm lazy, so instead of doing a bunch of resource or view directives in ZCML, I let my paste.ini do the handling. [app:pyjs1] use=egg:Paste#static document_root=/home/jwashin/projects/pyjamas/pyjamas-0.4/examples/jsonrpc/output then, I link that in with the composite app. [composite:Paste.Main] use = egg:Paste#urlmap / = zope /images = images /pyjs1 = pyjs1 Now, to get to JSONRPCExample.html, I need to go to http://website/pyjs1/JSONRPCExample.html But first, I need to actually handle the json-rpc requests in zope. Make a servicetest.py. Almost exactly similar to EchoService.py in the output/services folder. from zif.jsonserver.jsonrpc import MethodPublisher class Services(MethodPublisher): def echo(self, msg): return msg def reverse(self, msg): return msg[::-1] def uppercase(self, msg): return msg.upper() def lowercase(self, msg): return msg.lower() Now, a ZCML incantation. Start zope, and go to http://website/pyjs1/JSONRPCExample.html Nice page. Click the "Send to Python Service" button. Server Error or Invalid Response: ERROR 0 - Server Error or Invalid Response Damn. Pull up tcpwatch and see what we are getting. Aha. pyjamas app is sending jsonrpc with a content-type of application/x-www-form-urlencoded, so zope is not handing it off to zif.jsonserver for handling. Fix pyjamas or let zif.jsonserver handle this content-type? In zif.jsonserver's configure.zcml, in the "publisher" directive, add application/x-www-form-urlencoded to mimetypes. Restart zope. Go to http://website/pyjs1/JSONRPCExample.html It works. Change permissions in the jsonrpc:view directive. Restart zope. Go to the page. Page loads. Push the button, and I get a Basic HTTP Authentication dialog. Nice. Overall Results: So far, so good. :) - Jim Washington ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )