Hi,
from pylons.views import action from ebro.db import DBSession as db from ebro.sf import SFSession as sf from pylons.controllers.util import Response class MyHandler(object): def __init__(self, request): self.request = request def login(self): login = db.load_form('login.kk') # Pyro response = Response(login) response.content_type = 'application/vnd.mozilla.xul+xml' The remote template is works well. Thanks kk On Sep 30, 8:02 pm, Ben Bangert <b...@groovie.org> wrote: > On Sep 30, 2010, at 9:43 AM, Mike Orr wrote: > > > CC'ing pylons-devel because these will be FAQs. > >> @action > >> def login(self): > >> login=(db.load_form('login.kk')) > >> self.request.response_content_type = > >> 'application/vnd.mozilla.xul+xml' > >> return login > > >> @action > >> TypeError: __init__() takes exactly 1 argument (2 given) > > > The constructor is called with a request argument: > > > def __init__(self, request): > > self.request = request > > And @action is a decorator that requires arguments. Using @action is only > needed if you need to tweak the default's, ie, to limit the calling to a > request_method, or to assign a renderer. If you're doing something like: > > config.add_handler('home_page', '/', handler=Home, action='index') > > Then you don't need to use @action if its going to return its own Response > object. > > So the easy way to think of it, the methods in your handler are all actions > still (just like in a Pylons 1 controller!), *but*, if you need to modify how > the action is called, how the return value of it is handled (ie, using > renderer), or how the action is registered (ie, its name), then you use the > @action decorator to modify those parameters. > > >> def login(self): > >> login=(db.load_form('login.kk')) > >> self.request.response_content_type = > >> 'application/vnd.mozilla.xul+xml' > >> return login > > from pylons.controllers.util import Response > > Then return a response object: > def login(self): > login = db.load_form('login.hh') > response = Response(login) > response.content_type = 'application/vnd.mozilla.xul+xml' > return response > > > There is also a render_template_to_response() function somewhere, > > maybe in pylons.templating. It fills a template and creates a response > > and returns it. > > Yup. > > Cheers, > Ben -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-de...@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en.