I would like to use the mix-in class to add properties to the model.
from google.appengine.ext import db
class Taggable(object):
tag_list = db.StringListProperty()
def attach_tag(self, tag):
self.tag_list.append(tag)
self.put()
def remove_tag(self, tag):
self.tag_list.pop(self.tag_list.index(tag))
self.put()
class Post(db.Model, Taggable):
title = db.TextProperty()
This is just an example, no need to chew on my ear about bad practices or anything else.
Currently, I have something similar to this, except that I have to put tag_list = db.StringListProperty()outside the mix-in (errors otherwise), this is dirty code, and I would like to avoid that.
Just how can I assign properties (like tag_list) to a model from a mix?
source
share