Get field value within Flask-MongoAlchemy Document <p>I've looked at documentation, and have searched Google extensively, and haven't found a solution to my problem.<br> This is my <code>readRSS</code> function (note that 'get' is a method of Kenneth Reitz's requests module):</p> <pre><code>def readRSS(name, loc): linkList = [] linkTitles = list(ElementTree.fromstring(get(loc).content).iter('title')) linkLocs = list(ElementTree.fromstring(get(loc).content).iter('link')) for title, loc in zip(linkTitles, linkLocs): linkList.append((title.text, loc.text)) return {name: linkList} </code></pre> <p>This is one of my MongoAlchemy classes:</p> <pre><code>class Feed(db.Document): feedname = db.StringField(max_length=80) location = db.StringField(max_length=240) lastupdated = datetime.utcnow() def __dict__(self): return readRSS(self.feedname, self.location) </code></pre> <p>As you can see, I had to call the <code>readRSS</code> function within a function of the class, so I could pass <code>self</code>, because it's dependent on the fields <code>feedname</code> and <code>location</code>.<br> I want to know if there's a different way of doing this, so I can save the <code>readRSS</code> return value to a field in the <code>Feed</code> document. I've tried assigning the <code>readRSS</code> function's return value to a variable within the function <code>__dict__</code> -- that didn't work either. </p> <p>I have the functionality working in my app, but I want to save the results to the Document to lessen the load on the server (the one I am getting my RSS feed from). </p> <p>Is there a way of doing what I intend to do or am I going about this all wrong?</p>