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
daviskirk opened this issue Jan 11, 2018 · 7 comments

Comments

Projects
None yet
4 participants
@daviskirk
Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

commented Jan 11, 2018

@daviskirk

This comment has been minimized.

Copy link
Contributor Author

commented Jan 12, 2018

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

@funkyfuture

This comment has been minimized.

Copy link
Member

commented Mar 28, 2018

@daviskirk could you check this in the meantime?

@pib

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.