Can I get a reality check on another manifestation of this error?

In our app, we've been returning SQLObjects from controller methods.
E.g., to display a single record of type Foo, we have a method like:

    @turbogears.expose(template='templates.detail')
    def getDetail(self, id):
        return dict(obj=Foo.get(id))

and then reference obj.attr1, obj.attr2 etc. in the Kid template.  This
works great.  But: when I go to write a unit test, I get anomalous
results:

    result = call(cherrypy.root.getDetail, id)

    # these assertions succeed:
    self.assertEqual(result['elem'].id, id)
    self.assert_(hasattr(result['elem'], 'someAttr'))
    self.assertEqual(result['elem'].someAttr,
expected_value_for_someAttr)

    # Other attributes, inherited from Foo's superclass,
    # are present in the object's directory:
    self.assert_('inheritedAttr' in dir(result['elem']))

    # but the following assertion fails:
    # self.assert_(hasattr(result['elem'], 'inheritedAttr'))

    # and the attempt to access such attributes, thus:
    self.assertEqual(result['elem'].inheritedAttr,
expected_value_for_inheritedAttr)

    # yields a transaction error.

This is strange, since 'inheritedAttr' can be referenced in the Kid
template.

If the short answer is: "don't pass SQLObjects back from controller
methods," I'll grumble and serialize them.  But since it's working with
Kid, I'm puzzled why it's not working with Nose?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to