Re: Proposal: django.forms.SafeForm - forms with built in CSRF protection

2008-09-24 Thread Rudolph
I like Luke's arguments. A middleware seems like the right place because CSRF protection is about requests and responses. CSRF protection is more about POST requests in generic, with HTML forms being a very common type of POST request. IMHO the default settings.py file (generated with 'django-ad

Iteration over lines in uploaded files only supports `\n` line endings.

2008-09-24 Thread Tai Lee
In #8149 [1] I reported that `UploadedFile` uses `StringIO` to iterate through uploaded files line-by-line, but `StringIO` only treats `\n` as a line ending, at least in the current version. This effectively means we can't use line-by-line iteration over uploaded files because we don't know what

Re: session backed form wizard

2008-09-24 Thread Eduardo O. Padoan
On Wed, Sep 24, 2008 at 8:36 PM, David Durham, Jr. <[EMAIL PROTECTED]> wrote: > > Hi all, > > I posted a patch for django.contrib.formtools.wizard that adds a > SessionWizard class. I'd like to know if there's any interest in > apply this or a similar patch, and if so I'll work on tests and > doc

Re: Iteration over lines in uploaded files only supports `\n` line endings.

2008-09-24 Thread zvoase
This is an issue with Python, not Django in particular, although something could be done in Django to remedy this issue. I've already encountered this problem before, and I developed a solution which may (or may not) be optimal. I implemented the solution in two parts: * The first part was a g

Re: Proposal: django.forms.SafeForm - forms with built in CSRF protection

2008-09-24 Thread oggy
On Sep 24, 11:17 am, Simon Willison <[EMAIL PROTECTED]> wrote: > It turns out it's not that straight-forward after all: > > http://icanhaz.com/csrfpdf(PDF link, "Robust Defenses for Cross-Site > Request Forgery") > > The above paper introduces the "login CSRF" attack, where CSRF is used > to force

session backed form wizard

2008-09-24 Thread David Durham, Jr.
Hi all, I posted a patch for django.contrib.formtools.wizard that adds a SessionWizard class. I'd like to know if there's any interest in apply this or a similar patch, and if so I'll work on tests and documentation. http://code.djangoproject.com/ticket/9200 Thanks, Dave --~--~-~--~--

Re: Proposal: Let Context handle template loading (#7815)

2008-09-24 Thread Johannes Dollinger
I should have made this more accessible .. http://code.djangoproject.com/ticket/2949 "I want to be able to set the path to a directory that contains the templates I want to render at runtime. [...] The basic thing I'm looking for is to be able to load a template from a specific, arbitrary p

Re: Optimizations on templates

2008-09-24 Thread Johannes Dollinger
Am 25.09.2008 um 00:39 schrieb Manuel Saelices: > > It's a different aproach. I consider my cache attempt a optimization > like URL dispatcher cache, without considering django cache system, > like url resolvers cache, _join_cache in orm or other many cases. > Also, I'm not sure that #6262 consi

Re: Optimizations on templates

2008-09-24 Thread Manuel Saelices
It's a different aproach. I consider my cache attempt a optimization like URL dispatcher cache, without considering django cache system, like url resolvers cache, _join_cache in orm or other many cases. Also, I'm not sure that #6262 consider the inheritance problem (look at copy.deepcopy(self.get_

Re: Optimizations on templates

2008-09-24 Thread Johannes Dollinger
Am 25.09.2008 um 00:10 schrieb Manuel Saelices: > > Hi, > > one week ago I've made a little change in template rendering engine to > get a huge performance improvement, in template rendering: > > http://code.djangoproject.com/ticket/9154 > > The optimizations where two: > 1) cache loaded templa

Re: admin doesn't allow more than one null fk where unique=True

2008-09-24 Thread Karen Tracey
On Wed, Sep 24, 2008 at 4:49 PM, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote: > > I'll go upload a fix now, the current behavior doesn't make sense, > since the SQL spec says that NULL != NULL, does anyone know if there > are any dbs for which this isn't true? > There are a couple of oddball DB

Optimizations on templates

2008-09-24 Thread Manuel Saelices
Hi, one week ago I've made a little change in template rendering engine to get a huge performance improvement, in template rendering: http://code.djangoproject.com/ticket/9154 The optimizations where two: 1) cache loaded templates that becames compiled. In a threaded environment, with many con

Re: admin doesn't allow more than one null fk where unique=True

2008-09-24 Thread smcoll
Thanks Alex! You get one virtual beer... shannon On Sep 24, 3:49 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'll go upload a fix now, the current behavior doesn't make sense, > since the SQL spec says that NULL != NULL, does anyone know if there > are any dbs for which this isn't true

Nightly builds of ubuntu packages for Django trunk

2008-09-24 Thread elliot
Hi! I set up nightly builds of ubuntu packages for Hardy (8.04) and Intrepid (8.10) of django trunk. This runs via a bzr import of django trunk on launchpad, and has the revision number of trunk embedded in the package version number, so you should be able to upgrade each day. The PPA is here: h

Re: admin doesn't allow more than one null fk where unique=True

2008-09-24 Thread [EMAIL PROTECTED]
I'll go upload a fix now, the current behavior doesn't make sense, since the SQL spec says that NULL != NULL, does anyone know if there are any dbs for which this isn't true? On Sep 19, 11:10 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Fri, Sep 19, 2008 at 10:51 AM, smcoll <[EMAIL PROTECTE

Re: admin doesn't allow more than one null fk where unique=True

2008-09-24 Thread smcoll
i think this has to be fixed in the current code. i wish i knew how to fix it, or i'd close #9062. The ticket hasn't gotten any attention, but i feel like it's a biggie. i'm surprised it's not breaking other people's apps. shannon On Sep 19, 10:10 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:

Re: Inner imports in core code

2008-09-24 Thread Ludvig Ericson
On Sep 24, 2008, at 18:27, Alex Myodov wrote: > Being curious, had tried several benchmarks as well. > Indeed, the function-level imports have some overhead. But the > overhead becomes less and less important, as long as the function > complexity increases. If a function does nothing except import

Re: Proposal: django.forms.SafeForm - forms with built in CSRF protection

2008-09-24 Thread Luke Plant
Hi Simon, > CSRF[1] is one of the most common web application vulnerabilities, but > continues to have very poor awareness in the developer community. > Django ships with CSRF protection in the form of middleware, but it's > off by default. I'm willing to bet most people don't turn it on. > > I

Re: Inner imports in core code

2008-09-24 Thread Alex Myodov
Being curious, had tried several benchmarks as well. Indeed, the function-level imports have some overhead. But the overhead becomes less and less important, as long as the function complexity increases. If a function does nothing except import (as in your case), the performance hit is several hun

Re: Proposal: django.forms.SafeForm - forms with built in CSRF protection

2008-09-24 Thread David Durham, Jr.
On Wed, Sep 24, 2008 at 9:00 AM, Simon Willison <[EMAIL PROTECTED]> wrote: > > On Sep 24, 2:18 pm, zellyn <[EMAIL PROTECTED]> wrote: >> Would it make sense to have the middleware/view decorator set a >> property on the request, and pass the request to all forms, and have >> *all* forms CSRF-protec

Re: Proposal: django.forms.SafeForm - forms with built in CSRF protection

2008-09-24 Thread zellyn
On Sep 24, 10:00 am, Simon Willison <[EMAIL PROTECTED]> wrote: > That's an interesting idea. I'm a bit cautious of requiring ALL forms > to take a request object though - Django's current form library is > decoupled from Django's request object, which is actually a really > useful property. I've

Proposal: Let Context handle template loading (#7815)

2008-09-24 Thread Johannes Dollinger
#7815[1]: * Adds a loader kwarg to Context which should be something with a get_template(name) function. Default would be django.template.loader. * Provides get_template() and select_template() methods on Context. These are used in {% include %}, {% extends %} and inclusion_tag. * Caches temp

Re: Proposal: django.forms.SafeForm - forms with built in CSRF protection

2008-09-24 Thread Simon Willison
On Sep 24, 2:18 pm, zellyn <[EMAIL PROTECTED]> wrote: > Would it make sense to have the middleware/view decorator set a > property on the request, and pass the request to all forms, and have > *all* forms CSRF-protect themselves when the property is set? That > would make it easy to add protection

Re: Inner imports in core code

2008-09-24 Thread Ludvig Ericson
On Sep 24, 2008, at 14:52, Simon Willison wrote: > Not entirely sure how I managed to miss your benchmark figures when I > read your mail, but I'm wrong here - there's clearly a performance > overhead involved in importing inside a function. It would be > interesting to see how much this affects D

Re: Proposal: django.forms.SafeForm - forms with built in CSRF protection

2008-09-24 Thread zellyn
I like the middleware/view decorator for setting the cookie. Would it make sense to have the middleware/view decorator set a property on the request, and pass the request to all forms, and have *all* forms CSRF-protect themselves when the property is set? That would make it easy to add protection

Re: Inner imports in core code

2008-09-24 Thread Simon Willison
On Sep 24, 1:40 pm, Simon Willison <[EMAIL PROTECTED]> wrote: > As a result the performance overhead from having imports inside > functions as opposed to at module level should be virtually non- > existent. Not entirely sure how I managed to miss your benchmark figures when I read your mail, but

Re: Inner imports in core code

2008-09-24 Thread Simon Willison
On Sep 24, 8:37 am, David Cramer <[EMAIL PROTECTED]> wrote: > I was digging through some code today, and I noticed imports are > happening within a lot of functions. It was my knowledge that it works > like so: > > import in a function is the same as ruby's load or php's include -- > its executed

Re: Inner imports in core code

2008-09-24 Thread Jeremy Dunck
Note that in some cases, dynamic imports are done to avoid loading a Django subsystem, large external library, or optional dependency until it is strictly necessary. There are certainly still examples where none of those good reasons apply. On Sep 24, 2008, at 2:37 AM, David Cramer <[EMAIL

Re: Proposal: django.forms.SafeForm - forms with built in CSRF protection

2008-09-24 Thread Simon Willison
On Sep 23, 11:23 pm, Simon Willison <[EMAIL PROTECTED]> wrote: > CSRF attacks are a problem for systems where an action is only meant > to be available to a specific logged in user. This user is inevitably > identified by a unique cookie. This is normally a session cookie, > hence many CSRF protec

Re: Proposal: django.forms.SafeForm - forms with built in CSRF protection

2008-09-24 Thread Rudolph
I'd like to discuss if forms should try to be secure by default? It's a bit like the autoescaping discussion. The new Form class would need to accept dictionaries or request objects as input. A dictionary is however only accepted if you explicitly disable CSRF protection: form = MyForm(request.PO

Re: Denormalisation, magic, and is it really that useful?

2008-09-24 Thread David Cramer
Denormalized for me personally happens a LOT when it's not just a simple foreign key. Maybe I want to store a many to many field as name,name,name in a column (tags). We're already inside of Django so it should already be available (it's not going to be much slower than it is executing the subquer

Re: Denormalisation, magic, and is it really that useful?

2008-09-24 Thread David Cramer
I just wanted to touch on this point: models.IntegerField(default=0) does not translate to INT(11) default 0; in SQL :) Django doesn't nescesarily try to interact with the database properly when it should, because it requires too much thinking (and more code that hasn't been written). I would s

Inner imports in core code

2008-09-24 Thread David Cramer
I was digging through some code today, and I noticed imports are happening within a lot of functions. It was my knowledge that it works like so: import in a function is the same as ruby's load or php's include -- its executed everytime the function is import in a module outside a function is lik