Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Learning application documented and published  (Read 2674 times)
facorreia
Newbie
*
Posts: 9


View Profile Email
« on: July 30, 2008, 04:51:21 »

I am learning PureMVC and I hope to use it to build a Flex client that will talk to a Python service hosted on Google App Engine.

I am documenting the progress in my blog:

http://fernandoacorreia.wordpress.com/2008/07/30/flex-client-using-puremvc/

The source code of the application is published too.

This is not a full-blown example yet because it is a work in progress and I still have to learn a few best practices. If and when I get it done I will offer it to the samples gallery.

Feedback is most welcome. Specially, now I must consider how I will deal with a "has many" relationship: a project has many participants.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: July 30, 2008, 05:38:19 »

Will the GAE Python service be done in PureMVC as well? It'd rock to have a PureMVC Client AND Server demo...

-=Cliff>
Logged
facorreia
Newbie
*
Posts: 9


View Profile Email
« Reply #2 on: July 30, 2008, 06:02:43 »

Will the GAE Python service be done in PureMVC as well? It'd rock to have a PureMVC Client AND Server demo...

That would be something, wouldn't it?  ;D

Well, it might be. I can't really tell right now. That service is supposed to be quite simple, only exposing CRUD methods and returning the objects. Maybe it might benefit from two layers (view and model). The view might be the service interface, responsible for authentication, validation and data conversion, and the model might be responsible for communicating with GAE's data store. With one or two commands thrown in the middle for the odd server-side business logic. Maybe. I will think a little more about this when I get the client-side figured out.

Thank you for your support.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: July 31, 2008, 04:49:36 »

Take a look at the Python GAE Blog demo that Nathan did. It is a CRUD app essentially, allowing you to maintain the entries in your blog. It just happens to spit out HTML. You could follow it as the basis for doing a CRUD service easily.

-=Cliff>
Logged
facorreia
Newbie
*
Posts: 9


View Profile Email
« Reply #4 on: July 31, 2008, 08:29:28 »

I took some time to look again at the Python GAE Blog demo. I'm not sure if my CRUD service is complex enough that it would benefit from PyAMF. This is my current structure:

The view (boundary) is mostly handled by the PyAMF library. My view code is this:

services = {
    'EchoService': EchoService.EchoService,
    'ProjectService': ProjectService.ProjectService,
}

def main():
    application = WSGIGateway(services)
    wsgiref.handlers.CGIHandler().run(application)

This is my model code:

class Project(db.Model):
    code = db.IntegerProperty()
    name = db.StringProperty()
    department = db.IntegerProperty(default=0)
    created_at = db.DateTimeProperty(auto_now_add=True)
    modified_at = db.DateTimeProperty(auto_now=True)

This is the controller code for the Update command:

class ProjectService:
    def update(self, project):
        existing_project = Project.get(project._key)
        existing_project.name = project.name
        existing_project.department = int(project.department)
        existing_project.put()
        return Project.get(project._key)

And that's it. To use PyAMF, that update() method would raise a notification, that would be handled by a command, that would use a proxy to retrieve the current VO and store the updated VO. It seems quite a lot of indirection for something I currently do in 5 lines of sequential code. And even that code could be generalized to a helper class and become a single line.

Maybe a more complex service could benefit from PyMVC. I will look into this when my service starts to handle more kinds of objects.
Logged
Pages: [1]
Print