by drostie · 14y ago · 0 comments
https://www.youtube.com/watch?v=jo_B4LTHi3I
So thanks for that.I still don't like Django so much, precisely because of the fact that you're sitting here navigating through these massive config files -- and you even need Django's bundled applications to make those files in the first place. Libraries seem much cleaner to me. I guess what I'm dreaming of is a version of django where this whole talk becomes a little simpler, a sort of cookie-cutter formalism where you just start writing:
#!/usr/bin/python
import django
serve = django.server(port=8080, db=('sqlite3', 'mysite.db'))
serve.url('/admin/.*', django.admin_site())
blog = serve.app(model={
"some json model": "I don't know exactly how it works"
})
serve.url('/blog/.*', blog)
...to accomplish the same thing that you're doing in this talk. I mean, it's okay that applications often get their own folder, but shouldn't they grow into that with import statements?An open question to HN: are there libraries which do this sort of thing which I should know about?
But you don't have to use "startproject". Here's an example: http://olifante.blogs.com/covil/2010/04/minimal-django.html
No, I don't recommend you to do that. Use Flask, Bottle or any other lightweight framework/library you want to use. Just don't get hung up on how the Django docs suggests you structure your project. It's all still Python.
what do you mean??
That workflow is very particular to a Unix config file. It's, for example, what you have to do if you want to use Tor: you browse slowly through a torrc file that sets every setting with comments explaining what it does, and you uncomment or change these lines depending on what you want to happen.
That's not a bad workflow, but when I'm in a programming language I have a better option: I don't need to think about the world as "here is this monolithic application which I have to configure," but instead I can think, "oh, here are some methods which I might like to use -- methods which make servers listening on sockets with various protocols, and so forth."
The thing about config files is that if you don't embrace the Unix philosophy of "small tool which does one small job well", then the config language can come close to being Turing-complete. But if your config files are Python applications, that's already Turing complete. You don't need to build a new language on top of Python. Why should I be trying to describe in a data structure what my database is? Why make me write a data structure containing 'sqlite3' rather than mydb = django.dbs.sqlite3("filename") ? (There are a couple of reasons, actually -- one of the biggest is that they want to have a 'syncdb' command -- but I'm still not convinced that this is the best way to implement that.)