Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

lazy load classes from json schemas #2

Open
sloev opened this issue Feb 26, 2016 · 1 comment
Open

lazy load classes from json schemas #2

sloev opened this issue Feb 26, 2016 · 1 comment

Comments

@sloev
Copy link
Owner

sloev commented Feb 26, 2016

a module called classes:
when someone tries to import something from classes. it will try to see in its directory if it can find a matching jsonschema, if yes it will create a Model around it, cache the model and return it.

a module called Magic could hold the following:
for name in walk(this_dir):
schema = load(name)

globals[name] = type(name, (Pycorm.Model,),{schema: schema})

then from ipython (ipython loads on tapb) you could do black magic:
(if a jsonschema exist with name User):
from Magic import User
and the Magic module would generate a module to you, return it, and let sysmodules cache it
that would be cool

@sloev
Copy link
Owner Author

sloev commented Feb 26, 2016

this could even be in the pycorm library so that you could make a package called modules with a load of json_schemas.
in the package's init module you could then:
from pycorm import lazyload
lazyload(globals())

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant