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

I really don't see any benefit or sense in the Flask way of exposing request state through imported globals. It makes testing of views unnecessarily complex: you have to either patch the import or set up the thread local context in every test. And like you mentioned, it encourages unnecessary coupling.

It would be so much simpler to just have a request argument passed to each view.




But then you have to explicitly pass the context to everything you call.

Dynamic scoping would solve this problem (and similar problems, like dependency injection), but Python doesn't have that.

Flasks way emulates it as well as possible.




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

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

Search: