ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> activepython
activepython
RE: Struggling with CherryPy and Genshi
by Joe Tseng other posts by this author
Apr 10 2008 7:18AM messages near this date
view in the new Beta List Site
Struggling with CherryPy and Genshi | ANN: ActivePython 2.5.2.2 and 2.4.5.14 are now available
Well I was able to make the error msg go away using the following:
 
stream = tmpl.generate(runlist = runlist)Now I'm trying to loop through the list in my templ
ate but I'm getting a zero item count.  I've verified runlist in the template is of type lis
t.  What else could I be doing wrong?


From: joe_tseng@hotmail.comTo: activepython@listserv.activestate.comSubject: Struggling with
 CherryPy and GenshiDate: Thu, 10 Apr 2008 09:17:35 -0400


I'm still a very pythonically green newbie (since last Tuesday) so this issue may be obvious
 to someone else.  I'm trying to get a CherryPy/Genshi-based web app to display the contents
 of a list object being passed to a template but it's not playing nice.  I was able to verif
y in the shell the list was properly created and the methods and properties behaved as desig
ned.  Now I'm trying to pass the object to the template: ====================[model.py]class
 Run(object)  ...class Runlist(list)  ... [controller.py]loader = TemplateLoader(    os.path
.join(os.path.dirname(__file__), "templates"),    auto_reload=True)  ...runlist = Runlist() 
 ...class Root(object)  def __init__(self, runlist):    self.runlist = runlist   @cherrypy.e
xpose  def index(self)    tmpl = loader.load("index.html")    stream = tmpl.generate(runlist
)    return stream.render("html", doctype="html")==================== The code above returns
 an "AssertionError" message. If I try to serialize the object:====================  @cherry
py.expose    def index(self):      tmpl = loader.load("index.html")      data = pickle.load(
runlist)      stream = tmpl.generate(data)      return stream.render("html", doctype="html")
==================== I get the following:AttributeError: 'Runlist' object has no attribute '
readline'
_________________________________________________________________
Pack up or back up�use SkyDrive to transfer files or keep extra copies. Learn how.
hthttp://www.windowslive.com/skydrive/overview.html?ocid=TXT_TAGLM_WL_Refresh_skydrive_packu
p_042008
Thread:
Joe Tseng
Joe Tseng

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved