[albatross-users] al-a help

Didrik Pinte dpinte at itae.be
Wed Nov 16 12:28:31 EST 2005


Hi,

I'm using Albatross with pleasure but have a little problem.

I'm a having an HomePage sending request to a StationPage. On the
station page, I have implented pagination, etc. with success. Now, I'm
trying to add sort capabilities on the data shown. I've followed the
example code on the wiki
( http://www.object-craft.com.au/projects/albatross/wiki/Data_Presentation).

So my table header looks like that (see full code below):

<table width="100%" border='1'>
<tr>
<al-for iter="colname" expr="dataSource.colnames">
  <th><al-a
expr='str("sort="+dataSource.getFieldName(colname.value()))'><b><al-value expr="colname.value()"><b></al-a></td>
</al-for>
<th><b>Edit</b></td>
</tr>


The problem is that when I click on the column name, the link sends me
back to my IndexPage and not anymore to the StationPage I was
looking ...

I suppose that I must add some variables to the request. I've tried to
add __page__=station without success. I'm sure using a form this will
work directly ... but it must be possible with a link, no ?

Does anybody have an idea of the way to correct that ?

Many thanks in advance,

Didrik Pinte

--
Here is the python code :

class HomePage:
  name = 'index'

  def page_process(self,ctx):
    ctx.log('Processing index')
    if ctx.req_equals('goto'):
      ctx.log('Changing page to %s' % ctx.locals.goto)
      ctx.set_page(ctx.locals.goto)

  def page_display(self,ctx):
    ctx.load_template('header.html').to_html(ctx)
    ctx.load_template('footer.html').to_html(ctx)
    ctx.log('Displaying stations page')
    ctx.run_template('index.html')

class StationPage:

    name = 'station'

    sC = webconfig.DbObjectConfig(dbscheme.stations)

    def page_enter(self, ctx):
      '''
      Called when the user enters the page
      '''
      ctx.log('Entering station page')
      ctx.default_session_var('_sort', None)

    def page_process(self,ctx):
      '''
      Called when the user processes the form
      '''
      ctx.log('Processing stations page')
      if ctx.req_equals('editstation'):
        ctx.log('Editing %s ... ')
        ctx.set_page('editstation')
      elif ctx.req_equals('sort'):
        # Store the sort attribute in the session var
        ctx.locals._sort = ctx.locals.sort
      elif ctx.req_equals('clear_filter'):
        # Set the filter string to None
        ctx.locals.filter_string = None

    def page_display(self,ctx):
      '''
      Called when the user displays the page
      '''
      ctx.load_template('header.html').to_html(ctx)
      ctx.load_template('footer.html').to_html(ctx)
      ctx.log('Displaying stations page')

      self.sC.getAll(sort=ctx.locals._sort,filter=getattr(ctx.locals,
'filter_string', None))

      ctx.locals.dataSource = self.sC
      ctx.locals.title = 'Liste des stations du réseau'
      ctx.locals.type = 'stations'
      ctx.locals.qualifier = 'configurées'
      ctx.run_template('data.html')

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://www.object-craft.com.au/pipermail/albatross-users/attachments/20051116/2b5b4575/attachment.pgp>


More information about the Albatross-users mailing list