2008-8-13

23:29 Magus-
lirit: then as I said, axl500's method is fine
23:30 axl500
.....javascript that manipulates the HTML via the DOM api around the inputs.
23:30 Magus-
worst idea ever
23:30 johannix
hello all! i'm thinking of a way to initialize some data in my DB for django projects. my current thoughts on how to do this is to setup a middleware and have this initialization happen within the init of the middleware since thats called when the web server starts... any thoughts?
23:30 axl500
axl500++;
23:30 axl500
Some day I want to wake up and see MY code on thedailywtf.
23:30 webfarmer
how would I write that... /usr/lib/python2.5/site-packages/django/contrib/admin/templates/ /home/username/development/projectname/
23:30 Magus-
johannix: horrible idea
23:31 Magus-
there is no "webserver start" hook ANYWHERE
23:31 Magus-
some things might /happen/ to run on start, but they WILL run later
23:31 Magus-
so your code will run again, and again, and again
23:31 johannix
Magus-: i saw it mentioned in the middleware docs.... "Unlike the process_* methods which get called once per request, __init__ gets called only once, when the web server starts up."
23:31 Magus-
true initialization in db seems like it'd be syncdb hook
23:31 Magus-
like initial sql
23:31 johannix
true...
23:32 Magus-
johannix: and guess what, subprocesses of the webserver start up again later
23:32 Magus-
like when apache's maxrequestperchild runs out
23:32 johannix
so where would you do something like taht?
23:32 Magus-
and other such times
23:32 johannix
or should i just have a script and call it manually
23:32 Magus-
I'd do it like I said
23:32 Magus-
a syncdb hook or initial sql
23:32 johannix
is syncdb a DB thing? or django thing?
23:33 Magus-
....
23:33 Magus-
"manage.py syncdb"
23:33 Magus-
remember that? :รพ
23:33 Magus-
so django thing, of course
23:34 johannix
ya...
23:34 johannix
i do that like ten times a day
23:34 johannix
lol
23:34 johannix
thanks...
23:34 axl500
O_O
23:34 axl500
10x?
23:34 johannix
on a bad day...
23:34 axl500
lol :)
23:34 Magus-
johannix: hence the multiple options
23:35 Magus-
and you don't have to reinit every time syncdb runs - check if some of the data is there, skip the rest
23:35 johannix
Magus-: ya, that makes sense
23:35 Magus-
and initial sql is only run the first time the table is created
23:35 Magus-
so that could be even better
23:35 Magus-
well, I should say every time
23:35 Magus-
it'll run again if you reset an app
23:36 johannix
i'm setting something else up... i want to log whenever a page is viewed... that would make sense happening in middleware right?
23:37 Magus-
well that'd go in the process_* though
23:37 johannix
ya
23:37 Magus-
perhaps you need to be more clear on what you want to init
23:37 johannix
for the logging?
23:37 bododo
hello folks :)
23:38 Magus-
...what about it?
23:38 johannix
the DB init (my first question) i want to fill up some tables with data
23:38 Magus-
oh, we're switching topics
23:38 Magus-
gotcha
23:38 johannix
my second question is i want to use middleware to log page views
23:38 johannix
ya :)
23:38 axl500
are you confusing syncdb with unit testing?
23:38 Magus-
how on earth did you get that, axl500?
23:38 johannix
nono
23:39 technel
For my next app, I decided for the first time to use postgresql. What's the diff between the DATABASE_ENGINE postgresql and postgresql_psychopg2? What is most common?
23:39 axl500
I thought he wanted to initialize new data (fresh dataset) on webserver run.
23:39 axl500
I suppose that would be human testing
23:39 Magus-
technel: the different is psycopg v1 or v2 of course, as documented :)
23:39 Magus-
logic would indicate to use v2 unless you have some need to use v1
23:40 technel
Magus-: ohh, you mean "postgresql" is just psycopg1?
23:40 Magus-
as the docs say, yes
23:40 bododo
folks, I'm in love with the django templating system, isn't there a standalone version (I'll use it in a desktop app written in wxpython)
23:40 technel
Magus-: ah, ok, thanks (I didn't see that, I looked at http://www.djangoproject.com/documentation/sett... )
23:40 axl500
johannix: why not just use apache to log page views?
23:40 johannix
axl500: i want to log it in the DB
23:40 axl500
or are you talking about doing some sort of hit counter like on youtube videos
23:41 axl500
I see
23:41 johannix
axl500: and then put that in the stats in the backend...
23:42 neybar
I'm using class Media on a form. When I use {{ form.media }} is is escaping all the html. Is there a filter to unescape
23:42 axl500
well, that's an extra processing script (AND) database hit on every request, johannix
23:42 Magus-
axl500: I'm sure he realizes that
23:42 axl500
but I suppose if you really want to, then middleware would be te option.
23:42 johannix
axl500: as far as the DB init goes, i've got a couple lookups, which have gotten more complicated than just using Python dicts, so I figured it might clean stuff up if put it in the DB. cleaner lookups...
23:43 bododo
anyone? :/
23:43 bododo
please? :)
23:43 Magus-
bododo: no, there eisnt
23:43 johannix
axl500: ya, i know. i think it's worth the tradeoff for this site...
23:43 axl500
bododo: you can decouple it
23:43 Magus-
bododo: there's one similar to it though, google for jinja (specifically v2, I think its in beta right now though)
23:43 axl500
and use it as its own library (afaik)
23:43 bododo
Magus-: thanks for the info, what would you advice me instead?
23:43 rozwell
23:43 bododo
Magus-: thank you! :)
23:44 bododo
rhank you rozwell :)
23:44 rozwell
bododo: but you can't just rip the template package out django if that's what you want
23:44 Magus-
I'd still look at jinja for a standalone
23:45 bododo
rozwell: it's exactly what i want in fact, the app is a desktop one, i don't need the whole framework
23:45 bododo
Magus-: it, in fact, seems great!
23:47 neybar
any ideas on how to get {{ form.media }} to not encode the resulting html tags?
23:48 rozwell
neybar: if you looked at the template docs you'd see a variety of ways
23:48 Magus-
23:48 Magus-
and file a bug since it probably shouldn't be doing that to begin with
23:48 axl500
neybar: |safe
23:50 rozwell
as far as i can tell form media objects use mark_safe
23:51 neybar
running it through |safe did the trick. It seems like if you are using a media declaration that it aught to be considered safe be default.
23:52 Magus-
like I said
23:52 Magus-
so file a ticket :)
Page 37 of 38   ← Previous  Next →(3,704 total)