From f021df446cfd1749912d6a39b36d7d9617616483 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 11 Jan 2018 15:15:12 -0600 Subject: [PATCH] Let custom schema node start out with empty children sometimes that's just necessary --- tailbone/forms2/core.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tailbone/forms2/core.py b/tailbone/forms2/core.py index f3a3cae7..d3301bdf 100644 --- a/tailbone/forms2/core.py +++ b/tailbone/forms2/core.py @@ -145,10 +145,20 @@ class CustomSchemaNode(SQLAlchemySchemaNode): msg = 'excludes and includes are mutually exclusive.' raise ValueError(msg) - properties = sorted(self.inspector.attrs, key=_creation_order) # sorted to maintain the order in which the attributes # are defined - for name in includes or [item.key for item in properties]: + properties = sorted(self.inspector.attrs, key=_creation_order) + if excludes: + if includes: + raise ValueError("Must pass includes *or* excludes, but not both") + supported = [prop.key for prop in properties + if prop.key not in excludes] + elif includes: + supported = includes + elif includes is not None: + supported = [] + + for name in supported: prop = self.inspector.attrs.get(name, name) if name in excludes or (includes and name not in includes):