Hacker News new | past | comments | ask | show | jobs | submit login

Could you share some information about how your app code is structured? The main reason I'm using Django is because I like that it gives me a directory structure. The only examples I've seen of webapp are a ton of handlers in one main.py file, which doesn't seem maintainable.



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.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: