Turn MediaComment's author() into get_author property
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Sun, 18 Dec 2011 21:52:49 +0000 (22:52 +0100)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Fri, 23 Dec 2011 21:25:06 +0000 (22:25 +0100)
1) MediaComment's author method conflicts with the author
   field. So rename it to get_author.
2) Turn it from a normal function into a python property.
   That means you call it by ".get_author" not by
   ".get_author()". This is exactly what sqlalchemy gives
   us free of charge.

mediagoblin/db/mongo/models.py
mediagoblin/templates/mediagoblin/user_pages/media.html

index e2ac1b5a1d96b380b1e0bb84a60e2f808f7c89cb..0e31fc1c3b6ce815c2205913e49c959be8147809 100644 (file)
@@ -346,7 +346,8 @@ class MediaComment(Document):
     def media_entry(self):
         return self.db.MediaEntry.find_one({'_id': self['media_entry']})
 
-    def author(self):
+    @property
+    def get_author(self):
         return self.db.User.find_one({'_id': self['author']})
 
 
index b9e31667d1ff73540647ce8b63d977709656532f..c171dd5abc7c2206abd24b476f967cfcee464bc7 100644 (file)
       {% endif %}
       {% if comments %}
         {% for comment in comments %}
-          {% set comment_author = comment.author() %}
+          {% set comment_author = comment.get_author %}
                  {% if pagination.active_id == comment._id %}
               <div class="comment_wrapper comment_active" id="comment-{{ comment._id }}">
                            <a name="comment" id="comment"></a>