Re: Status of the #6904 ticket (case insensitive sort in dictsort)

2009-10-16 Thread Michael P. Jung
The collation for other languages than English is not that simple. e.g. the German Umlaut "ä" is often seen equivalent to "ae" when ordering lists. Thus a list like [u'baf', u'bäx', u'baz'] would be sorted [u'bäx', u'baf', u'baz']. There are even some collations that just treat 'ä' as an 'a' and

Re: shortcut proposal

2009-10-16 Thread Michael P. Jung
Some time ago I came up with a decorator to enable rendering jinja2 templates easily. The decorator 'monkey patches' the request object by providing a __getattr__ method and adding some new methods. https://labs.pyrox.eu/common/jinja2/tree/django.py This could be easily adapted for django templa

Are threading.local objects evil? (was Re: shortcut proposal)

2009-10-16 Thread Michael P. Jung
Hi Alex, mp> I've found it to be way more practical to just store the request object mp> inside a threading.local object and let my functions access it directly. mp> (...) Alex> Quite simply, no. Storing anything in a threadlocal instead of Alex> passing it around is indicative of bad coding pr

Re: Are threading.local objects evil? (was Re: shortcut proposal)

2009-10-16 Thread Michael P. Jung
Jeremy Dunck wrote: > Alex just spent a bunch of time adding multi-db support; part of the > effort involved in that work was removing the > request=thread=connection assumption that tied django to a single DB. Untying the database session from the request response cycle makes sense for multi-db

Re: Are threading.local objects evil? (was Re: shortcut proposal)

2009-10-16 Thread Michael P. Jung
James Bennett wrote: > Setting aside async concerns, making the request available implicitly > would be both counter to that overall design (and I'm very much a fan > of that design, and I suspect its simplicity and understandability is > part of why Django's popular), and feels like an attempt to

Re: Can you add a build-in template tags?

2009-10-19 Thread Michael P. Jung
> There is a templatetags {% include 'x.html' %}, it's very nice. may a > templatetags like {% include no-parse "x.html"} is needed. It's so > powerful to improve the speed of include some static files which has > no variable,and it's so easy for you guys, isn't it? It'd be very easy to add an t

Proposal for __neq field lookup

2009-10-20 Thread Michael P. Jung
I'd like to propose a new field lookup __neq which could be used to negate a single parameter. It is not ment to make exclude() obsolete, as they both have a different scope: filter(x__neq=1, y__neq=2) would translate to "(x <> 1 AND y <> 2)" while exclude(x=1, y=2) translates to "NOT (x = 1 AND

Re: Proposal for __neq field lookup

2009-10-20 Thread Michael P. Jung
rm> exclude(x=1).exclude(y=2) translates to NOT (x=1) AND NOT (y=2) So why do we have __gt, __ge, __lt, __le then? It would be as simple to have only __le and get rid of the rest as it can easily expressed using exclude and filter. I know, it's picky, but you get my point. I don't see why all co

Re: Custom fields and PostGreSQL composite types

2009-10-20 Thread Michael P. Jung
I've written something called a 'CompositeField' which basicly does what you're looking for by grouping fields together. Assume you want to have an AddressField you could define it the following way: class AddressField(CompositeField): def __init__(self, blank=False): super(AddressFie

Re: Can you add a build-in template tags?

2009-10-20 Thread Michael P. Jung
> How can I cache the sub-template witch is included in the main > template? And how can I ensure it won't be render(parse) the next > request? If you look at django.template.loader_tags.do_include you'll notice an if statement that checks if the given argument was a string. If so it'll use a Con

Proposal for new field type: CompositeField

2009-12-24 Thread Michael P. Jung
Quite often I find myself in the need of fields composed of other fields. e.g. class AddressField(CompositeField): addressee = models.CharField(max_length=50) street = models.CharField(max_lenght=50) zipcode = models.CharField(max_lenght=10) # ... more fields he

Re: Proposal for new field type: CompositeField

2009-12-24 Thread Michael P. Jung
On 2009-12-24 19:45, Stephen Crosby wrote: > In your address example, I'm not sure what advantage this > CompositeField has over just creating an address model/table and > using a regular foreign key to reference it. You mentioned the need > to create a field composed of other fields which to me so

Re: Proposal for new field type: CompositeField

2009-12-26 Thread Michael P. Jung
On 2009-12-26 05:17, Andy Mikhailenko wrote: > Maybe I'm missing something, but I don't understand how is this > different from having a bunch of separate fields. The CompositeField > adds a namespace, but foo.bar_x=1 seems to be no harder to read than > foo.bar.x=1. I must admit that this field

Re: Proposal for new field type: CompositeField

2009-12-26 Thread Michael P. Jung
I just implemented [1] the ComplexNumberField using the CompositeField class. It also shows that it is possible to change subfield attributes inside the __init__ method since the subfields are deep copied for every instance. I hope that the test cases are mostly complete. I plan on writing down th

DjangoCon.eu sprint proposal: New field type "CompositeField"

2010-05-26 Thread Michael P. Jung
Some time ago I proposed a new field type called "CompositeField". It's basicly a way of doing composition in Django models. Its usage looks like: class CoordField(CompositeField): x = models.FloatField() y = models.FloatField() class Place(models.Model): name =

Re: DjangoCon.eu sprint proposal: New field type "CompositeField"

2010-05-27 Thread Michael P. Jung
Please check out the repacked and slightly refactored implementation of CompositeField: http://bitbucket.org/mp/django-composite-field I'm currently lacking ideas how to get that into admin without having to specify all subfields in the fieldsets. --mp -- You received this message beca

Re: RFC: Composite fields API

2011-05-19 Thread Michael P. Jung
About one year ago I wrote a CompositeField implementation, which I proposed as a clean way of grouping fields together, while making it easy to reuse that composition of field: https://bitbucket.org/mp/django-composite-field It's a slightly different approach and is centered around defining a fi