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
Contributor

@daviskirk daviskirk commented Jan 11, 2018

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 funkyfuture commented Jan 11, 2018

@daviskirk
Copy link
Contributor Author

@daviskirk daviskirk commented Jan 12, 2018

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

@funkyfuture
Copy link
Member

@funkyfuture funkyfuture commented Mar 28, 2018

@daviskirk could you check this in the meantime?

@pib
Copy link

@pib 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

@funkyfuture funkyfuture commented Apr 25, 2018

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

@nicolaiarocci nicolaiarocci commented Apr 26, 2018

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

@funkyfuture funkyfuture commented Jun 1, 2018

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
Closes #354.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants