lgiordani/dictregister — pull request #4 by msabramo (2014-11-05 06:59:53+00:00)
Title: Add `sfilter` method; filters on `eval` expression

e.g.:

fixdr.sfilter('x == 1 and y == 2')
fixdr.sfilter('x + 1 == y')

Rather than use Django ORM-style keyword arguments to filter, this is an alternative method that lets you pass in a Python expression and it is actually executed using `eval`.

I needed this for a project where I wanted to give the user the ability to filter in arbitrary ways from the command-line -- e.g.:

$ doula queue list --where "user_id == 'msabramo'"

I built the feature in that project, but then I thought it was kind of a generally useful thing to do so I started looking to see if there was a module on PyPI that did this. I couldn't find any, but I found two that do the ORM-like thing -- this one and [Lookupy](https://pypi.python.org/pypi/Lookupy). Since it's kind of similar, I decided to send a PR to see if it was something useful that you wanted to include.

I don't know about the name -- `sfilter` -- I guess I was thinking of "s" for "string". If you have better ideas, let me know.