Browse Source

Simplify code - remove un-needed method

Oz N Tiram 8 years ago
parent
commit
aeedd3777d
2 changed files with 8 additions and 11 deletions
  1. 7 10
      blogit/blogit.py
  2. 1 1
      tests/test_all.py

+ 7 - 10
blogit/blogit.py

@@ -155,15 +155,7 @@ class Tag(object):
         _slug = re.sub(r'[;:,. ]+', '-', _slug.lstrip(',.;:-'))
         return _slug.lstrip('-')
 
-    @property
-    def posts(self):
-        """return a listpost ids tagged with Tag"""
-        Tags = Query()
-        tag = self.table.get(Tags.name == self.name)
-        return tag['post_ids']
-
-    @posts.setter
-    def posts(self, post_ids):
+    def set_posts(self, post_ids):
         if not isinstance(post_ids, list):
             raise ValueError("post_ids must be of type list")
         Tags = Query()
@@ -174,11 +166,16 @@ class Tag(object):
         tag['post_ids'].extend(list(new))
         self.table.update({'post_ids': tag['post_ids']}, eids=[tag.eid])
 
+    posts = property(fget=None, fset=set_posts)
+
     @property
     def entries(self):
         """return the actual lists of entries tagged with"""
+        Tags = Query()
+        tag = self.table.get(Tags.name == self.name)
+        posts = tag['post_ids']
 
-        for id in self.posts:
+        for id in posts:
             post = self.db.posts.get(eid=id)
             if not post:  # pragma: no coverage
                 raise ValueError("No post found for eid %s" % id)

+ 1 - 1
tests/test_all.py

@@ -224,7 +224,7 @@ summary: This is a summary
     e2 = Entry(os.path.join(CONFIG['content_root'], 'f.md'))
     e2.tags
     assert len(DB.posts.all()) == 22
-    assert e1.tags[0].posts == e2.tags[0].posts
+    #assert e1.tags[0].posts == e2.tags[0].posts
     e1.render()
     [t.render() for t in e1.tags]