[ckan-dev] User.get_groups problem
ross.jones at okfn.org
Wed Jun 27 11:27:18 BST 2012
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.
On 27 Jun 2012, at 11:19, David Read wrote:
> 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:
> 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.
More information about the ckan-dev