[albatross-users] al-input type="image" with variable src

Cameron Blackwood korg at darkqueen.org
Wed Feb 25 10:44:49 EST 2004


Andrew McNamara writes:
  |
  | 
  | This is something that albatross currently doesn't do, and it's been
  | annoying many of us for some time. The solution is to extend Albatross
  | to provide a mechanism to evaluate any attribute, so you could do
  | something like:
  | 
  |         <al-input type="image" al-src="foo(3,4)" />

srcexpr="..." anyone?

or maybe it should be expr="..." 

  * That matches <al-img>
  * expr="" doesnt seem to be used for type="image"  (according to the docs)

??

  | 
  | Unfortunately, that doesn't help you. It doesn't help me, either -
  | I ran into exactly the same problem yesterday.

I admit that I tend to do warped things with cgi's, but I was going to
be surprised if noone has hit this before ;). Im glad its not just me :)

  | 
  | Note that you can't nest albatross tags (so Matt's suggestion won't work,
  | unfortunately).

*nod* I tried that road in my previous albatrossing :) so I didnt 
bother trying it this time. ;)

I did nest an <input ...> but that just seemed messy. I tried "_." but
then I remembered that was a zope thing, or atleast from somehere weird
inside my rotting brain.


So I ended up with:

      <td><al-a expr="'newpos=(%s,%s)'%(x.value(),y.value())"><al-img expr="desi
gn.html_planview_floorroof(x.value(),y.value())"></al-a></td>

and albatross code to do:

    if ctx.get_value('newpos'):
      p=ctx.get_value('newpos')
      if p[0]=='(' and p[-1]==')':
        sp=string.split(p[1:-1],',')
        if len(sp)==2:
          x=string.atoi(sp[0])
          y=string.atoi(sp[1])
          ctx.locals.design.view_move(x,y)
          ctx.locals.msg='Moved view by %s,%s to %s<br>\n'%(x,y,ctx.locals.desig
n.pos)

Which isnt very safe, input wise, but its just a hack until I get
something else worked out (or im brave enough to try adding srcexpr 
to albatross :)

Actually, that does raise another question, im on

    albatross-1.10.tar.gz

if I was going to try to add srcexpr, then which version of the code
would it be best to do that to?


--
 / `Rev Dr'   cam  at darkqueen.org            Roleplaying, virtual goth \
<   http://darkqueen.org        Poly, *nix, Python, C/C++, genetics, ATM  >
 \  [+61 3] 9809 1523[h]         skeptic, Evil GM(tm). Sysadmin for hire /
                      ---------- Random Quote ----------
This life is a test.  It is only a test.  Had this been an actual life, you
would have received further instructions as to what to do and where to go.



More information about the Albatross-users mailing list