Well, I think I figured it out. Or at least, a workaround.
All ViewField does is to fire up ViewDefinition with the wrapper
-param filled by the class it is bound to.
So, when doing all this at init time, just call ViewDefinition instead, like so:
def __init__(self, *args, **kwargs):
if not self.doc_type:
self.doc_type = self.__class__.__name__
for attr_name in dir(self):
if not attr_name.startswith("_") and attr_name not in ["id", "rev"]:
attr_val = getattr(self, attr_name)
if isinstance(attr_val, CouchView):
setattr(self, attr_name, ViewDefinition(self.doc_type, attr_name, attr_val.template.render(self.__dict__), wrapper=self))
Of course, now you must remember to instantiate your model classes before adding them to the manager (it comes with the flask extension):
user = User()
manager.add_document(user)
This bit me while testing. Gotta stop doing this when I'm this tired.
And for some reason you need to add _data = {}
to your custom base class. I can't figure out why it is not getting set properly, but its an easy fix.