parent
658b85d327
commit
22a7ee5885
@ -23,13 +23,20 @@ class ValidationError(Exception):
|
||||
_document_registry = {}
|
||||
|
||||
def get_document(name):
|
||||
if name not in _document_registry:
|
||||
doc = _document_registry.get(name, None)
|
||||
if not doc:
|
||||
# Possible old style names
|
||||
end = ".%s" % name
|
||||
possible_match = [k for k in _document_registry.keys() if k.endswith(end)]
|
||||
if len(possible_match) == 1:
|
||||
doc = _document_registry.get(possible_match.pop(), None)
|
||||
if not doc:
|
||||
raise NotRegistered("""
|
||||
`%s` has not been registered in the document registry.
|
||||
Importing the document class automatically registers it, has it
|
||||
been imported?
|
||||
""".strip() % name)
|
||||
return _document_registry[name]
|
||||
return doc
|
||||
|
||||
|
||||
class BaseField(object):
|
||||
|
Loading…
x
Reference in New Issue
Block a user