[ckan-dev] "context" reasoning?

David Raznick kindly at gmail.com
Mon Aug 1 23:25:54 UTC 2011


On Mon, Aug 1, 2011 at 7:46 PM, Friedrich Lindenberg <
friedrich.lindenberg at okfn.org> wrote:

> Hi all,
>
> I'm doing some adaptations in a CKAN plugin right now and I don't get
> the coding style of the logic/dictization layer at all: why do none of
> the methods have signatures and use this weird context dict instead?
>

The logic functions are supposed to all have two arguments, context and
data_dict.
Context is meant to have essentially thread local per request information,
such as user, model.  This will hopefully one day remove any global
threadlocal monstrosities like g in flask.

Data_dict is for any arguments/data that you are passing through.  It is
intended to be jsonable so that people can call these functions from
outside, so signatures are not really useful.


> I've never seen that done anywhere before.. (save CLOS perhaps). Also:
> why isn't dictization in the model?
>

This should definitely not be in the model but it is also misplaced where it
is, probably should be in logic.  I really hate model code as it ties you to
using sqlalchemy objects for everything. The model code should not mix with
the how the data is internally represented.   This way we could much more
easily change data store if we wanted to.

A bit confused,
>
I am very happy with this way of doing things but I can see that the fact
thats its not standard could confuse. If anything is overly complicated then
it would be good to have your feedback to how it could be improved and its
far from perfect.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20110802/dfdd20b4/attachment-0001.html>


More information about the ckan-dev mailing list