On Friday, 10. January 2003 15:00, Kjetil Kjernsmo wrote:

> So, I'll end up with something like:
>
> <auth:password-matches>
>       <auth:encrypted><mydb:getpasswd/></auth:encrypted>
>       <auth:clear><param:passwd/></auth:clear>
>       <auth:false>Password is invalid</auth:false>
>       <auth:true><strong><xsp:content>Password is
> valid</xsp:content></strong></auth:true>
>       </auth:password-matches>
>
> Conceptually, it might be argued it would be nicer to seperate the input
> stuff (encrypted and clear) from the output stuff (true, false), but I
> don't feel too strongly about that.

Yeah, that's why I don't like it. OTOH, this is indeed the shortest way if you 
want true and false. Here's how to do this:

sub password_matches__true___open {
  return 'if (crypt($attr_clear,$attr_encrypted) eq $attr_encrypted) {'
}
sub password_matches__true {
  return '}'
}
sub password_matches : expr child(encrypted,clear) {
 ...
}

I hope you get the idea. $attr_foo is in scope for the child elements as well 
unless there's some other element in between which overrides it. We depend on 
auth:clear and auth:encrypted to occur before auth:true, obviously.
Btw, in "password_matches__true___open" that's one underscore for the "-" in 
"password-matches", two underscores for matching auth:true only below 
auth:password-matches, and then three to specify the open-event.

> How about
> <auth:single-access-ok type="user" name="guest"/>
>       <auth:true><p>sorry, only for registered users</p></auth:true>
> </auth:single-access-ok>

hmm... there is auth:has-permission. Actually, I begin to like your idea. I 
only wished there was something I could do to generalize this, as it is 
obviously fot for many places. Perhaps some additional SimpleTaglib 
feature... well anyways, look at the example above, it applies here 
similarly.

> OK, I'll just post my rather verbose password_matches sub, feel free to
> tear your hear off, but do not hold me responsible for baldness...: :-)
> Anyway, this does this, except of course that the true/false child
> elements can't have child elements of their own.

Not too bad, really. I once planned SimpleTaglib to support this directly, but 
I'm not sure if it's worth the trouble.

I hope you get your ideas done from the example above.

-- 
CU
  Joerg

PGP Public Key at http://ich.bin.kein.hoschi.de/~trouble/public_key.asc
PGP Key fingerprint = D34F 57C4 99D8 8F16 E16E  7779 CDDC 41A4 4C48 6F94


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to