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

As you can see, it makes SITE_ID a thread-local property which has a different 
value for every thread.

Hope this helps someone.

Bye,
Waldemar

--
http://www.allbuttonspressed.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



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 pass request object to the
auth backend's get_user() which is sole reason I had to write *own*
authentication middleware for per site basis.

Another unrelated thing I'm now wondering is the django.core.cache, is
it faster than my simple dict cache? That is { 'example.com' : 5, ...}
should I change my caching to this django.core.cache... I'll have to
study this further.

On Jan 29, 10:21 am, Waldemar Kornewald  wrote:
> 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/djang...https://bitbucket.org/wkornewald/djangotoolbox/src/535feb981c50/djang...
>
> As you can see, it makes SITE_ID a thread-local property which has a 
> different value for every thread.
>
> Hope this helps someone.
>
> Bye,
> Waldemar
>
> --http://www.allbuttonspressed.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



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 = make_tls_property()
# This does not have to be in settings object but for the sake of
example:
settings.__class__.REQUEST = make_tls_property()

After which I create own middleware that sets them for each request.
Then I can just access the values with settings.REQUEST,
settings.SITE_ID ...

Only thing I probably have to be aware is that if this
make_tls_property is not done early enough my apps must not rely on
this method:

SETTING = getattr(settings, 'MYAPP_SETTING', 'default')

especially if the use SITE_ID, MEDIA_URL or MEDIA_ROOT.

On Jan 29, 2: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.
>
> It would solve many problems, such as django's authentication
> middleware's shortcoming where it does not pass request object to the
> auth backend's get_user() which is sole reason I had to write *own*
> authentication middleware for per site basis.
>
> Another unrelated thing I'm now wondering is the django.core.cache, is
> it faster than my simple dict cache? That is { 'example.com' : 5, ...}
> should I change my caching to this django.core.cache... I'll have to
> study this further.
>
> On Jan 29, 10:21 am, Waldemar Kornewald  wrote:
>
>
>
>
>
>
>
> > 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/djang..
>
> > As you can see, it makes SITE_ID a thread-local property which has a 
> > different value for every thread.
>
> > Hope this helps someone.
>
> > Bye,
> > Waldemar
>
> > --http://www.allbuttonspressed.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



Deploying a django application to apach2 on Ubuntu

2011-01-29 Thread Maxim Mai
Hi all,

I am really new to django and apache.
I've  just finished a django application recently, and now I am have
problems of deploying it to a server.

system environments:
ubuntu 10.10
apache2
django1.2
php5
mod_wsgi
python2.6

problems are:

1. I think my apache2 configures are all messed up.
what happened is I wanted to enable the static files(*.css and image
files that I need for my templates) serving for my application, then I
googled online, turns out, there are many versions of HOWTO. So, I
edited httpd.conf, apache2.conf, sites-available/default, and sites-
enabled/default... tried a2ensite, a2dissite.
I've also tried sudo apt-get purge apache2, then reinstalled it. I was
hoping that I could get a new set of configuration for the apache2.
that's how i ended up with nothing working, not even phpmyadmin.

2. how do you serve static media files in development mode?
I mean, how do you serve those files just using the built-in web
server? (python manage.py runserver)

3. are there any good web server software for django applications? or
are there any good web app hosting for django, google app engine,
webfaction?
pros and cons? My application is just a extended version of the built-
in django admin system: a invoice. book keeping application that
allows a store owner to manage their daily business with clients,
invoices, products and shippings.

Thanks,

Maxim Mai

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



Google Summer of Code 2011

2011-01-29 Thread Lauri Võsandi
Hello,

GSoC was just announced few days ago. Is Django going to participate
on GSoC as mentoring organization? Related blogpost is here:

http://google-opensource.blogspot.com/2011/01/google-summer-of-code-announced-at-lca.html

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



Re: Deploying a django application to apach2 on Ubuntu

2011-01-29 Thread David P. Novakovic
Hey, this post is definitely for the django-users mailing list. This mailing
list is solely for the discussion of django development itself. That is,
discussion about development of the core libraries.

Cheers,

David

On Sat, Jan 29, 2011 at 6:46 PM, Maxim Mai  wrote:

> Hi all,
>
> I am really new to django and apache.
> I've  just finished a django application recently, and now I am have
> problems of deploying it to a server.
>
> system environments:
> ubuntu 10.10
> apache2
> django1.2
> php5
> mod_wsgi
> python2.6
>
> problems are:
>
> 1. I think my apache2 configures are all messed up.
> what happened is I wanted to enable the static files(*.css and image
> files that I need for my templates) serving for my application, then I
> googled online, turns out, there are many versions of HOWTO. So, I
> edited httpd.conf, apache2.conf, sites-available/default, and sites-
> enabled/default... tried a2ensite, a2dissite.
> I've also tried sudo apt-get purge apache2, then reinstalled it. I was
> hoping that I could get a new set of configuration for the apache2.
> that's how i ended up with nothing working, not even phpmyadmin.
>
> 2. how do you serve static media files in development mode?
> I mean, how do you serve those files just using the built-in web
> server? (python manage.py runserver)
>
> 3. are there any good web server software for django applications? or
> are there any good web app hosting for django, google app engine,
> webfaction?
> pros and cons? My application is just a extended version of the built-
> in django admin system: a invoice. book keeping application that
> allows a store owner to manage their daily business with clients,
> invoices, products and shippings.
>
> Thanks,
>
> Maxim Mai
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers" group.
> To post to this group, send email to django-developers@googlegroups.com.
> To unsubscribe from this group, send email to
> django-developers+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-developers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



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 == 42

and they all failed after using make_tls_property, this is because of
funny LazyObject Django uses.

So I came up with _patch_setattr, see gist:
https://gist.github.com/802020

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



Re: Google Summer of Code 2011

2011-01-29 Thread Russell Keith-Magee
2011/1/29 Lauri Võsandi :
> Hello,
>
> GSoC was just announced few days ago. Is Django going to participate
> on GSoC as mentoring organization? Related blogpost is here:
>
> http://google-opensource.blogspot.com/2011/01/google-summer-of-code-announced-at-lca.html

Yes, we do intend to participate. If you follow the links on that blog
post, you'll see that organization registration doesn't start until
the end of February, so we've got some time before we need to start
the formalities.

However, potential candidates can start thinking about their projects
if they want to -- if you've got an idea of what you want to work on,
formalize your proposal and post to django-dev.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



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 of the biggest reasons why Django doesn't
encourage the practice of using threadlocals.

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
soundly beaten by any supervisor worth their salt. Somehow, because
the name has been changed to "threadlocal", global variables have
suddenly become acceptable.

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
entirely with a good dose of rigorous engineering.

I *strongly* advise against the use of this technique.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



Re: ANN: Server upgrade on djangoproject.com

2011-01-29 Thread Russell Keith-Magee
On Sat, Jan 29, 2011 at 5:45 AM, Jacob Kaplan-Moss  wrote:
> On Fri, Jan 28, 2011 at 3:33 PM, Jacob Kaplan-Moss  wrote:
>> I'm starting the switchover to the new djangoproject.com server right
>> now. Might be around 5 mins of downtime or so.
>
> Migration should be complete now. I'm still cleaning up a few
> last-minute things, but if you notice anything wrong please pop into
> #django-dev on freenode and let me know.

You're not around in IRC (I'm guessing you're in bed) so here's a
couple of issues:

One problem has already been reported in Trac:
http://code.djangoproject.com/ticket/15192 -- docs.djangoproject.com
is serving the wrong docs for v1.2

A couple of minor UX issues that I've noticed this afternoon while doing triage:

 * The code browser and diff viewer doesn't have zebra stripes on code
samples/snippets.

 * Is it possible to get the "modify ticket properties" section of a
ticket expanded by default? I don't know who thought "closed by
default" was a good idea, but it's a PITA to have to open that section
of every single ticket when you're doing triage.

Russ %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.