First, I would suggest you have a look at "Rapid Development with Python, Django, and Google App Engine"
GvR describes a general/standard project layout on page 10 of his slide presentation.
Here I'll post a slightly modified version of the layout/structure from that page. I pretty much follow this pattern myself. You also mentioned you had trouble with packages. Just make sure each of your sub folders has an __init__.py file. It's ok if its empty.
Boilerplate files
- These hardly vary between projects
- app.yaml: direct all non-static requests to main.py
- main.py: initialize app and send it all requests
Project lay-out
- static/*: static files; served directly by App Engine
- myapp/*.py: app-specific python code
- views.py, models.py, tests.py, __init__.py, and more
- templates/*.html: templates (or myapp/templates/*.html)
Here are some code examples that may help as well:
main.py
import wsgiref.handlers
from google.appengine.ext import webapp
from myapp.views import *
application = webapp.WSGIApplication([
('/', IndexHandler),
('/foo', FooHandler)
], debug=True)
def main():
wsgiref.handlers.CGIHandler().run(application)
myapp/views.py
import os
import datetime
import logging
import time
from google.appengine.api import urlfetch
from google.appengine.ext.webapp import template
from google.appengine.api import users
from google.appengine.ext import webapp
from models import *
class IndexHandler(webapp.RequestHandler):
def get(self):
date = "foo"
# Do some processing
template_values = {'data': data }
path = os.path.join(os.path.dirname(__file__) + '/../templates/', 'main.html')
self.response.out.write(template.render(path, template_values))
class FooHandler(webapp.RequestHandler):
def get(self):
#logging.debug("start of handler")
myapp/models.py
from google.appengine.ext import db
class SampleModel(db.Model):
I think this layout works great for new and relatively small to medium projects. For larger projects I would suggest breaking up the views and models to have their own sub-folders with something like:
Project lay-out
- static/: static files; served directly by App Engine
- js/*.js
- images/*.gif|png|jpg
- css/*.css
- myapp/: app structure
- models/*.py
- views/*.py
- tests/*.py
- templates/*.html: templates
Well django 1.0 was updated today on Google AppEngine. But you can make user authentication like anything else you just can't really use sessions because it is so massive.
There is a session utility in http://gaeutilities.appspot.com/
http://gaeutilities.appspot.com/session
http://code.google.com/p/gaeutilities/
Or,
You have to create your own user tables and hash or encrypt passwords, then probably create a token system that mimics session with just a token hash or uuid cookie (sessions are just cookies anyways).
I have implemented a few with just basic google.webapp request and response headers. I typically use uuids for primary keys as the user id, then encrypt the user password and have their email for resets.
If you want to authorize users for external access to data you could look at OAuth for application access.
If you just want to store data by an id and it is more consumer facing, maybe just use openid like stackoverflow and then attach profile data to that identifier like django profiles (http://code.google.com/p/openid-selector/).
django 1.0 just came out today on GAE but I think the same problems exist, no sessions, you have to really create your own that store session data.
Best Answer
There is remember me on this computer checkbox on Google login page. And it works for me. Do you need something different?