App Architecture/best practices

118 views
Skip to first unread message

progrmr

unread,
May 15, 2008, 8:47:30 AM5/15/08
to Google App Engine
So I did my first google app engine application and I dig it, but
knowing nothing about python I am unfamiliar with how real
applications should be structured for maintainability and
extensibility.

My app has ALL the code in one file. Its a simple forums app so its no
big deal but an application of any consequence will be much more
complex and a single file is not going to cut it.

Where can I get some recommendations or read some articles about
proper application structure/technique for google app engine apps?

joh...@easypublisher.com

unread,
May 15, 2008, 1:09:56 PM5/15/08
to google-a...@googlegroups.com
I don't think this is a question specific to appengine or python, but
much more general question.

I would say that, imho, appengine lacks a good pattern for this, anything goes.

Personally I'd like so see a MVC module written for appengine,
maybe there is one in Django (please let me know if so).

This might be a good task for the appengine-utitlies project. I'm
gonna raise the issue there.
http://code.google.com/p/appengine-utitlies/

Cheers,
Johan


--
Johan Carlsson
Colliberty Easy Publisher
http://www.easypublisher.com

luismgz

unread,
May 15, 2008, 1:29:15 PM5/15/08
to Google App Engine
What do you mean by "MVC module"? A framework?
GAE comes with webapp, which is a simple framework for creating apps
with the MVC model.
If you don't like it or want something more complex, you can use
Django, Pylons, webpy, or any other framework that complies with the
wsgi standard.


On May 15, 2:09 pm, joh...@easypublisher.com wrote:
> I don't think this is a question specific to appengine or python, but
> much more general question.
>
> I would say that, imho, appengine lacks a good pattern for this, anything goes.
>
> Personally I'd like so see a MVC module written for appengine,
> maybe there is one in Django (please let me know if so).
>
> This might be a good task for the appengine-utitlies project. I'm
> gonna raise the issue there.http://code.google.com/p/appengine-utitlies/
>
> Cheers,
> Johan

Robert

unread,
May 16, 2008, 6:13:19 AM5/16/08
to Google App Engine
If you take a closer look at Django you will see that it covers much
from MVC paradigma. With the help of this article
http://code.google.com/appengine/articles/django.html you can enable
the view-mechanism within Django. This really works - at least in
local development (can't test online beause I suffer from Issue 119
http://code.google.com/p/googleappengine/issues/detail?id=119&colspec=ID%20Type%20Status%20Priority%20Stars%20Owner%20Summary).
Next part I will test is the new Forms-franework of Django - hope it
will work too ... :-)

progrmr

unread,
May 16, 2008, 6:52:12 AM5/16/08
to Google App Engine
hmmm...well, not really a fan of the "anything goes" methodology
unless its a trivial matter. For me it would make the GAE something
fun to tinker with but not really to invest in.

I will have to do some more reading on the issue.

On May 16, 6:13 am, Robert <rbausd...@googlemail.com> wrote:
> If you take a closer look at Django you will see that it covers much
> from MVC paradigma. With the help of this articlehttp://code.google.com/appengine/articles/django.htmlyou can enable
> the view-mechanism within Django. This really works - at least in
> local development (can't test online beause I suffer from Issue 119http://code.google.com/p/googleappengine/issues/detail?id=119&colspec...).

Filip

unread,
May 16, 2008, 6:57:45 AM5/16/08
to Google App Engine
Well, the discussion seems to have veered off in the direction of MVC,
Django, et.al.

I believe the original question is to have a little tutorial on how to
split code over multiple files, and import them.

Filip.

progrmr

unread,
May 16, 2008, 8:00:35 AM5/16/08
to Google App Engine
yes - that would be great. I'm reading Programming Python right now
but a short tutorial on breaking up application components into a more
maintable structure that would be very helpful.

Filip

unread,
May 16, 2008, 8:05:39 AM5/16/08
to Google App Engine
There should probably also be particular attention to Google App
Engine specific issues. Where do you put the separate files, does this
impact the app.yaml file, is any configuration needed to import them
easily.

Filip.
> > > proper application structure/technique for google app engine apps?- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -

Sylvain

unread,
May 16, 2008, 8:36:29 AM5/16/08
to Google App Engine
It may help : http://code.google.com/appengine/docs/webapp/running.html

--
Tip: App Engine routes requests to Python scripts based on the URL and
mappings specified in the application's app.yaml file. A webapp
WSGIApplication further maps specific URL paths to request handlers.
How you use both mappings is up to you: You could have all non-static
URLs go to a single Python script, and have the script dispatch all
dynamic URLs to handlers. Or, you can group functionality into
multiple WSGI applications run by different scripts, and use app.yaml
to map the appropriate URLs to the appropriate applications.
---

Filip

unread,
May 16, 2008, 12:03:29 PM5/16/08
to Google App Engine
While waiting for a good docs on this, you might want to look at:
http://appengine-utitlies.googlecode.com/svn/trunk/

It is a sample of how you can build your own framework.

Filip.
> > > - Tekst uit oorspronkelijk bericht weergeven -- Tekst uit oorspronkelijk bericht niet weergeven -

Filip

unread,
May 16, 2008, 11:54:28 AM5/16/08
to Google App Engine
Sylvain, this is the right approach when you have different URLs that
you need to handle. It certainly should be part of a manual that
explains how to chop up your program.

But when writing a larger program, it is very likely you'll run into
code that you wish to reuse across files, or that you wish to put in
your own framework. That's what the import keyword is for in Python.
Since you can't directly configure Python on GAE, and hence can't use
the search path, I believe some tutorial is in order on how to do
this. In fact, I'm in fact not sure the way I currently do it is the
best way to do it.

I guess a docs page on this subject would be best, but some simple
sample code might go a long way to help clarify this issue.

Filip.
> > > - Tekst uit oorspronkelijk bericht weergeven -- Tekst uit oorspronkelijk bericht niet weergeven -

joh...@easypublisher.com

unread,
May 17, 2008, 5:15:06 AM5/17/08
to google-a...@googlegroups.com
@Filip

Is what your asking, where do I put my libraries?


(assuming I understood you correctly)

I haven't realized before I read this thread (due to the lack of a GAE
account, correct me
if I am wrong) but libraries needs to be put in the application path!?

So one way to layout an app would be to have a "lib" directory in it
where all you add all modules you want to use with the app (this can
be modules that you reuse over different projects).
Each module being its own subdirectory in that directory.

If you're using subversion modules could be "linked" into that directory
with svn:externals from other separate svn repositories.

Now on the question how to organize your code, e.g. what goes in
what module, it's more of an general software architecture question
really. But building components with low coupling is a key off course.

I think there Best Practices will evolve here as people get more experience
and apply their prior knowledge on building appengine apps.

I think the appengine-utilities project might be a good place to evolve this
kind of patterns in a collaborative manner.
Actually the question has already been raise there (by yours truly) :-D

Cheers,
Johan

Filip

unread,
May 17, 2008, 9:15:51 AM5/17/08
to Google App Engine
Hi Johan,

Thanks for your answer. Yes, my question was on where to put the
files. Since we don't configure python on GAE, it is not so clear
where the path leads to.
I have understood that you can simply create packages by creating
subdirectories of the main directory, and off course putting a
__init__.py in that directory. I also believe there is no need to put
these directcory in the app.yaml file (contrary to static files you
want to access from the outside).

All of this directory stuff took some figuring out. I think there
should be some docs on this.

As for the software engineering side, I think that is well outside the
scope of GAE, and does not to be explained here. But I guess I'm
assuming there are plenty of people like me, who have (quite a bit of)
experience in software engineering, but are relatively new to Python.
You get started easily ("it's just another language"), but continuely
learn Python-specifics.

On the other hand, I'm sure there are plenty of people like my cousin,
who is just learning to program and who I advised to learn Python
first. That way, if he builds a (web)application, he can share it with
his friends easily. I told him to write small lots of small pieces of
software, and launch them quickly. And only continue on those that
attract visitors. Off course, right now he'll be limited to 1 or 3,
but by the time he is good at it, that limitation will perhaps be
gone? Anyway, for him a book that teaches people how to program
starting from zero with Python and GAE would be useful. In fact,
perhaps Google should openly publish such a thing to promote their
platform. But that is a different discussion.

Filip.

On 17 mei, 11:15, joh...@easypublisher.com wrote:
> @Filip
>
> Is what your asking, where do I put my libraries?
>
> (assuming I understood you correctly)
>
> I haven't realized before I read this thread (due to the lack of a GAE
> account, correct me
> if I am wrong) but libraries needs to be put in the application path!?
>
> So one way to layout an app would be to have a "lib" directory in it
> where all you add all modules you want to use with the app (this can
> be modules that you reuse over different projects).
> Each module being its own subdirectory in that directory.
>
> If you're using subversion modules could be "linked" into that directory
> with svn:externals from other separate svn repositories.
>
> Now on the question how to organize your code, e.g. what goes in
> what module, it's more of an general software architecture question
> really. But building components with low coupling is a key off course.
>
> I think there Best Practices will evolve here as people get more experience
> and apply their prior knowledge on building appengine apps.
>
> I think the appengine-utilities project might be a good place to evolve this
> kind of patterns in a collaborative manner.
> Actually the question has already been raise there (by yours truly) :-D
>
> Cheers,
> Johan
>

joh...@easypublisher.com

unread,
May 17, 2008, 9:30:02 AM5/17/08
to google-a...@googlegroups.com
On 5/17/08, Filip <filip.v...@gmail.com> wrote:
>
> Hi Johan,
>
> Thanks for your answer. Yes, my question was on where to put the
> files. Since we don't configure python on GAE, it is not so clear
> where the path leads to.
> I have understood that you can simply create packages by creating
> subdirectories of the main directory, and off course putting a
> __init__.py in that directory. I also believe there is no need to put
> these directcory in the app.yaml file (contrary to static files you
> want to access from the outside).

Exactly. (note though I don't have don't have an GAE account, so
I'm assuming it works so on production as well. But it seems fairly
likely to me.)


> All of this directory stuff took some figuring out. I think there
> should be some docs on this.
>
> As for the software engineering side, I think that is well outside the
> scope of GAE, and does not to be explained here. But I guess I'm
> assuming there are plenty of people like me, who have (quite a bit of)
> experience in software engineering, but are relatively new to Python.
> You get started easily ("it's just another language"), but continuely
> learn Python-specifics.
>
> On the other hand, I'm sure there are plenty of people like my cousin,
> who is just learning to program and who I advised to learn Python
> first. That way, if he builds a (web)application, he can share it with
> his friends easily. I told him to write small lots of small pieces of
> software, and launch them quickly. And only continue on those that
> attract visitors. Off course, right now he'll be limited to 1 or 3,
> but by the time he is good at it, that limitation will perhaps be
> gone? Anyway, for him a book that teaches people how to program
> starting from zero with Python and GAE would be useful. In fact,
> perhaps Google should openly publish such a thing to promote their
> platform. But that is a different discussion.

I agree. Maybe we should write it for Google (in the spirit of Open Source) :-D

I think there are a lot of discussions on this mailing list trying to figure out
best practices. Let's keep up that great work and I think people will put
up articles on the net as we move forward :-D

Cheers,
Johan

Reply all
Reply to author
Forward
0 new messages