jsl icon indicating copy to clipboard operation
jsl copied to clipboard

Document base class should allow all property names with best effort

Open sseg opened this issue 10 years ago • 1 comments

Although the name argument for fields allows any name to be assigned to a property, the Document class should at least try to avoid polluting the namespace of schemas.

Unknowingly overwriting a class attribute can sometimes produce confusing errors. TypeError: 'StringField' object is not callable is thrown from the class definition:

class Schema(Document):
    walk = StringField()

Internal methods of Document and it's parents could be prefixed with an underscore to at least try to preserve more of the namespace for users and reduce the cases where an alias must be invoked.

sseg avatar Mar 18 '16 23:03 sseg

Unfortunately, Document's methods are public and documented and can not be renamed without breaking backwards compatibility. I'll consider renaming them in the next major version.

aromanovich avatar May 11 '16 19:05 aromanovich