Monday, October 24, 2011

Using PyAMF in the Google Application Engine (Python AMF gateway for Flash Player apps)

Just an update on a prior blog I wrote; I'm using PyAMF in my latest GAE project, and it's working quite successfully. I haven't put it into production yet, but I see no reason why it wouldn't proceed successfully.

PyAMF provides a Google module that makes integrating with a standard GAE startup class very easy. Adding and altering services is just a matter of adding an entry to the services object, and writing the class or method to back it. I use a command pattern, so my service entries look like { 'myservicename' : MyServiceNameClass.execute ( ) }

You can find more about PyAMF (AMF for Python) at their website, www.pyamf.com

As always, thanks for visiting.

Wednesday, October 12, 2011

PyDev and PyAMF; force them to play nice

Short one: I use PyDev for my google GAE efforts.

I used PyAMF as detailed in the PyAMF Google App Engine tutorial (which is braindead easy; just copy the pyamf directory into the base of your GAE project). When added to a vanilla GAE project created with the GAE SDK tool, it worked fine.

But then I created a project in Eclipse with PyDev; it's always worked. But I dumped in the pyamf directory and, although auto complete worked and I could "click into" the pyamf classes after importing, the app wouldn't run; import errors (no such module). I knew it was a pythonpath problem of some kind, but I couldn't figure it out, and I tried everything.

I eventually did this, and it worked; I retried it several times, it seems to be the fix for this sort of thing, possibly any such issue related to using a PyDev project.

Create project in PyDev, but do NOT configure python path (use the "configure later" option), and do NOT configure src directory; just use the base project path. Do all other configs as normal (your GOOGLE_APP_ENGINE config and so on, as if you were doing a usual project).

Then drop your PyAMF directory into the root of your PyDev project folder (remember, you don't have a src directory), doctor up your main.py to use the WebAppGateway and so on, and it finally sees all the imports and works as expected.

No idea what's going on, I'd say there's something going on in the way PyDev interprets paths vs. the way many libraries like PyAmf are set up to do their imports. I'm sure there is an elaborate answer to this involving site-directories and so on, but all I wanted was for my PyDev project to see my PyAMF modules properly, and the above steps, which simplify the PyDev project config drastically, seems to work.

Hope that saves sombody some effort, it killed half a day for me.