djmicro icon indicating copy to clipboard operation
djmicro copied to clipboard

Few more examples

Open fruch opened this issue 12 years ago • 3 comments

  • added support for star import (could shorten the code, on the expense of name space littering)
  • added an example that uses the Django ORM (couldn't find a way to do it in one file...)

fruch avatar Mar 08 '12 18:03 fruch

This is interesting, certainly... I think, though, that I'd like to figure out a way that gives access to models without requiring creating an explicit app. I want to play with it some more, this weekend, but I'm pretty sure that you could get there with the right hacky helper functions. I'm basically of the opinion that the helper library can be as ugly as necessary to keep the code that consumes it clean and compact.

This pull request provides a good starting place for that, though.

apendleton avatar Mar 08 '12 19:03 apendleton

I've tried that for a hour or so... for some reason couldn't found a way to force django to create the tables. tables are created per app, and there if theres no app, no tables are created.

I'm not sure it could be done without hacking into the django code.

one directory, and two files (one empty init.py) are quite reasonable for mini-framework (I myself really like the Django app style, but I can see how Flask/CherryPy and other micro-frameworks can help)

I hope you'll be able to solve that.

BTW what do you think about the star import, I know some people really hate it.

fruch avatar Mar 08 '12 19:03 fruch

I have no objection to the star import, and I agree that it should be a supported pattern... that said, the names of the helpers will be relatively common names ("configure," "route," etc.), so I definitely see the possibility for conflicts, and I don't have any interest in changing the names of the helpers (to "djroute" or something) to make that less likely, so if I ever use this thing in production, I probably personally won't use it that way.

apendleton avatar Mar 08 '12 19:03 apendleton