[ckan-dev] User.get_groups problem

David Read david.read at hackneyworkshop.com
Wed Jun 27 10:35:05 UTC 2012


Thanks Ross!

Dave

On 27 June 2012 11:27, Ross Jones <ross.jones at okfn.org> wrote:
> Hi,
>
> Oops, thanks for finding that.  I've of a mind to remove the caching altogether, as I'm attempting to be persuasive about using a FK for membership instead of the current solution and I am feeling optimistic. Perhaps my optimism is misplaced though so in the meantime  I've created a ticket at http://trac.ckan.org/ticket/2605 and have set it for the 1.8 which means it should be fixed this week.
>
> Ross.
>
>
> On 27 Jun 2012, at 11:19, David Read wrote:
>
>> Ross,
>>
>> I had some slightly obscure problems with the model.User.get_groups()
>> function in DGU today and I think this is a part of the code you know
>> about best. There were no tests so I added one that shows the problem
>> I had:
>> https://gist.github.com/3003117
>>
>> Basically get_groups() appears to cache its results, but this falls
>> down when subsequent calls are in a different session. We get this
>> when saving a dataset. get_groups() first gets called in the
>> controller when it is trying to work out what permissions the user
>> has. It later gets called, and by this time c.userobj is detached, so
>> get_groups() fails.
>>
>> I'm working around this by refreshing c.userobj (from c.user) before
>> calling get_groups(), but I wonder if the get_groups caching could
>> detect the detached session and bypass the cache in this case?
>>
>> BTW you may also wish to add this to the CKAN codebase.
>>
>> Dave
>




More information about the ckan-dev mailing list