On Wed, 2007-06-13 at 22:25 +0000, [EMAIL PROTECTED] wrote: > Greetings. I am about 75% through creating a django application as a > new section of my company's site, www.etsy.com. It's basically a CMS, > something that I know django is especially well suited to (tho I can > tell it would work for nearly any domain). > > Recently, my site ops team started asking me questions about > reliability with the database and such. After asking around in the irc > channel and doing some google searches, and even trying to browse > through the source a bit, I still have some questions: > > 1) Is there some way to tell django to talk to two different databases > (sort of a fail-over system), eg, behaviour matching the pseudo-code:
No. [...] > Is there some way to activate this functionality? As far as I can > tell, the answer is "no"; in that case, can you suggest how I might go > about adding it myself? Where in the django source I would have to > tinker to get this behaviour? > > 2) Site ops might be able to handle database fail-over at the network > configuration level, but I need to know whether the django orm, when > using postgress, keeps a pool of persistent connections. If so, and if > the connections fail or are disconnected, will it automatically > attempt to reconnect them upon future requests? > > Again, I don't mind writing the code myself to handle this if it is > not already handled. If I must write it myself, can you point me in > the direction of where I would handle this. Is monkeypatching a class > or method considered superior to editing the source locally? Coming > from a Ruby background, that would be my natural response. One of the benefits of everything being a first-class object in Python is so that things can be replaced at runtime. The only question is whether you can get in early enough in the pipeline to replace the functionality before it is used. I'm not sure in this case, although it might be tricky to do so. Database connections are set up in django/db/__init__.py The real heavy lifting for each backend is in django/db/backends/<backend-name>/base.py in the DatabaseWrapper class. You'll probably be wanting to replace the cursor() method there, I would guess. It might be simplest to create your own pseudo-backend that essentially imports everything from an existing backend and then sub-classes the DatabaseWrapper class to provide the functionality you want. Last Tuesday, in a thread called "inspectdb and mssql", I laid out the steps needed to create a new backend. I'm thinking this might be most appropriate because then you are only adding new code, rather than modifying existing code. Updating Django's source then only requires remembering to move your new code across without having to repatch certain files. Likely to be more robust. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---