Message8172
On Sun, Oct 27, 2024 at 07:17:04PM +0000, Ralf Schlatterbeck wrote:
> Yes, the filter function *always* duplicates the check function.
> I don't know if this makes the check function redundant and if we could
> automagically derive a check function from a filter function. I guess it
> could be done by passing the current itemid through the filter,
> something along the lines of
>
> def check (db, userid, itemid, klass, filter_function):
> args = filter_function (db, userid, klass)
> if klass.filter ([itemid], **args):
> return True
This would need to be a loop:
def check (db, userid, itemid, klass, filter_function):
args = filter_function (db, userid, klass)
for a in args:
if klass.filter ([itemid], **a):
return True
>
> Note that the check function currently has no knowledge of the klass and
> the filter function. But it would certainly be possible to write a
> factory that can return a check function from a given filter function,
> and klass according to the recipe above. Like so:
>
> def check_factory (klass, filter_function):
> def check (db, userid, itemid):
> args = filter_function (db, userid, klass)
> if klass.filter ([itemid], **args):
> return True
> return check
Same here, need to loop over filter args:
def check_factory (klass, filter_function):
def check (db, userid, itemid):
args = filter_function (db, userid, klass)
for a in args:
if klass.filter ([itemid], **a):
return True
return check
KR, Ralf
--
Dr. Ralf Schlatterbeck Tel: +43/2243/26465-16
Open Source Consulting www: www.runtux.com
Reichergasse 131, A-3411 Weidling email: office@runtux.com |
|
Date |
User |
Action |
Args |
2024-10-28 14:30:09 | schlatterbeck | set | recipients:
+ schlatterbeck, rouilj |
2024-10-28 14:30:08 | schlatterbeck | link | issue2551330 messages |
2024-10-28 14:30:08 | schlatterbeck | create | |
|