Changeset 41
- Timestamp:
- 01/29/07 00:22:31 (5 years ago)
- Location:
- trunk/cogplanet
- Files:
-
- 4 modified
-
admin/controller.py (modified) (1 diff)
-
model.py (modified) (2 diffs)
-
tests/test_controllers.py (modified) (1 diff)
-
tests/test_model.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/cogplanet/admin/controller.py
r29 r41 67 67 def entry(self, id): 68 68 entry = Entry.selectone(Entry.c.id==id) 69 print entry.content70 69 planet = Planet.selectone() 71 70 return({'entry':entry, -
trunk/cogplanet/model.py
r29 r41 9 9 from BeautifulSoup import BeautifulSoup 10 10 from genshi.input import ParseError 11 from genshi.template import MarkupTemplate 11 from genshi.template import MarkupTemplate, Template 12 12 13 13 import logging 14 14 log = logging.getLogger("cogplanet.model") 15 15 16 class NoopEvalFilter(object): 17 """A no-op eval filter for Genshi -- expressions pass through without evaluation""" 18 19 def __call__(self, stream, context=None): 20 for kind, data, pos in stream: 21 if kind is Template.EXPR: 22 yield data.source 23 else: 24 yield kind, data, pos 25 16 26 class Planet(ActiveMapper): 17 27 class mapping: … … 64 74 entry.original = e['content'][0]['value'] 65 75 soup = BeautifulSoup("<div>%s</div>" % entry.original) 66 original= soup.prettify()76 htmlsoup = soup.prettify() 67 77 68 78 try: 69 mt = MarkupTemplate(original) 79 mt = MarkupTemplate(htmlsoup) 80 for f in mt.filters: 81 if f.im_func.func_name == '_eval': 82 mt.filters.remove(f) 83 mt.filters.append(NoopEvalFilter()) 70 84 stream = mt.generate() 71 85 rendered = stream.render('xhtml') 72 entry.content = original86 entry.content = htmlsoup 73 87 entry.parsed = True 74 88 except ParseError, pe: -
trunk/cogplanet/tests/test_controllers.py
r1 r41 1 1 from turbogears import testutil 2 from cogplanet.controllers import Root2 # from cogplanet.controllers import Root 3 3 import cherrypy 4 4 5 cherrypy.root = Root()5 # cherrypy.root = Root() 6 6 7 def test_method():8 "the index method should return a string called now"9 import types10 result = testutil.call(cherrypy.root.index)11 assert type(result["now"]) == types.StringType7 # def test_method(): 8 # "the index method should return a string called now" 9 # import types 10 # result = testutil.call(cherrypy.root.index) 11 # assert type(result["now"]) == types.StringType 12 12 13 def test_indextitle():14 "The mainpage should have the right title"15 testutil.createRequest("/")16 assert "<TITLE>Welcome to TurboGears</TITLE>" in cherrypy.response.body[0]13 # def test_indextitle(): 14 # "The mainpage should have the right title" 15 # testutil.createRequest("/") 16 # assert "<TITLE>Welcome to TurboGears</TITLE>" in cherrypy.response.body[0] -
trunk/cogplanet/tests/test_model.py
r39 r41 41 41 model = Feed 42 42 43 #def test_refresh_invalid_entries(self):44 #"Invalid feed entries should not halt processing"43 def test_refresh_invalid_entries(self): 44 "Invalid feed entries should not halt processing" 45 45 46 #feed = Feed()47 #feed.xmlurl = "./cogplanet/tests/invalid_entries.rss"48 #feed.refresh_entries()49 # assert len(feed.entries) == 546 feed = Feed() 47 feed.xmlurl = "./cogplanet/tests/invalid_entries.rss" 48 feed.refresh_entries() 49 assert len(feed.entries) == 10 50 50 51 51 def test_utf8_characters_in_feed(self): … … 53 53 trans = session.create_transaction() 54 54 feed = Feed() 55 #feed.xmlurl = "./cogplanet/tests/utf8_feed.xml"56 feed.xmlurl = "http://feeds.feedburner.com/caskey"55 feed.xmlurl = "./cogplanet/tests/utf8_feed.xml" 56 # feed.xmlurl = "http://feeds.feedburner.com/caskey" 57 57 feed.refresh_entries() 58 58 trans.commit() … … 66 66 rendered = MarkupTemplate(entry.content).generate().render('xhtml') 67 67 print rendered 68 69 def test_genshi_in_feed(self): 70 "Feeds with Genshi/Kid code in the entries should import and display correctly" 71 feed = Feed() 72 feed.xmlurl = "./cogplanet/tests/genshi_feed.xml" 73 feed.refresh_entries()
