Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Usually I put one handler per .py, to the point, what that particular module should do and nothing else. I leave the routing stuff to the app.yaml file.

For a dir structure, I have admin, css, js, prog and view. Not hard to know what goes in every folder. Right now I have like fifty progs and fifty views, each for every specific task.

For every program there is usually one line to get the data from models and one line to render it using a template. Nothing else.

I really don't get what a framework would do to help me, I already have everything I need at my fingertips.



Here is a sample index.py that renders index.html. I enhanced webapp with some utilities to make my life easier, I hate typing in excess.

    import app

    class main(app.request):
      app.session.start()
      data=app.models.getContacts()
      app.render('index',data)

    app.run('/',main)

And here the html in the template:

    <html>
    <body>
      <h1>Contacts List</h1>
      {% for item in data %}
        <li>{{item.name}} - {{item.phone}}</li>
      {% endfor %}
    </body>
    </html>
Some purists will burn me at the stake, but it works wonders for me.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: