Re: Multi-tenant Django

2012-05-15 Thread Anthony Briggs
Hi Alec,

One of the science experiments on my todo list is to try and set up one of
the fancy new database routers (possibly with get_current_site() or
similar) and
see if I can serve multiple sites+databases from the same Django instance.

Not sure if that helps, or even it it'll work, but if it does it might do
what you need.

Cheers,

Anthony

On 9 May 2012 13:02, Alec Taylor  wrote:

> Dear Django-developers,
>
> I've been using Django for a few months now, and recently—for
> different projects—started using the web-framework: web2py[1], and the
> Django project: mezzanine[2].
>
> Both advertise as being multi-tenant solutions[3][4].
>
> Would it be possible to extend Django to meet this use-case? — Or have
> I overlooked something and is this possible already?
>
> Thanks for all information,
>
> Alec Taylor
>
> [1] http://www.web2py.com/
> [2] http://mezzanine.jupo.org/
> [3] https://groups.google.com/forum/#!topic/mezzanine-users/4XPe5MaD4Fw
> [4] PyCon 2012 talk: http://youtu.be/M5IPlMe83yI?t=5m32s
> http://dl.dropbox.com/u/18065445/Slides/PySFTalkSlides.pdf (slide42,
> see yt for more info)
>
> --
> 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.



Incorrect serialization for 3d GEOSGeometry

2012-05-15 Thread Craig de Stigter
Hi folks


I discovered django.contrib.gis support for 3d geometries is pretty 
patchy. I realised that the database stuff only worked in postgis, etc, but 
it turns out even the serialisation methods on GEOSGeometry don't work 
properly.

Here's a small test script that demonstrates the problem: 
https://gist.github.com/2594905

And here's the output: https://gist.github.com/2594926

In summary, all these properties return 2d-only output for 3d geometries 
(the Z dimension gets stripped):

   - wkt
   - ewkt
   - hex
   - wkb
   - json
   - geojson
   
Yet these others produce correct 3d output:

   - ewkb
   - hexewkb
   - kml

Is there any reasoning behind this, or should I create a ticket and try to 
fix them?

I tried posting this to the geodjango list 
(here),
 
but I'm not sure if anyone actually reads those posts, as I haven't got a 
response in 10 days.

Thanks
Craig de Stigter

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-developers/-/s4smWq7j4xIJ.
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: Multi-tenant Django

2012-05-15 Thread Alec Taylor
Thanks Anthony,

Looking forward to seeing your results :)

On Tue, May 15, 2012 at 7:30 PM, Anthony Briggs
 wrote:
> Hi Alec,
>
> One of the science experiments on my todo list is to try and set up one of
> the fancy new database routers (possibly with get_current_site() or
> similar) and see if I can serve multiple sites+databases from the same
> Django instance.
>
> Not sure if that helps, or even it it'll work, but if it does it might do
> what you need.
>
> Cheers,
>
> Anthony
>
> On 9 May 2012 13:02, Alec Taylor  wrote:
>>
>> Dear Django-developers,
>>
>> I've been using Django for a few months now, and recently—for
>> different projects—started using the web-framework: web2py[1], and the
>> Django project: mezzanine[2].
>>
>> Both advertise as being multi-tenant solutions[3][4].
>>
>> Would it be possible to extend Django to meet this use-case? — Or have
>> I overlooked something and is this possible already?
>>
>> Thanks for all information,
>>
>> Alec Taylor
>>
>> [1] http://www.web2py.com/
>> [2] http://mezzanine.jupo.org/
>> [3] https://groups.google.com/forum/#!topic/mezzanine-users/4XPe5MaD4Fw
>> [4] PyCon 2012 talk: http://youtu.be/M5IPlMe83yI?t=5m32s
>> http://dl.dropbox.com/u/18065445/Slides/PySFTalkSlides.pdf (slide42,
>> see yt for more info)
>>
>> --
>> 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.

-- 
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.



#18277 : Passing additional context to startproject command

2012-05-15 Thread Dominique Guardiola Falco
Jezdez said he wanted to discuss the point of this feature.
I posted a very simple working patch (I only have a yellow belt in 
django/python)
As this was advertised as possible in the docs, I wanted to pass more 
variables to the project template rendering command (./manage.py 
startproject --template)

Example use case : in order to make a valid wsgi.py file, pass the 
virtualenv site-packages folder path 

Now for the discussion of is it a good idea : the command in itself 
empowers us to create our own templates
Big apps already use this kind of template-base-project : satchmo and 
mezzanine are two examples. I'm sure they could also benefit from this 
additional context feature.


Dominique
http://quinode.fr/

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-developers/-/LyuFjhJNiv8J.
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: Django 1.4 bug: Using cache_page and csrf_protect decorators results in a messy Set-Cookie response header.

2012-05-15 Thread Rafał Stożek
Should we reopen https://code.djangoproject.com/ticket/15863 then?

On Mon, May 14, 2012 at 4:39 PM, Suteepat Damrongyingsupab <
tianiss...@gmail.com> wrote:

> Hi all,
> Thanks for your help to investigate the issue. I didn't have a chance to
> look further into it.
> So every class-based views that subclass from TemplateResponseMixin are
> affected by this bug because it uses TemplateResponse as its response_class.
>
>
>
> On Monday, May 14, 2012 7:28:50 PM UTC+7, Rafał Stożek wrote:
>>
>> Oh, I see where the bug is. SimpleTemplateResponse.__**getstate__ does
>> not call super(). And HttpResponse class serializes cookies in its
>> __getstate__ method. So basically SimpleTemplateResponse doesn't serialize
>> cookies correctly.
>>
>> On Mon, May 14, 2012 at 1:25 PM, Rafał Stożek  wrote:
>>
>>> Could you try again to cause bug with SafeView class, but this time
>>> using TemplateResponse class instead of render_to_response shortcut?
>>>
>>>
>>> On Mon, May 14, 2012 at 10:24 AM, Suteepat Damrongyingsupab <
>>> tianiss...@gmail.com> wrote:
>>>
 I've just found the root cause of the problem.
 The bug occurs when using ListView (I haven't tested other CBV though)
 and decorating it with cache_page and csrf_protect.
 I've tested it with a new clean project and left settings.py as a
 default.
 The simple code I used to test is as follows:

 *urls.py (excerpt):*
 url(r'safe/$', cache_page(1800)(csrf_protect(**
 SafeView.as_view(,
 url(r'bug/$', cache_page(1800)(csrf_protect(**BugView.as_view(,

 *views.py:*
 from django.template import RequestContext
 from django.views.generic import View, ListView

 class SafeView(View):
 template_name = 'basic/index.html'

 def get(self, request):
 return render_to_response('basic/**index.html', {'msg':
 'Hello, world'}, context_instance=**RequestContext(request))

 class BugView(ListView):
 template_name = 'basic/index.html'
 queryset = []

 *template (basic/index.html):*
 Today message: {{ msg }}{% csrf_token %}

 I kept reloading the SafeView page (20+ times) and the bug didn't occur.
 You should try reloading the BugView page and the bug will occur within
 10 reloading times.




 On Monday, May 14, 2012 12:14:21 AM UTC+7, Paul McMillan wrote:
>
> That looks a lot like 15863.
> https://code.djangoproject.**com**/ticket/15863
>
> Which cache backend are you using? Which session backend? Are you
> absolutely positive you are using Django 1.4, and not a
> system-installed version of 1.3? Does your code pickle or unpickle
> sessions or cookies anywhere outside of the caching framework?
>
> I thought we fixed that bug, but if you can provide minimal steps to
> reproduce it in Django 1.4, we'll have to reopen the ticket.
>
> -Paul
>
> On Sat, May 12, 2012 at 1:13 PM, Suteepat Damrongyingsupab
>  wrote:
> > I'm using Django 1.4.
> > According to the Django csrf docs, I decorate my class-based view in
> the
> > urls.py as follows:
> >
> > cache_page(1800)(csrf_protect(MyView.as_view()))
> >
> > I kept reloading MyView page url and Set-Cookie header would be
> recursive
> > like this:
> >
> > Set-Cookie: csrftoken="Set-Cookie: csrftoken=\"Set-Cookie:
> > csrftoken=**XeRCBpXuNpuRie17OqWr**DIM3xKt9hV**3Q\\073
> expires=Sat\\054 11-May-2013
> > 19:50:21 GMT\\073 Max-Age=31449600\\073 Path=/\""
> >
> > I don't know what's a trigger to this behavior.
> > Has anyone found a problem like this? Please help.
> > Thanks.
> >
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups
> > "Django developers" group.
> > To view this discussion on the web visit
> > https://groups.google.com/d/**ms**g/django-developers/-/**Q5Ywwf3O**
> 0sIJ.
>
> > To post to this group, send email to django-developers@**
> googlegroups**.com .
> > To unsubscribe from this group, send email to
> > django-developers+unsubscribe@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 view this discussion on the web visit https://groups.google.com/d/**
 msg/django-developers/-/**9YkZgDFQTfYJ
 .

 To post to this group, send email to django-developers@**
 googlegroups.com .
 To unsubscribe from this group, send ema

Authentication page

2012-05-15 Thread francescobocca...@libero.it
Hi all,
i'm new of Django world and i would like to create  for my web site an 
autentication page (login, logout, sign up, change user , etc..)
How can found a tutorial to do that? Anyone can suggest me ho build that?
Thanks

Francesco

-- 
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: Authentication page

2012-05-15 Thread Gert Van Gool
django-developers is for the discussion of the development of Django
itself, not development with Django.
As such this mailing list is not appropriate for this message,
django-users would be more appropriate.

-- Gert

Mobile: +32 498725202
Twitter: @gvangool
Web: http://gertvangool.be


On Tue, May 15, 2012 at 3:55 PM, francescobocca...@libero.it
 wrote:
> Hi all,
> i'm new of Django world and i would like to create  for my web site an
> autentication page (login, logout, sign up, change user , etc..)
> How can found a tutorial to do that? Anyone can suggest me ho build that?
> Thanks
>
> Francesco
>
> --
> 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.



Exception Middleware not run [was Re: Subclass handle_uncaught_exception]

2012-05-15 Thread Rory Campbell-Lange
On further investigation it appears that the process_exception
middleware isn't being called in my case. In other words, 

 /usr/lib/python2.7/dist-packages/django/utils/decorators.py:
 92 except Exception, e:
 93 import ipdb; ipdb.set_trace()
 94 if hasattr(middleware, 'process_exception'):
 95 result = middleware.process_exception(request, e)
 96 if result is not None:
 97 return result

I'm not familiar enough with Django to work out the relationship between
base.py and decorators.py. However the middleware class above does not have the
class I have loaded in base.py's self._exception_middleware. Should it have?

Rory

On 14/05/12, Rory Campbell-Lange (r...@campbell-lange.net) wrote:
> I have a custom database interface with (amongst other things) a lazy
> rowgetter. Our database provides custom exception messages when, for instance,
> a rate limit is exceeded.
> 
> Because of the "laziness" of the rowgetter, the except clause in my view
> (shown below) is not triggered, and control falls to
> core/handlers/base.py : handle_uncaught_exception.
> 
> try:
> rota = self.model.xmlapi_get_location (**kwargs)
> except DBException, e:
> code, message = [epart.strip() for epart in e.msg.split(':')]
> return HttpResponse(message, status=code,
> content_type="text/plain")
> 
> I've tried the following:
> 
> * The use of middleware using "process_exception" : DBException not raised
> * handler500 in urls : DBException not available
> 
> Consequently I believe I need to either make my lazy rowgetter less lazy so
> that it errors earlier, or subclass handle_uncaught_exception. If the latter 
> is
> feasible I'd be grateful for some advice on how to do so within my app.
> 
> Rory
> 
> p.s.
> An earlier version of this question was asked on Stack Overflow at
> http://stackoverflow.com/questions/10574581/reroute-djangos-handle-uncaught-exception

-- 
Rory Campbell-Lange
r...@campbell-lange.net

-- 
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: Bug (in 1.4+) double slash in URL leads to incorrect ``request.build_absolute_uri()``

2012-05-15 Thread Yo-Yo Ma
I've attached a diff in the ticket I created, and I resolved the
ticket as "fixed" (as habit, I'm used to doing this for work, allowing
QA to change the status to "closed" after testing). Is this correct?
Also, is it better to fork Django and make a pull request on GitHub,
or simply provide the git diff as I did (the docs on contributing
don't really make mention of any new GitHub-related polices)?

On May 13, 10:02 pm, Russell Keith-Magee 
wrote:
> Thanks for the report -- but is there a particular reason that you're
> reporting this here, rather than on the ticket tracker?
>
> Yours,
> Russ Magee %-)
>
>
>
>
>
>
>
> On Mon, May 14, 2012 at 9:55 AM, Yo-Yo Ma  wrote:
> > A request to:
>
> >    http://www.example.com:8080//foo-bar-baz.html
>
> > leads to request.build_absolute_uri() returning:
>
> >    http://foo-bar.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 
> > athttp://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: Bug (in 1.4+) double slash in URL leads to incorrect ``request.build_absolute_uri()``

2012-05-15 Thread Aymeric Augustin
Hello,

On 15 mai 2012, at 21:36, Yo-Yo Ma wrote:
> I've attached a diff in the ticket I created, and I resolved the
> ticket as "fixed" (as habit, I'm used to doing this for work, allowing
> QA to change the status to "closed" after testing). Is this correct?

We resolve tickets as "fixed" only once a patch is committed.

See 
https://docs.djangoproject.com/en/dev/internals/contributing/triaging-tickets/#triage-workflow

> Also, is it better to fork Django and make a pull request on GitHub,
> or simply provide the git diff as I did

As you wish!

Best regards,

-- 
Aymeric.

-- 
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: Multi-tenant Django

2012-05-15 Thread charettes
Using django-hosts I managed to put together a simple setup that maps 
subdomains to databases.

First, I have a default database with a table mapping sudomains to database 
name and a middleware that tries to load the correct object based on the 
match provided by django-hosts.

In my settings I have a *placeholder* database that gets replaced by the 
middleware if the subdomain is mapping to a database.

Finally I have a database router that returns the *placeholder* db alias 
when models are subdomain specific.

This setup is working pretty well so far.

Hope it helps!

Le mardi 15 mai 2012 05:30:28 UTC-4, Anthony Briggs a écrit :
>
> Hi Alec,
>
> One of the science experiments on my todo list is to try and set up one of 
> the fancy new database routers (possibly with get_current_site() or 
> similar) and see if I can serve multiple sites+databases from the same 
> Django instance.
>
> Not sure if that helps, or even it it'll work, but if it does it might do 
> what you need.
>
> Cheers,
>
> Anthony
>
> On 9 May 2012 13:02, Alec Taylor  wrote:
>
>> Dear Django-developers,
>>
>> I've been using Django for a few months now, and recently—for
>> different projects—started using the web-framework: web2py[1], and the
>> Django project: mezzanine[2].
>>
>> Both advertise as being multi-tenant solutions[3][4].
>>
>> Would it be possible to extend Django to meet this use-case? — Or have
>> I overlooked something and is this possible already?
>>
>> Thanks for all information,
>>
>> Alec Taylor
>>
>> [1] http://www.web2py.com/
>> [2] http://mezzanine.jupo.org/
>> [3] https://groups.google.com/forum/#!topic/mezzanine-users/4XPe5MaD4Fw
>> [4] PyCon 2012 talk: http://youtu.be/M5IPlMe83yI?t=5m32s
>> http://dl.dropbox.com/u/18065445/Slides/PySFTalkSlides.pdf (slide42,
>> see yt for more info)
>>
>> --
>> 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-developers/-/wQHSDXdAv3cJ.
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: Incorrect serialization for 3d GEOSGeometry

2012-05-15 Thread Russell Keith-Magee
On Tue, May 15, 2012 at 8:02 PM, Craig de Stigter  wrote:
> Hi folks
>
>
> I discovered django.contrib.gis support for 3d geometries is pretty
> patchy. I realised that the database stuff only worked in postgis, etc, but
> it turns out even the serialisation methods on GEOSGeometry don't work
> properly.
>
> Here's a small test script that demonstrates the
> problem: https://gist.github.com/2594905
>
> And here's the output: https://gist.github.com/2594926
>
> In summary, all these properties return 2d-only output for 3d geometries
> (the Z dimension gets stripped):
>
> wkt
> ewkt
> hex
> wkb
> json
> geojson
>
> Yet these others produce correct 3d output:
>
> ewkb
> hexewkb
> kml
>
> Is there any reasoning behind this, or should I create a ticket and try to
> fix them?

I'm afraid I'm not an expert on Django's GIS libraries, so I can't
speak with authority as to whether the stripping of the Z axis is
deliberate or accidental. It feels like something that is probably
accidental, but it *might* be deliberate.

If I were in your shoes, the first way I'd check would be to make the
change to the serializer for one of the fields, and see if that change
breaks Django's test suite (in particular, the GIS portions). In
theory, everything in Django should be tested, so there *should* be a
test covering serialisation of GIS.

Failing that, you'll need some expertise from someone that knows the
GIS code well.

Sorry I can't be much more help than that.

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: Multi-tenant Django

2012-05-15 Thread Anssi Kääriäinen
On May 16, 12:18 am, charettes  wrote:
> Using django-hosts I managed to put together a simple setup that maps
> subdomains to databases.
>
> First, I have a default database with a table mapping sudomains to database
> name and a middleware that tries to load the correct object based on the
> match provided by django-hosts.
>
> In my settings I have a *placeholder* database that gets replaced by the
> middleware if the subdomain is mapping to a database.
>
> Finally I have a database router that returns the *placeholder* db alias
> when models are subdomain specific.
>
> This setup is working pretty well so far.

How to implement "database per client" is a commonly asked questions
in django-users. So, if you have something to share I think there
would be interested users.

Note that what you have done above will work only in 1.4+. In 1.3 the
connections dictionary wasn't thread-local object, and thus you are
changing the placeholder database for all threads - not just the
currently running thread.

 - Anssi

-- 
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.