same question but in other words, is there a way to apply the same filtering construct (e.g. Q-objects) to both querysets and lists (or even single items) to maintain DRY? (I hope I won't get kicked for this), something similar to Linq and Linq to SQL in C#/.NET...
knbk
sleblanc: please rephrase? I'm not exactly sure what you're getting at
FunkyBob
sleblanc: there is a linq-alike lib for python
but... no...currently QuerySets are for constructing SQL queries
what's your real problem here? what are you hoping to solve with this?
sleblanc
So I have a model that inherits from a "PublishableMixin". The mixin adds "publication_date(dt)", "publication_end_date(dt)" and "is_published(bool)" fields to the model. I know how to build a `filter` construct to filter published items from unpublished items. Now I'd like to apply the same construct to a single object, so that its "is_published" method does not lead to code repeat (even worse than that, it's code repeat in a different "lang
uage", so prone to errors)
FunkyBob
sleblanc: stop writing walls of text
they're hard to read
sleblanc
Do you want me to apologize?
FunkyBob
no, I just want you to not do it again, please
so you want to avoid implementing the same logic in two places
Guddu joined the channel
sleblanc
Yes, exactly (sorry for being rude)
the_rat has quit
FunkyBob
certainly agree with the idea
sleblanc
I would like to avoid hitting the database just for this
I know I could do Object.objects.filter(pk=object.pk).filter(…)
I dabbled in C# a few months ago and they have this somehow great feature (IMO) called Linq. It's a subset of SQL-like syntax built into the language, but with additional greatness:
it works with both regular iterables and "database abstractions"
FunkyBob
yeah, friend of mine raves about linq
sleblanc
In my opinion, QuerySets and the Q interface could become Django's own Linq
FunkyBob
indeed
carljm
sleblanc: I think ptone had a project he was working on a while back for that (applying Q objects to lists of Python objects)