2009-7-14
| 22:43 | hense | Hi. Is there some way to be able to import basic django modules (without actually using them) without having a django project set up (and thus no settings module to point DJANGO_SETTINGS_MODULE to)? |
| 22:43 | hense | I want to generate documentation for a django-helpers style library |
| 22:44 | hense | which has to import the modules provided by that library to get to the docstrings |
| 22:44 | hense | and I don't want to have try/except blocks around my django imports just so generating the docs works |
| 22:46 | sayane_ | i hate that ;x |
| 22:47 | becky | what does this mean? [Errno socket error] (111, 'Connection refused') |
| 22:48 | synic | looks like a mysql error |
| 22:48 | aonweb | becky: most likely permission issue |
| 22:48 | synic | you probably didn't bind to the right interface in my.cnf |
| 22:48 | sayane_ | becky, did u get my message? |
| 22:49 | sayane_ | before i got connection reset by peer? |
| 22:49 | rozwell | hense: check the faq in the topic |
| 22:49 | sayane_ | <sayane> becky, google blocked your server's ip |
| 22:49 | sayane_ | <sayane> and sitemap framework or something tries to "ping" google |
| 22:49 | becky | sayane_: no |
| 22:49 | becky | sayane_ ok i'll disable signal and try |
| 22:49 | becky | any idea why they would do that? |
| 22:50 | sayane_ | too lot of "pings" |
| 22:50 | aonweb | so that you don't do a DOS/DDS on them |
| 22:51 | hense | rozwell: hm, I've been though there but I don't see anything related to my question in there? |
| 22:51 | becky | ok i'll put some sleeps in or something |
| 22:51 | hense | rozwell: what item are you refering to? |
| 22:51 | rozwell | |
| 22:51 | sayane_ | hense, what is your question? |
| 22:52 | rozwell | hense: if you're importing django stuff, then you need to set up the environment for it |
| 22:52 | hense | rozwell: how does that relate to my question? |
| 22:53 | hense | sayane_: http://dpaste.com/67248/ |
| 22:53 | hense | sayane_: (just a paste of what I wrote earlier to state my question) |
| 22:54 | becky | sayane_ seemed to have worked. I'll have to see why they banned me :( |
| 22:55 | sayane_ | becky, move your ping code to command and execute it with cron |
| 22:55 | sayane_ | hense, it depends |
| 22:55 | sayane_ | for example models and template modules needs to be configured before using |
| 22:55 | sayane_ | and django.utils.html doesn't |
| 22:56 | becky | sayane_ the code is set up to only ping when object is entered. objects are entered one at a time maybe one/week... ping code only updates if created or deleted... |
| 22:56 | sayane_ | (this is just an example) |
| 22:56 | hense | there's no using involved at all, as I said, I just want to import the modules so the docstrings can be read |
| 22:56 | hense | and there's no code other than module and class definitions on module level |
| 22:56 | hense | (and the django imports which is my problem) |
| 22:57 | rozwell | hense: as i said, you're still going to have to set up the environment for django |
| 22:57 | sayane_ | hense the problem is that even if you define a model, there is code executed behind the scenes |
| 22:57 | hense | I've been reading the django code and it seems that I really have no other way than to set up a simple setting though settings.configure |
| 22:57 | hense | sayane_: I know how python class creation works |
| 22:57 | hense | sayane_: there are no models though. |
| 22:57 | sayane_ | so what modules are you using? |
| 22:58 | hense | as I said, there is no code from any django modules executed.. |
| 22:58 | rozwell | hense: if you'd read that link i gave you you'd know of several ways to set up the environment without creating a settings module |
| 22:58 | hense | they're just imported |
| 22:58 | rozwell | hense: importing does execute code |
| 22:58 | hense | the django modules |
| 22:58 | hense | sigh |
| 22:58 | rozwell | any modules |
| 22:58 | rozwell | top level code gets executed at import time |
| 22:58 | fualo | sigh is right... Managers, QuerySets oh my! |
| 22:58 | hense | oh you illy bugger |
| 22:58 | hense | I've been coding python vor 15 years now, stop with the basics already :) |
| 22:59 | rozwell | well then you know that |
| 22:59 | hense | the point is that I'm not using anything provided by the django modules |
| 22:59 | rozwell | yet you deny it |
| 22:59 | rozwell | if you're importing it you certainly are |
| 22:59 | hense | and that it's really silly that they seem to need that environment setup anyway |
| 22:59 | rozwell | right, well it is what it is |
| 22:59 | hense | they're executing this code on module level |
| 22:59 | hense | which is really bad style |
| 23:00 | rozwell | yet it happens |
| 23:00 | hense | but, well, it's as they say, if you know python, you won't like django |
| 23:00 | hense | very true. |
| 23:00 | fualo | if __name__ == '__main__' executes at the module level |
| 23:00 | rozwell | hense: well besides settings and a couple of other things it's quite pythonic |
| 23:00 | hense | the fuck 8) |
| 23:01 | hense | rozwell: 'a couple of other things' being incredibly ugly stuff like this class Meta business |
| 23:01 | rozwell | hense: i don't find that ugly |
| 23:01 | hense | besides creating horrific clashes in terminoligy since python already has metaclasses, it's completely useless |
| 23:01 | rozwell | there's no clash there |
| 23:01 | hense | of course there is. |
| 23:01 | rozwell | it's never referred to as a "metaclass" |
| 23:02 | rozwell | it's referred to as the Meta inner class |
| 23:02 | hense | right. not confusing at all. 8) |
| 23:02 | rozwell | anyway, it's only there to keep metadata isolated |
| 23:02 | rozwell | i've never encountered anyone being confused by it |
| 23:02 | hense | that's probably because ~90% of all django programmers seem to be utter python newbies that probably never heard of metaclasses |
| 23:03 | jcreigh | well, if they've never heard of meteclasses, there's no problem then, is there? :) |
| 23:03 | rozwell | anyway, django isn't the only python web framework out there |
| 23:03 | rozwell | so if you don't like it, hey you've got options |
| 23:04 | rozwell | and metaclasses are used in a number of places in django |
| 23:04 | hense | in reality, you often haven't |
| 23:04 | rozwell | so it's not like you wouldn't encounter them if you're using django |
| 23:04 | rozwell | often haven't what? |
| 23:04 | hense | only a small percentage of programmers actualy get to chose all the technologies they have to use |
| 23:05 | aonweb | hense: what is your point? |
| 23:05 | rozwell | heh, and normally django isn't a top down decree |
| 23:06 | hense | aonweb: that was a response to rozwell saying I had a choice about not using django |
| 23:06 | aonweb | oh ok. carry on |
| 23:06 | rozwell | anyway, if you come into it with the notion that it's not for you, you're probably going to find it's not for you |
| 23:06 | hense | rozwell: erm, what? you know that programmers work in teams, right? |
| 23:06 | rozwell | and i suppose that can't be helped |
| 23:06 | rozwell | yes |
| 23:07 | rozwell | i don't see what that's got to do with anything |
| 23:07 | fualo | what does it mean if Im getting a StopIteration exception when running models.AClass.objects.extra(...) |
| 23:07 | hense | rozwell: in a team, decissions get made. normally not by democratic processes. |
| 23:07 | hense | fualo: you're using an iterator wrongly |