[albatross-users] Macro and links?
Cameron Blackwood
korg at darkqueen.org
Fri Aug 15 01:15:45 EST 2003
Andrew McNamara writes:
|
| >
| > <al-input type="text" name="remove" expr="<al-usearg name="arg1">">
| >
| >which will do what I think it is you are trying to achieve!
|
| I don't think you can nest albatross tags like this - the parser isn't
| sophisticated enough.
I tinkered round and this worked:
<al-input type="text" name="remove" expr="<al-usearg name="arg1">">
but this didnt:
<al-input type="text" name="remove" expr="<al-usearg>">
So I took that as a sign that I was doing the wrong thing and I
abandoned the macro way of doing it. :)
|
| Macro's aren't function calls, more's the pity. Sooner or later we're
| going to have to do something a little fancier - I want to make the
| "disabled" or "size" attributes on an <al-input> determined under
| application control, and you can't currently do that.
Yeah, I had a brainfart and somehow linked macros with functions. :-0
My problem today was that I had a list of items of the form:
[ unique_id_number, non_unique_string ]
and I wanted to have a nice neat little delete button (but a delete
button that was tied to the id_number _AND_ the string). In the end I
ended up using....
<al-if expr="tuples">
<ul>
<al-for iter="i" expr="tuples">
<li>ID:<b><al-value expr="i.value()[0]"></b>
string data:<tt><al-value expr="i.value()[1]"></tt>
<al-input type="submit" nameexpr="'removetuple_%s' % (i.value()[0],)" value="remove">
<al-input type="hidden" nameexpr="'data_removetuple_%s' % (i.value()[0],)" expr="base64.encodestring(cPickle.dumps(i.value()))">
</br>
</al-for>
</ul>
</al-if>
In this way I have a removetuple_ID and then a hidden value that I can
extract the string from.
My app then searches through dir(ctx.locals) for anything of the form
'removetuple_XXX' and search for the data_removetuple_XXX which is the
base64 encoded pickle of the string.
It's ugly, but it works fine and it means that I can delete with ID
and string without rereading my database again. (Dont ask :)
What I learnt today:
--------------------
* dont use macros for anything that is at all programatic or complex.
* you need to base64 encode the pickle string or you'll be hitting
your head a lot :) because it wont unpickle, but it looks like a
pickle string until you look real close ;)
* once you get over some of the confusing bits, you remember that
albatross rocks :)
| Andrew McNamara, Senior Developer, Object Craft
cam
--
/ `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 ----------
I feel partially hydrogenated!
More information about the Albatross-users
mailing list