Categories
Technology

Running a bottle.py app on Dreamhost

I wrote the Stack Monthly site on the one file Bottle framework, since my needs were really bare bones. But when I tried to get it running on Dreamhost, I had to struggle quite a lot, because there was no documentation to show how to do it.

Only past midnight, did it dawn on me that there is no documentation, because it is so darn simple! So as a note to self, and to save someone an hour or two, here’s how to run a Bottle app on Dreamhost.

In a rush? Get the code at github.

Categories
Education Technology

Django Flowchart

Based on my current understanding of Django, this is how a user request is responded to.

Django Flowchart

  1. User requests a page
  2. Request reaches Request Middlewares, which could manipulate or answer the request
  3. The URLConffinds the related View using urls.py
  4. View Middlewares are called, which could manipulate or answer the request
  5. The view function is invoked
  6. The view could optionally access data through models
  7. All model-to-DB interactions are done via a manager
  8. Views could use a special context if needed
  9. The context is passed to the Template for rendering
  1. Template uses Filters and Tags to render the output
  2. Output is returned to the view
  3. HTTPResponse is sent to the Response Middlerwares
  4. Any of the response middlewares can enrich the response or return a completely new response
  5. The response is sent to the user’s browser.

Please leave a comment if I have got something wrong.

Categories
Education Technology

Week with python & Django

Spent the last week picking up Python and Django. Notes to self and anyone else who wants a quick start on Python/Django on Windows. Most Linux flavours already come with most tools needed for python development.

Requirements:

  • Installed ActivePython 2.6
  • Installed Komodo Edit
  • Installed Python Win32 Extensions (not sure why, but was recommended in some blog post and the project itself does not say much of what it does. Stuff like this gives me the heebie-jeebies.)
  • Installed Pinax, which in turn installed Django.
  • Installed PyQt4
  • Installed Eric4 (uninstalled after using it for 10 minutes)

Problems faced:

  • Pinax installation was a bit flawed, it could not install all dependencies. Worked around by manually installing (pip install else easy_install)
  • Windows 7 was not passing command line arguments to .py scripts. Had to hack registry and add %* to the end to make it work. See the Key and value below.

Registry screenshot

Getting started:

Python: Like everyone else, I followed and recommend ‘Dive Into Python’. But more importantly, this page of titbits is amazing extract from the book and quickly brings a Java dev up to speed. I should blog about ‘Python for Java developers’. Time spent 4 hrs.

Pinax: Stopped at the installation step. Will delve further after understanding Django better.

Django: Followed the tutorial, then the Django Book, and finally the Django Docs for a deep dive. Time spent 8 hrs.

Django is surely one on the best documented project and also very straight forward. It suits my style of writing code and I did not feel like giving up in few hours, like the experience I had with RoR. Will surely blog about Django more.