durusmail: quixote-users: Strange issue with string substitution in quixote
Strange issue with string substitution in quixote
2003-10-13
2003-10-13
Strange issue with string substitution in quixote
VanL
2003-10-13
Hello,

I am using dtuple to make the tuples coming back from my
database act like dicts.  They seem to work in every test:

# db is a wrapped db cursor with some convenience functions,
# including wrapping the output in dtuple
result = db.select_by_domain('example.com').fetchone()

result[0] # prints 'example.com'
'%s' % result # prints 'example.com'
'%(domain)s' % result # prints 'example.com'

In a quixote ptl file:

def view [html] (request):
         header("View Domain")
         req = request.get_form_var('did')
         result = db.select_by_domain("%s" % req).fetchone()
         if result:
                """
                
Domain: %(domain)s
""" % result else: "No result" footer() However, this always fails: Traceback (most recent call last): File "/usr/local/lib/python2.2/site-packages/quixote/publish.py", line 534, in publish output = self.process_request(request, env) File "/usr/local/lib/python2.2/site-packages/quixote/publish.py", line 516, in process_request output = self.try_publish(request, env.get('PATH_INFO', '')) File "/usr/local/lib/python2.2/site-packages/quixote/publish.py", line 464, in try_publish output = object(request) File "/usr/local/lib/python2.2/site-packages/benbox/view.ptl", line 25, in view """ % result KeyError: domain Is there something different about the way that ptls (or quixote) do dict-based string substitution? Thanks, VanL
reply