sloev / pycorm

MIT License
1 stars 0 forks source link

lazy load classes from json schemas #2

Open sloev opened 8 years ago

sloev commented 8 years ago

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 commented 8 years ago

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())