cewing/training.python_web — pull request #60 by austinhappel (2013-02-10 23:46:04+00:00)
Title: week05 homework

So I decided to go the extra step and implement the flaskr blog in another lightweight framework. In this case, I chose **bottle**. After working with it, I've come to think of it as a poorly documented, simple framework, with a hodge-podge of contributed modules that are even more poorly documented, and in some cases didn't work at all.

Needless to say, I had a lot of trouble. The site I have up on my bluebox vm is an unbelievably simple piece of software: you can view and add posts, but you cannot delete any. I spent so much time messing with this framework that I decided it wasn't worth the extra effort to add all the bells and whistles.

#### Site details / usage

The site is running here: http://block647049-vxq.blueboxgrid.com:8080/

You can go to **/admin** to add new posts. The username and password are both `admin`.

You can view individual posts with **/post/:id**

The database is an in-memory sqlite database - I chose not to implement anything else fancier, mainly because I didn't want to waste the time learning that aspect of a framework I probably won't use again.

#### Problems

**Multiple ways to do things, adding confusion**

Bottle's documentation offers in some cases, a few different ways to do certain things. Contributed modules also seem to differ and/or offer different options. This originally was not an issue, but when I started adding contributed modules, each of which have their own way of doing things, it quickly became a nightmare to get everything working correctly.

For instance: I saw two different ways of instantiating the bottle app class:
```python
# option 1
app = bottle.Bottle()

# option 2
app = bottle.app()
```
What is the advantage to having to ways to do this? It makes no sense to me.

Another thing I came across was 2 ways to declare templates. One option was with a `@view` decorator, and another was by returning `template('name-of-template', **kwargs)` inside a route function.

**Cork**

The contributed Cork module supplies basic user management, but it took me quite a while to set up. This mainly was attributed to poor documentation, and a poor example. Trying to combine this module with the sqlalchemy module was a bit of a pain - and I wasn't even trying to integrate user management into a database (cork uses json files for user management). Just putting them together in the same bottle app was a PITA.

#### Some good things

**I liked sqlalchemy**

SQLAlchemy worked like a charm once I got it integrated. It's a pretty straight-forward, and makes dealing with sql much easier. It reminds me of the Django ORM.

#### conclusion

I think I like flask better. It seems more up-to-date with a better community of contributors. Also, I could have done this in 20 minutes using Django.