[ckan-dev] imports
Toby Dacre
toby.okfn at gmail.com
Mon Mar 26 12:01:38 UTC 2012
2012/3/26 Adrià Mercader <amercadero at gmail.com>
> This looks really sensible and they are great guidelines.
>
> I don't know if you are aware of this ticket created by Sean a while ago:
> http://trac.ckan.org/ticket/1740
>
hadn't seen this :)
>
> One minor comment though:
> On 26 March 2012 12:06, Toby Dacre <toby.okfn at gmail.com> wrote:
> > It is also nice to import things from the correct places eg why `from
> base
> > import _` when we could use `from pylons.i18n import _`
> Perhaps this is useful if it at some point in the future we decide to
> move away from pylons, paster or whatever external library we are
> "proxying" through lib.base, because that would mean that we only have
> to create a new function there, instead of changing all the imports
> throughout the code.
> Also in cases like json where you need to load different libraries
> depending on the python version it is more convenient to have
> ckan.lib.base do the checking instead of checking for ImportErrors
> every time you want to import it
>
Good point, maybe we should have a lib.core_modules that we could use for
this that holds external libs/functions rather than mixing it in with
lib.base. lib.base is imported all over the place at present and doesn't
feel like it really needs to be if it's only for something like json or _.
Also currently lib.base imports json from lib.helpers (which should be
template helper functions only)
I think the _ case is easy enough json is more messy as we sometimes just
import it directly and I'm not sure why we don't just do `import simplejson
as json`. I'm just keen to get the imports as clean as possible.
>
> But as you said, maybe importing the explicit stuff outweighs these
> points (Explicit is better than implicit etc...)
>
>
> Adrià
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20120326/b82dc180/attachment-0001.html>
More information about the ckan-dev
mailing list