On Tuesday 27 January 2004 00:51, Michael A Nachbaur wrote:
> On Monday 26 January 2004 02:29 pm, Kjetil Kjernsmo wrote:
> > Mike's new QueryParam has an enumerate element that I suppose could list
> > all the elements, and it fooled me for a moment (ha, I bet you did that
> > on purpose, Mike! ;-) ), but I think it would be overkill for my purpose.
> > I want just a list of these parameters, not all the others...
>
> Great idea!  I never thought about that before.  After a few moments of
> happy hacking, I've pieced together two changes to A:X:QueryParam:

Yiiiiiha! Great stuff!


> ----
> =head2 C<<param:get name="foo" index="1"/>>
>
> Get a value from the given parameter.  The "name" attribute can be passed
> as a child element for programattic access to parameter values.  If the
> index attribute is supplied, and if multiple parameters are supplied for
> the same "name", then the appropriate parameter is returned.  If multiple
> values for the same parameter are given, but no index is supplied, the
> first value is returned. Now, if you can understand that convoluted set of
> instructions, then you're smarter than me!


Hehe! Yep, this works as documented in my tests with version 1.4! Great!

But it doesn't do all I wanted, at least not straightforwardly. I want them 
all! :-) That is, a list of all parameters for a name. With the two 
additions, I guess you could do that with a loop, but then, I have this 
something against mixing in Perl... In the interest of backwards 
compatability and maintaining relative simplicity, I guess it is best to keep 
that element like it is... :-)

May I suggest an element, something like 
<param:get-all name="foo"/>
that if given the query ?foo=bar&foo=baz
will return
<value>bar</value>
<value>baz</value>

Possibly, the name of the element (instead of 'value') could be an attribute 
too, and perhaps an optional element around these...
 
> =head2 C<<param:count name="foo"/>>
>
> Returns the number of parameters provided on the request.  If a name is
> provided, the number of parameters supplied for the given name is returned.
> If the name is left out, then the total number of parameters is returned.

Hm, this returned 1 on me if I used multiple parameters with the same name. 
With different parameters, and no name attribute, it was correct. I'll try to 
look more about what could be the matter with that later (gotta run now 
(quite literally)).

> This code is *completely* untested, since my development server has been
> taken by my SysAdmin for some emergency server replacement work,

Uhm, that's life... :-) I don't even have a separate development server (so I 
do most work on my workstation, and upload when I want others to have a 
look). 

> so if
> anyone wants to grab the latest copy out of CVS and try it out, go for it. 
> If you do try it out, let me know if it works / fails, so I can release it
> to CPAN or fix the bugs, respectively:

Sure!

Cheers,

Kjetil


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

Reply via email to