Created
July 9, 2010 03:57
-
-
Save GraylinKim/469013 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for post in self.objs.get('posts',[]): | |
| def makeRef(name,value): | |
| for obj in self.objs.get(name,[]): | |
| if obj.slug == value: | |
| tag.posts.append(post) | |
| post.tags[i] = tag | |
| return True | |
| warning = "%s '%s' referenced but not defined." | |
| self.log.warning(warning % (name[:-1].capitalize(),value)) | |
| return False | |
| post.tags = [tag for tag in post.tags if makeRef('tags',tag)] | |
| post.feeds = [feed for feed in post.feeds if makeRef('feeds',feed)] |
Oops, I'm missing a 'return False'
So this hasn't been tested because I don't have the dependencies and haven't checked out the Firmant testing framework recently.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 26: Warning should warn instead of undefined feed referenced.
Lines 9 and 24: can be followed by continue since match has already been found
Since both if blocks need early escape and are virtually identical, we could factor out the code.