Som-Energia / intercoop

Communication libraries for social economy entities to cross services for their members.
GNU Affero General Public License v3.0
2 stars 2 forks source link

Adding a new option for the user info #5

Closed sommobilitat closed 6 years ago

sommobilitat commented 6 years ago

While implementing intercoop to sommobilitat, we faced that almost every request has a different user, so it would better to instead of saving the user info to a yaml file, we could pass a simple namespace object, so we avoid saving the file and loading it later.

So, a simple example of how it could be used would be:

user = ns.loads("""
    originpeer: somillusio
    lang: es
    nif: 12345678Z
    name: Bunny, Bugs
""")
continuationUrl = self.catalog.activate(peer, service, user)
vokimon commented 6 years ago

I think you missinterpreted the usage of those classes. user must be a key in your system. UserInfo is a custom class you MUST implement to get those fields from your own ERP. The YAML based implementation of UserInfo used in the example should be used JUST for demo purposes. Please, don't dump all your users in yaml! Don't read yaml files on every query like that class does.

Indeed all the components in red in the following diagram should be custom classes that have to be reimplemented:

Intercoop architecture

Common classes like Catalog and IntercoopApi have constructors that receive instances of the reimplementable classes they rely on. Example and tests inject dummy classes, but, in production you should inject instances of your own production ready classes.

vokimon commented 6 years ago

@sommobilitat I added our workinprogress implementation of user info in python/intercoop/userinfo.py so you can take it as reference.