Hello. I am trying to get data from MySql.
I created model.py in model directory with content:

__all__ = [ 'Table1' ]

class Table1(DeclarativeBase):
    __tablename__ = 'table1'

    id = Column(Integer, primary_key=True)
    data = Column(Unicode, nullable=True)

I added next strings to the /controllers/root.py:

@expose('tg2app.templates.index')
    def index(self):
        """Handle the front-page."""
        tabledata = DBSession.query(Table1).all()
        datalen = len(tabledata)
        return dict(datalen=datalen, tabledata = tabledata,)

And I created templates master.mak and index.mak. 
In the master.mak I added next strings:

 <div>
      Rows in the tabe: <span>${datalen}</span>
 </div>
 <div py:for="data in tabledata">
    <p py:content="data">Text</p>
 </div>


I have error in the log when I try open page:

[Tue Mar 12 22:34:40 2013] [error] [client 127.3.133.129]   
__M_writer(escape(data))
[Tue Mar 12 22:34:40 2013] [error] [client 127.3.133.129] File 
'/var/lib/openshift/511e43005973cafe7500009a/python-2.6/virtenv/lib/python2.6/site-packages/Mako-0.7.3-py2.6.egg/mako/runtime.py',
 
line 194 in __str__
[Tue Mar 12 22:34:40 2013] [error] [client 127.3.133.129]   raise 
NameError("Undefined")
[Tue Mar 12 22:34:40 2013] [error] [client 127.3.133.129] NameError: 
Undefined

When I coment string "    <p py:content="data">Text</p>", all work fine 
without data.
"datalen" variable contains correct value

What is wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to