Prefix for URLs?

2007-01-24 Thread vfoley

Hello,

one thing that bugs me about URL patterns is that you can specify a
prefix only for the view functions to call, not for the URLs to match.
A quick example

web request:
http://localhost/project/view/1/

urls.py:
urlpatterns = patterns('', (r'^view/(?P\d+)/$',
'myproject.myapp.views.view'),)

The client will get a 404, because 'project/view/1/' isn't matched.
Now, I could add project to all my regular expressions, but that seems
like a whole lot of repetition.  Instead, could we have another
parameter for patterns() that would trim this part off the passed URL?
Example:

urls.py:
urlpatterns = patterns('', prefix_url='project/',
(r'^view/(?P\d+)/$', 'myproject.myapp.views.view'),)

And the previous URL would now work.  If this is something that could
be useful and that is not currently being worked on, I could try my
hand at modifying the relevant functions and classes.  Due to the risk
of breaking older applications, this could be another function.

Vincent


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



filesizeformat filter

2007-02-01 Thread vfoley

According to the Django template documentation for developpers (http://
www.djangoproject.com/documentation/templates_python/#writing-custom-template-filters),
a filter shouldn't raise an exception, it should silently ignore
errors.

The filesizeformat filter raises an exception for an inexistant file.
Should this be fixed?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: filesizeformat filter

2007-02-01 Thread vfoley

I just saw that filesizeformat expects a number bytes.  So the culprit
in my case would be get_file_size.  Not sure if this one should fail
silently...

On Feb 1, 12:39 pm, "vfoley" <[EMAIL PROTECTED]> wrote:
> According to the Django template documentation for developpers 
> (http://www.djangoproject.com/documentation/templates_python/#writing-custom-...),
> a filter shouldn't raise an exception, it should silently ignore
> errors.
>
> The filesizeformat filter raises an exception for an inexistant file.
> Should this be fixed?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: filesizeformat filter

2007-02-04 Thread vfoley

It was in my my unit tests, instead of properly upload a file, I just
set the name to "whatever.pdf", but when I loaded the detail page,
Python couldn't find the file, so it raised an OSError.  I don't think
I can qualify that as a bug.

On Feb 3, 4:52 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> That does sound like a bug to me, can you file a ticket with an
> example of where it's going wrong (i.e. what value you're giving it?)
>
> Cheers,
> Simon G.
>
> On Feb 2, 6:43 am, "vfoley" <[EMAIL PROTECTED]> wrote:
>
> > I just saw that filesizeformat expects a number bytes.  So the culprit
> > in my case would be get_file_size.  Not sure if this one should fail
> > silently...
>
> > On Feb 1, 12:39 pm, "vfoley" <[EMAIL PROTECTED]> wrote:
>
> > > According to the Django template documentation for developpers 
> > > (http://www.djangoproject.com/documentation/templates_python/#writing-..),
> > > a filter shouldn't raise an exception, it should silently ignore
> > > errors.
>
> > > The filesizeformat filter raises an exception for an inexistant file.
> > > Should this be fixed?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Newforms: colon after label

2007-03-27 Thread vfoley

Hello,

I rewrote the forms portion of an application by using newforms.  It's
pretty nice, however there is something extremely annoying: newforms
automatically adds a colon after labels (hopefully, my formatting is
correct):

Out[58]: class ExampleForm(forms.Form):
 name = forms.CharField(label='Your name')
 yob  = forms.CharField(label='Year of birth')

In [59]: example = ExampleForm()

In [60]: print example.as_p()
Your name: 
Year of birth: 


See?  I specified the label to be "You name" and "Year of birth"
without the colon, but newforms adds it automatically.  I think this
is set on line 124 of django.newforms.forms.py:

label = bf.label and bf.label_tag(escape(bf.label + ':')) or ''

I don't think the library should add text like that, what do you
think?

Vincent.

P.S: This code is from 0.96, I haven't checked the Subversion tree.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Ticket #5172 discussion

2007-09-24 Thread vfoley

SmileyChris added a ticket to propose extending the for loop tag to
support numerical looping.  I posted a patch that adds such a
capability and includes a few tests.  Documentation is still lacking.
Let me know what you think, here are some code examples:

{% for i 1 to 5 %}
{{ i }}
{% endfor %}

{% for i 1 to 5 by 2 exclusive %}
{{ i }}
{% endfor %}

{% for i 5 to 1 by -2 %}
{{ i }}
{% endfor %}

http://code.djangoproject.com/ticket/5172


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: Ticket #5172 discussion

2007-09-25 Thread vfoley

Most likely.  I implemented it just to get more insight into Django's
internals, but I'm -0 on this ticket.  I have never needed anything
more than my range0 and range1 filters (10|range0 => range(10); 10|
range1 => range(1, 11))

On Sep 25, 5:43 am, "Andrew Durdin" <[EMAIL PROTECTED]> wrote:
> On 9/25/07, vfoley <[EMAIL PROTECTED]> wrote:
>
>
>
> > SmileyChris added a ticket to propose extending the for loop tag to
> > support numerical looping.  I posted a patch that adds such a
> > capability and includes a few tests.  Documentation is still lacking.
> > Let me know what you think, here are some code examples:
>
> > {% for i 1 to 5 %}
> > {{ i }}
> > {% endfor %}
>
> Wouldn't a filter or two solve this problem equally well?
>
> {% for i in 1|to:5 %}{{ i }}{% endfor %}
>
> {% for i in 5|to:1 %}{{ i }}{% endfor %}
>
> {% for i in 1|to:5|every:2 %}{{ i }}{% endfor %}
>
> @register.filter
> def to(start, finish):
> start, finish = int(start), int(finish)
> if finish > start:
> step = 1
> else:
> step = -1
> return range(start, finish + step, step)
>
> @register.filter
> def every(seq, step):
> return seq[::step]
>
> Andrew


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---