Control: tags -1 +patch
On 2021-12-10 10:34:05, Antonio Terceiro wrote:
> On Thu, Dec 09, 2021 at 03:38:00PM -0500, Antoine Beaupré wrote:
>> Control: forwarded -1 https://gitlab.com/anarcat/feed2exec/-/issues/22
>>
>> I'm not sure what to do with this bug report. I had the same upstream,
>> and it seems like the issue is more with the cachecontrol package than
>> with feed2exec itself:
>>
>> https://github.com/ionrock/cachecontrol/issues/262
>>
>> Could you take a look at that package? See also the feed2exec bug
>> above...
>
> Ah, I missed looking into the closed bugs.
>
> The fact is that cachecontrol changed the interface it expects from the
> cache store objects, by adding a expires argument to the `cache.set()` call.
>
> Any use cases that provides a custom cache store implementation needs to
> either adapt to that new interface, or cachecontrol needs to be made
> smart enough to still support cache stores with the old implementation.
> For example this patch makes feed2exec at least not crash:
>
> ----------------8<----------------8<----------------8<-----------------
> diff --git a/feed2exec/model.py b/feed2exec/model.py
> index 7d9f979..24c863e 100644
> --- a/feed2exec/model.py
> +++ b/feed2exec/model.py
> @@ -344,7 +344,7 @@ class SqliteStorage(object):
> % (self.value_name, self.table_name,
> self.key_name), (key, )).fetchone()
> return val[0] if val else None
>
> - def set(self, key, value):
> + def set(self, key, value, expires=None):
> with self.connection() as con:
> con.execute("INSERT OR REPLACE INTO `%s` (`%s`, `%s`) VALUES (?,
> ?)"
> % (self.table_name, self.key_name, self.value_name),
> ----------------8<----------------8<----------------8<-----------------
>
> Of course, ideally you would also want to handle the expires by saving
> it to the database, and checking for it in the implementation of get(),
> (and maybe __iter__() as well).
You're entirely right: adding expiries to the database would be a great
start. we don't expires entries at all right now, so it's great that
cachecontrol added support for this...
Now I need to implement schema migrations, sigh. :)
Thanks for the patch, I reopened the upstream bug and will followup
there.
a.
--
Concepts have meaning only if we can point to objects to which they
refer and to the rules by which they are assigned to these objects.
- Albert Einstein