Hi,

I'm trying to do something I remember using from TG1.  Basically using
the default() function to create a simple rest controller.  URLs are
something like this "http://0.0.0.0:0/<type of object>/<record number>/
<action>"

This is my default function:

@expose()
def default(self, _id, action):
    try:
        frames = DBSession.query(model.Frame)
        record = frames.filter_by(id=_id).one()
    except NoResultFound:
        flash("Could not find record for frame id: %s" % _id, 'error')
        redirect(url("/frame"))

    if action == "load":
         return self.load(record)
    elif action == "view":
         return self.view(record)

and then ...

@expose()
def load(self, record):
     ...
    return "some html"

@expose("lts.templates.view")
def view(self, record):
    ...
    return dict(record=record, etc=...)

As you can see, in the "view" method, I need it to render the page
using the template, but in the load method I don't need to use a
template.  Well, the view method does not render the page using the
template, it just prints out the dict's keys on the screen.

The best way I see of doing this is to forget about the @expose
decorator on the view function and to manually apply the arguments to
the template and return the html.  How can I do that?

What am I doing wrong?!?  What's the right way?  Thanks.

~Sean

Two questions?  What is the proper way to use the default method like
this?

-- 
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?hl=en.

Reply via email to