[albatross-users] can't figure out why it's flipping me the bird
Eric S. Johansson
esj at harvee.org
Fri Sep 12 02:17:28 EST 2003
Matt Goodall explained:
> The wording in your sentence is a bit ambiguous so just to clarify ...
> the name of all checkbox fields will be 'albatross_token', i.e. in the
> HTML each checkbox will have a name="albatross_token" attribute.
>
> Erm, I just noticed something. Unless I'm missing something obvious
> (which is quite possible!) the albatross_token variable in your example
> is set but never actually used.
you are quite right. I managed to code around the problem without being fully
cognizant of it. I must admit, this has had me sitting back here in my chair
blinking little bit. I guess I don't understand albatross as well as I thought
I did.
I would be interested in hearing the theory behind this behavior with name and
value. It's another cognitive clash.
> I only just realised this myself but, according to the documentation,
> the valueexpr attribute will be ignored for type="text" inputs. The
> value is taken from ctx.locals.
ahh the dreaded context.locals...
following your example, I created the following:
for line in display_list:
field_value = line.variable
if line.variable == "None":
field_value = ""
setattr(context.locals,line.field_name, field_value)
display_list is a list of objects containing attributes which contain the actual
values I want to use in the albatross code. I need to strip out the string
"None" and replace it with a blank line when it is displayed in the form.
and albatross I just use the normal:
<al-input type="text" nameexpr="line.value().field_name" size="50"
maxlength="100">
and since field name resolves to a context.locals attribute, everything
works and the value is set to the value of the action viewed just as it should.
now one of the hazards of this technique is if one of the fields match another
variable that is a part of context.locals. It also makes it difficult to
actually index through the list although I'm sure I'll find a pythonism to make
it possible. Fortunately this wasn't as ugly as I feared, merely obtuse.
> Of course, there may be a much better way of doing this.
blood taste salty...
---eric
More information about the Albatross-users
mailing list