[Import-SIG] Loading Resources From a Python Module/Package

Barry Warsaw barry at python.org
Mon Feb 2 22:53:03 CET 2015


On Jan 31, 2015, at 01:18 PM, Donald Stufft wrote:

>I think it actually makes things *harder* from an implementation and
>description standpoint. You’re thinking in terms of implementation for the
>FileLoader, but say for a PostgreSQLLoader now I have to create mock packages
>for warehouse.templates and warehouse.templates.accounts whereas if we treat
>the resource path not as a file path, but as a key for an object store where
>“/“ is slightly special then my PostgreSQL loader only need to have a
>“warehouse” package, and then a table that essentially does something like:
>
>    package   | resource key                    | data
>    --------------------------------------------------
>    warehouse | templates/accounts/profile.html | …
>
>In the FileLoader we’d obviously treat the / as path separators and create
>directory entries, but in reality it’s just a key: value store. I already
>implemented one of these functions in a way that allows the / separator and I
>would have had to have gone out of my way to disallow it rather than allow
>it.

So that would mean the API is actually:

resource_whatever(resource_anchor, resource_key)

and loaders would be free to interpret resource_key however they want,
including *not* supporting some resource_keys, e.g. throw an exception.

Cheers,
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/import-sig/attachments/20150202/d50cff19/attachment.sig>


More information about the Import-SIG mailing list