Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema cannot be added to registry object #354

Closed
6 tasks done
daviskirk opened this issue Jan 11, 2018 · 7 comments
Closed
6 tasks done

Schema cannot be added to registry object #354

daviskirk opened this issue Jan 11, 2018 · 7 comments
Milestone

Comments

@daviskirk
Copy link

Used Cerberus 1.1:


Use-case abstract

I am trying to add schemas to a custom registry so that I don't clutter the cerberus.schema_registry namespace.
Adding any schema to a newly created Registry object results in an attribute error.


Support request / Bug report

import cerberus 
r = cerberus.Registry()
r.add('non-system user', {'uid': {'min': 1000, 'max': 0xffff}})

results in

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-20-ad8c4bb8a5d2> in <module>()
----> 1 r.add('non-system user', {'uid': {'min': 1000, 'max': 0xffff}})

~/anaconda/envs/athion-forecaster/lib/python3.6/site-packages/cerberus/schema.py in add(self, name, definition)
    375         :param definition: The definition.
    376         :type definition: any :term:`mapping` """
--> 377         self._storage[name] = self._expand_definition(definition)
    378 
    379     def all(self):

AttributeError: 'Registry' object has no attribute '_expand_definition'
@funkyfuture
Copy link
Member

funkyfuture commented Jan 11, 2018 via email

@daviskirk
Copy link
Author

No, I'll check the master branch and report back

@funkyfuture
Copy link
Member

@daviskirk could you check this in the meantime?

@pib
Copy link

pib commented Apr 25, 2018

Registry is the abstract parent class of SchemaRegistry and RulesSetRegistry which are not exported from the top-level cerberus module.

I solved this same problem for myself by from cerberus.schema import SchemaRegistry and then using that.

@funkyfuture
Copy link
Member

i'd say we remove Registry from the top level namespace and just keep the default instances there as i guess these are more commonly used. shall we?

@nicolaiarocci
Copy link
Member

Yes.

funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Apr 26, 2018
funkyfuture added a commit to funkyfuture/cerberus that referenced this issue May 27, 2018
funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Jun 1, 2018
@funkyfuture
Copy link
Member

addressed in #383.

@funkyfuture funkyfuture added this to the 1.2.1 milestone Jun 2, 2018
funkyfuture added a commit that referenced this issue Jun 2, 2018
funkyfuture added a commit that referenced this issue Jan 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants