Well, I think it's the same as you'd do anything in Python -- not
everything has to be a servlet, and you don't have to use the logic flow
that's built into Webware. In fact, you aren't expected to use it --
you are expected to make your own logic.
For instance, if you want to sort on a field, you might have links like:
self.write('''
<table>
<th><a href="?sort=name>Name</a></th>
<th><a href="?sort=age>Age</a></th>
''')
dbresults.sort(lambda a, b, field=self.request.field('sort', 'name'):
cmp(a[field], b[field]))
# Then you write the results
You can use the self.response().forwardRequest('newServletName') if you
want to go to another servlet completely. But otherwise, it's simply a
matter of normal Python -- you call functions and methods, test values,
etc. If you want to pass control over to another method in the same
servlet, just call that method (self.newMethod()).
On Wed, 2001-11-14 at 10:55, Aleksandar Kacanski wrote:
> Let's say that servlet renders DB query. My top
> header for the query has column names.
> I want to sort the records by clicking on the
> name link.
> I need to render view (same servlet) but sort
> method will be invoked.
> Plainly, I don't understand the mechanics of the
> request().field method.
> _action_ method does the trick, but I am invoking
> method, without the html header part implemented
> by application -> SomePage classes.
> I looked into examples, but the invocation of the
> field is not clear to me. How to trigger link to
> invoke same servlet with a different method?
>
> --- Ian Bicking <[EMAIL PROTECTED]> wrote:
> > I'm not entirely clear what you want to do.
> > You can do this in an adhoc
> > way, simply by doing something like:
> >
> > class Home(SomePage):
> > def writeContent(self):
> > if self.request().field('show', None)
> > == 'whatever':
> > return self.whatever()
> > elif ...
> >
> >
> > What is it you're trying to acomplish that
> > can't be done like that, or
> > using the _action_ stuff?
> >
> > On Tue, 2001-11-13 at 22:23, Aleksandar
> > Kacanski wrote:
> > > What would be alternative way to invoke
> > different
> > > method in the same servlet instance.
> > > I am currently using _action_ method
> > >
> > > class Home(SomePage):
> > > def actions(self):
> > > return SomePage.actions(self) +
> > > ['whatever']
> > > def whatever(self):
> > > self.writeln('''...''')
> > >
> > > but that is invoking method but not the whole
> > > framework.
> > > i can not recursively invoke class itself,
> > > return Home.actions(self) + ...
> > >
> > > Essentially, I would ideally like to make a
> > > template servlet, with "targets" hitting a
> > same
> > > servlet but different methods.
> > > maybe some pointers...
> > > Thanks
> > > /s
> > >
> > >
> >
> __________________________________________________
> > > Do You Yahoo!?
> > > Find the one for you at Yahoo! Personals
> > > http://personals.yahoo.com
> > >
> > >
> > _______________________________________________
> > > Webware-discuss mailing list
> > > [EMAIL PROTECTED]
> > >
> >
> https://lists.sourceforge.net/lists/listinfo/webware-discuss
> > >
> >
> >
>
> __________________________________________________
> Do You Yahoo!?
> Find the one for you at Yahoo! Personals
> http://personals.yahoo.com
>
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss