Open xmonader opened 5 years ago
Great, i'm still looking into current use cases, but we should consider lazy loading too anyway.
@xmonader the issue description has some really good ideas. My main concern is that we do not have a clear idea of what is j
. IMO, the other ticket https://github.com/rkhamis/reparo/issues/2 should addressed first.
Once we have a definition of what is j
and what are the main components that it should have out of the box, then we can move forward to how to implement that using all/some of the ideas presented here.
why is this on gitlab ?
why is this on gitlab ?
because it's more example on how to use python namespaces anyhow I added it to https://github.com/rkhamis/reparo/tree/master/docs/ideas/namespacesgodobject/jumpscale-skeleton
Problem 1: Code Structure
We can use namespaces the way
zope
does with zope.interface for example. Now we can easily havejumpscale.sal
,jumpscale.clients
easily separated into there own pip packages like any normal python project. (bye bye installtools!)declaring namespaces
One of two ways
1- remove
__init__.py
2- add namespace declaration in__init__.py
__import__('pkg_resources').declare_namespace(__name__)
Example structure
Problem 2: implicit imports (autoloading subpackages)
jumpscale by design wants the least amount of imports thats why all are registered under j
e.g for
sal/__init__.py
CHECK: lazyloader/import hooks in stdpython https://docs.python.org/3/library/importlib.html#importlib.util.LazyLoader
Problem 3: Singletons
Solved by design using python modules
Problem 4: jslocation
If we open
god.py
we have handcrafted imports for sal, tools, clients so their subpackages can be autoloaded, but how should it work with packages like
digitalme
How to register digitalme in the god object
Do we generate
import jumpscale.digitalme
? is there a standard python way to do it? a reliable plugin system?where would its module be registered?
for instance there might be
digitalme.tools
should it be underj.tools
directly orj.digitalme.tools
? I prefer the latter for clarity and conflict resolution tooExample usage with jumpscale
Example usage with
j