Hey Gerdus,

> Some code that I use to do the same thing:
>
> cls = Employee
> param = { 'age':30,'lastname':'smith' }
>
> expressions = []
> for k in param:
>    v = param[k]
>    if v == "none":
>        v = None
>    if hasattr(cls,k):
>        expressions += [ getattr(cls,k) == v ]
>
>
> sl = store.find(cls,And(*expressions))

Except for the None special handling and the check to see if the class
has the attribute, you could just do something like:

    store.find(cls, **param)

Since something like this works:

    store.find(cls, age=30, lastname="smith")

-- 
Gustavo Niemeyer
http://niemeyer.net

-- 
storm mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/storm

Reply via email to