Re: One Django instance, hundreds of websites

2011-01-31 Thread Jari Pennanen
On Jan 31, 8:27 pm, Carl Meyer wrote: > On Jan 31, 1:49 am, Xavier Ordoquy wrote: > > > The thread is pretty long because there are also 2 threads in one: > >  - one for simply changing the site_id per request > >  - one for changing the all setting

Re: One Django instance, hundreds of websites

2011-01-31 Thread Carl Meyer
On Jan 31, 1:49 am, Xavier Ordoquy wrote: > The thread is pretty long because there are also 2 threads in one: >  - one for simply changing the site_id per request >  - one for changing the all setting per request Exactly! For the record, as far as I'm concerned #15089 is

Re: One Django instance, hundreds of websites

2011-01-31 Thread Jari Pennanen
On Jan 31, 8:30 am, James Hancock wrote: > This post is getting pretty long. But I had a simple Django fix that would > make it work a lot easier for me, and might help others. (I say this because > of how I implemented it, I am working with about 60 different sites and it >

Re: One Django instance, hundreds of websites

2011-01-30 Thread Xavier Ordoquy
Le 31 janv. 2011 à 07:30, James Hancock a écrit : > This post is getting pretty long. But I had a simple Django fix that would > make it work a lot easier for me, and might help others. (I say this because > of how I implemented it, I am working with about 60 different sites and it is > a

Re: One Django instance, hundreds of websites

2011-01-30 Thread James Hancock
This post is getting pretty long. But I had a simple Django fix that would make it work a lot easier for me, and might help others. (I say this because of how I implemented it, I am working with about 60 different sites and it is a pretty simple arrangement) Imagine you were able to set a site_id

Re: One Django instance, hundreds of websites

2011-01-30 Thread lwcy...@gmail.com
I believe this ticket: http://code.djangoproject.com/ticket/14628 which was created during this chat session http://www.revsys.com/officehours/2010/nov/05/#question5 is also relevant to the issue at hand. An interesting bit of that chat is: jacobkmnicoechaniz: one hint is that although the

Re: One Django instance, hundreds of websites

2011-01-30 Thread Jari Pennanen
Notice that I never suggested *django* to implement thread local hack, it just allowes me to continue. The thread local hack is just that hack, it hides the real problem for now since Django does not support the stuff I need it to. Settings object should be considered mainly read-only, if the

Re: One Django instance, hundreds of websites

2011-01-30 Thread Daniel Moisset
On Sun, Jan 30, 2011 at 2:20 AM, Russell Keith-Magee wrote: > > Every single problem associated with using global variables exists > with threadlocals -- and then a few more. They *can* be used > successfully. However, in almost every case, they can also be avoided >

Re: One Django instance, hundreds of websites

2011-01-30 Thread Jari Pennanen
In above I have error: authbackend.save(session, user) -> bool authbackend.load(session) -> user object should be: authbackend.save(request, user) -> bool authbackend.load(request) -> user object Since getting site id from request is the thing I need to do and save it to session. --

Re: One Django instance, hundreds of websites

2011-01-30 Thread Jari Pennanen
With globals: No patches to Django required. Flatpages, media urls, media roots can be customed by request and works without single problem. Mostly because settings are used like settings.SITE_ID etc. and not like getattr(settings, 'SITE_ID') in apps. If Django ever is patched to work without

Re: One Django instance, hundreds of websites

2011-01-30 Thread Jari Pennanen
On Jan 30, 7:20 am, Russell Keith-Magee wrote: > On Sat, Jan 29, 2011 at 8:55 PM, Jari Pennanen > wrote: > If an engineer came to their supervisor with a problem and said "I'm > going to fix this problem with a global variable", they would be

Re: One Django instance, hundreds of websites

2011-01-29 Thread Russell Keith-Magee
On Sat, Jan 29, 2011 at 8:55 PM, Jari Pennanen wrote: > Certainly something new for me. > > That does look like a rather cool. Essentially if that works one could > save even the request object to thread "global" and it would be > accessible anywhere. ... and this is one

Re: One Django instance, hundreds of websites

2011-01-29 Thread Jari Pennanen
Hi! I suggest you to look on to this _patch_setattr I cooked. I noticed that it is also necessary to patch the __setattr__ of the settings object in order to allow changes to the settings.SITE_ID again. Following test would fail after TLSProperty: settings.SITE_ID = 42 assert settings.SITE_ID

Re: One Django instance, hundreds of websites

2011-01-29 Thread Jari Pennanen
Sorry about second post but I'm so thrilled about this thread local approach! Thanks Waldemar. This changes everything, EVERYTHING. I can just do: settings.__class__.SITE_ID = make_tls_property() settings.__class__.MEDIA_URL = make_tls_property() settings.__class__.MEDIA_ROOT =

Re: One Django instance, hundreds of websites

2011-01-29 Thread Jari Pennanen
Certainly something new for me. That does look like a rather cool. Essentially if that works one could save even the request object to thread "global" and it would be accessible anywhere. It would solve many problems, such as django's authentication middleware's shortcoming where it does not

Re: One Django instance, hundreds of websites

2011-01-29 Thread Waldemar Kornewald
Hi, it's possible to manipulate the settings object in a thread-safe way. Here's our dynamic site middleware: https://bitbucket.org/wkornewald/djangotoolbox/src/535feb981c50/djangotoolbox/sites/dynamicsite.py https://bitbucket.org/wkornewald/djangotoolbox/src/535feb981c50/djangotoolbox/utils.py

Re: One Django instance, hundreds of websites

2011-01-28 Thread Jari Pennanen
Graham is correct. I pointed out this in my reply to reviewboard method which works just like Jjdelc proposed, and that is incorrect way. So simply put: Changing settings object in middelwares is WRONG. If one changes the settings object before or after request, it will be in intermediate state

Re: One Django instance, hundreds of websites

2011-01-28 Thread Graham Dumpleton
On Friday, January 28, 2011 6:59:43 PM UTC+11, James Hancock wrote: > > I have one question about changing the site ID per request. > I assume that settings is imported from conf, and so in the end it is > simply changing the same SITE_ID to fit the current request Django is > handling. > >

Re: One Django instance, hundreds of websites

2011-01-28 Thread James Hancock
I have one question about changing the site ID per request. I assume that settings is imported from conf, and so in the end it is simply changing the same SITE_ID to fit the current request Django is handling. Does this ever become a problem? I am setting up around 250 sites for example. If the

Re: One Django instance, hundreds of websites

2011-01-26 Thread Jari Pennanen
On Jan 26, 6:56 pm, FeatherDark wrote: > Greetings huge django developer list, > I just wanted to mention, this method totally works for me, I call it > "Skinning" > > In the templates folder I have a file called "base.html' > Inside that file is only 1 line: > {% extends

Re: One Django instance, hundreds of websites

2011-01-26 Thread FeatherDark
Greetings huge django developer list, I just wanted to mention, this method totally works for me, I call it "Skinning" In the templates folder I have a file called "base.html' Inside that file is only 1 line: {% extends request.META.HTTP_HOST|cut:':'|add:'.html'%} The rest of that same folder

Re: One Django instance, hundreds of websites

2011-01-26 Thread Jari Pennanen
On Jan 26, 5:20 pm, Xavier Ordoquy wrote: > Given the title, I would feel bad for the sysadmin if there was hundreds of > setting files with just the site id within ;) Ha, single file per site :) I would change to that any day. The current system in place is following:

Re: One Django instance, hundreds of websites

2011-01-26 Thread Jari Pennanen
For the project which I plan to use this is such that all sites could share same INSTALLED_APPS, but it would be truly awesome if full settings were possible for each site. On Jan 26, 5:10 pm, Lorenzo Gil Sanchez wrote: > I suggest to have a look to

Re: One Django instance, hundreds of websites

2011-01-26 Thread Lorenzo Gil Sanchez
2011/1/25 Jari Pennanen <jari.penna...@gmail.com>: > Hi! > > I'm on a monumental task here, I've decided to get one Django instance > running hundreds of websites. > > I've run in to couple of shortcomings with django: > > 1. Global SITE_ID does not work since some

Re: One Django instance, hundreds of websites

2011-01-26 Thread Xavier Ordoquy
Given the title, I would feel bad for the sysadmin if there was hundreds of setting files with just the site id within ;) As for the urlconf, it's already possible. core/urlresolvers have a set/get urlconf that is set for the thread by the BaseHandler. Don't get me wrong, I started some work

Re: One Django instance, hundreds of websites

2011-01-26 Thread David Danier
> On the other hand, having one setting file per site where the only difference > is the site id seems a bit too much overhead. Why not use something like this: from global_settings import * SITE_ID = 235 #This also allows further changes like: #INSTALLED_APPS = INSTALLED_APPS + ( #

Re: One Django instance, hundreds of websites

2011-01-26 Thread Xavier Ordoquy
decided to get one Django instance >> running hundreds of websites. > > I'm also on similar path here. I'm trying to build a system where > django instances running on several servers are serving hundreds of > websites. Each website has different urlconf, different templates, &g

Re: One Django instance, hundreds of websites

2011-01-26 Thread Derega
On Jan 25, 4:56 pm, Jari Pennanen <jari.penna...@gmail.com> wrote: > I'm on a monumental task here, I've decided to get one Django instance > running hundreds of websites. I'm also on similar path here. I'm trying to build a system where django instances running on several servers

Re: One Django instance, hundreds of websites

2011-01-25 Thread Rohan Jain
I am also trying to achieve something highly similar to this but in a dilemma, for how to proceed. I have written a post about this: http://www.rohanjain.in/blog/hosting-multiple-sites-with-same-django-project/. Is there any existing big project following a similar concept? -- You received

Re: One Django instance, hundreds of websites

2011-01-25 Thread Russell Keith-Magee
2011/1/25 Łukasz Rekucki : > On 25 January 2011 16:15, Russell Keith-Magee wrote: >> >> For the next couple of weeks the core developers will be a little busy >> finalizing the 1.4 release; > > That is obviously supposed to be 1.3 ;) Erm... ahh...

Re: One Django instance, hundreds of websites

2011-01-25 Thread Łukasz Rekucki
On 25 January 2011 16:15, Russell Keith-Magee wrote: > > For the next couple of weeks the core developers will be a little busy > finalizing the 1.4 release; That is obviously supposed to be 1.3 ;) -- Łukasz Rekucki -- You received this message because you are

One Django instance, hundreds of websites

2011-01-25 Thread Jari Pennanen
Hi! I'm on a monumental task here, I've decided to get one Django instance running hundreds of websites. I've run in to couple of shortcomings with django: 1. Global SITE_ID does not work since some requests belong to different site. I've created middleware that adds request.site_id based