apache_table command for Rivet access to notes table

View: New views
8 Messages — Rating Filter:   Alert me  

apache_table command for Rivet access to notes table

by Karl Lehenbauer-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Guys,

I last brought this up a little over a year ago and other priorities  
intervened but I have now implemented an "apache_table" command and I  
want to get y'alls' feedback on it.

apache_table as currently implemented provides read/write access to  
four tables in Apache:  notes, headers_in, headers_out,  
err_headers_out and subprocess_env.

Here's the syntax of the command:

apache_table get tableName key

        returns the value of the specified key or an empty string

apache_table set tableName keyValueList
apache_table set tableName key value

        In the first case, takes zero or more key-value pairs in keyValueList  
and sets each key in the table with its corresponding value.

        In the second case, takes one key and one value and sets that key and  
value into the specified table.

apache_table unset tableName key

        Unsets the specified key-value pair from the table.  It is not an  
error to unset a key that doesn't exist.

apache_table names tableName

        Returns a list of all the keys in the specified table.

apache_table array_get tableName

        Returns the key-value pairs of the specified table as a list,  
suitable for array set.  For instance:

        array set notes [apache_table array_get notes]

apache_table clear tableName

        Invokes apr_table_clear to clear the contents of the specfied table.

I think the above syntax is pretty reasonable.  The part that's  
questionable is providing access to headers_in, headers_out,  
err_headers_out and subprocess_env.  I know we already have a  
mechanism for access to subprocess_env and would be more than willing  
to remove any or all of these, or potentially add access to other  
tables, although I'm not aware of other tables that would be candidates.



---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@...
For additional commands, e-mail: rivet-dev-help@...


Re: apache_table command for Rivet access to notes table

by Damon Courtney :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think the syntax is fine.  Easy and simple.  I don't really have a  
problem with exposing Apache internals.  I would actually like to see  
more of it.  Apache has some pretty neat stuff in there.

D


On Apr 27, 2009, at 2:42 PM, Karl Lehenbauer wrote:

> Hi Guys,
>
> I last brought this up a little over a year ago and other priorities  
> intervened but I have now implemented an "apache_table" command and  
> I want to get y'alls' feedback on it.
>
> apache_table as currently implemented provides read/write access to  
> four tables in Apache:  notes, headers_in, headers_out,  
> err_headers_out and subprocess_env.
>
> Here's the syntax of the command:
>
> apache_table get tableName key
>
> returns the value of the specified key or an empty string
>
> apache_table set tableName keyValueList
> apache_table set tableName key value
>
> In the first case, takes zero or more key-value pairs in  
> keyValueList and sets each key in the table with its corresponding  
> value.
>
> In the second case, takes one key and one value and sets that key  
> and value into the specified table.
>
> apache_table unset tableName key
>
> Unsets the specified key-value pair from the table.  It is not an  
> error to unset a key that doesn't exist.
>
> apache_table names tableName
>
> Returns a list of all the keys in the specified table.
>
> apache_table array_get tableName
>
> Returns the key-value pairs of the specified table as a list,  
> suitable for array set.  For instance:
>
> array set notes [apache_table array_get notes]
>
> apache_table clear tableName
>
> Invokes apr_table_clear to clear the contents of the specfied table.
>
> I think the above syntax is pretty reasonable.  The part that's  
> questionable is providing access to headers_in, headers_out,  
> err_headers_out and subprocess_env.  I know we already have a  
> mechanism for access to subprocess_env and would be more than  
> willing to remove any or all of these, or potentially add access to  
> other tables, although I'm not aware of other tables that would be  
> candidates.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: rivet-dev-unsubscribe@...
> For additional commands, e-mail: rivet-dev-help@...
>


---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@...
For additional commands, e-mail: rivet-dev-help@...


Re: apache_table command for Rivet access to notes table

by Massimo Manghi-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The syntax you have depicted here seems to be a very natural approach to
the problem: easy to read and easy to use. This command has to signal a few
potential error conditions though: table-key-value not existing, but
also more specifically
improper table names or not existing key in a valid table.

I welcomed the new  'try/catch/finally' construct recently introduced for
Tcl8.6. I wonder if it's possible to adopt a style for raising errors
that might
encourage the programmer to exploit it.  Personally I don't like the
idea of checking
for an empty string in order to understand if a key-value pair exists
(but i'm sure long
time Tcl programmers will shrug at my attitude)

 -- Massimo


Karl Lehenbauer wrote:

> Hi Guys,
>
> I last brought this up a little over a year ago and other priorities
> intervened but I have now implemented an "apache_table" command and I
> want to get y'alls' feedback on it.
>
> apache_table as currently implemented provides read/write access to
> four tables in Apache:  notes, headers_in, headers_out,
> err_headers_out and subprocess_env.
>
> Here's the syntax of the command:
>
> apache_table get tableName key
>
>     returns the value of the specified key or an empty string
>
> apache_table set tableName keyValueList
> apache_table set tableName key value
>
>     In the first case, takes zero or more key-value pairs in
> keyValueList and sets each key in the table with its corresponding value.
>
>     In the second case, takes one key and one value and sets that key
> and value into the specified table.
>
> apache_table unset tableName key
>
>     Unsets the specified key-value pair from the table.  It is not an
> error to unset a key that doesn't exist.
>
> apache_table names tableName
>
>     Returns a list of all the keys in the specified table.
>
> apache_table array_get tableName
>
>     Returns the key-value pairs of the specified table as a list,
> suitable for array set.  For instance:
>
>     array set notes [apache_table array_get notes]
>
> apache_table clear tableName
>
>     Invokes apr_table_clear to clear the contents of the specfied table.
>
> I think the above syntax is pretty reasonable.  The part that's
> questionable is providing access to headers_in, headers_out,
> err_headers_out and subprocess_env.  I know we already have a
> mechanism for access to subprocess_env and would be more than willing
> to remove any or all of these, or potentially add access to other
> tables, although I'm not aware of other tables that would be candidates.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: rivet-dev-unsubscribe@...
> For additional commands, e-mail: rivet-dev-help@...
>


---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@...
For additional commands, e-mail: rivet-dev-help@...


Re: apache_table command for Rivet access to notes table

by David Welton-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

+1

--
David N. Welton

http://www.welton.it/davidw/

http://www.dedasys.com/
Sent from Padova, PD, Italy

---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@...
For additional commands, e-mail: rivet-dev-help@...


Re: apache_table command for Rivet access to notes table

by Karl Lehenbauer-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

So you would prefer for it to work like an array?  Have an  
"apache_table exists tableName key" and make "apache_table get  
tableName key" force an error ?

On Apr 29, 2009, at 4:13 AM, Massimo Manghi wrote:

> The syntax you have depicted here seems to be a very natural  
> approach to
> the problem: easy to read and easy to use. This command has to  
> signal a few
> potential error conditions though: table-key-value not existing, but  
> also more specifically
> improper table names or not existing key in a valid table.
>
> I welcomed the new  'try/catch/finally' construct recently  
> introduced for
> Tcl8.6. I wonder if it's possible to adopt a style for raising  
> errors that might
> encourage the programmer to exploit it.  Personally I don't like the  
> idea of checking
> for an empty string in order to understand if a key-value pair  
> exists (but i'm sure long
> time Tcl programmers will shrug at my attitude)
>
> -- Massimo
>
>
> Karl Lehenbauer wrote:
>> Hi Guys,
>>
>> I last brought this up a little over a year ago and other  
>> priorities intervened but I have now implemented an "apache_table"  
>> command and I want to get y'alls' feedback on it.
>>
>> apache_table as currently implemented provides read/write access to  
>> four tables in Apache:  notes, headers_in, headers_out,  
>> err_headers_out and subprocess_env.
>>
>> Here's the syntax of the command:
>>
>> apache_table get tableName key
>>
>>    returns the value of the specified key or an empty string
>>
>> apache_table set tableName keyValueList
>> apache_table set tableName key value
>>
>>    In the first case, takes zero or more key-value pairs in  
>> keyValueList and sets each key in the table with its corresponding  
>> value.
>>
>>    In the second case, takes one key and one value and sets that  
>> key and value into the specified table.
>>
>> apache_table unset tableName key
>>
>>    Unsets the specified key-value pair from the table.  It is not  
>> an error to unset a key that doesn't exist.
>>
>> apache_table names tableName
>>
>>    Returns a list of all the keys in the specified table.
>>
>> apache_table array_get tableName
>>
>>    Returns the key-value pairs of the specified table as a list,  
>> suitable for array set.  For instance:
>>
>>    array set notes [apache_table array_get notes]
>>
>> apache_table clear tableName
>>
>>    Invokes apr_table_clear to clear the contents of the specfied  
>> table.
>>
>> I think the above syntax is pretty reasonable.  The part that's  
>> questionable is providing access to headers_in, headers_out,  
>> err_headers_out and subprocess_env.  I know we already have a  
>> mechanism for access to subprocess_env and would be more than  
>> willing to remove any or all of these, or potentially add access to  
>> other tables, although I'm not aware of other tables that would be  
>> candidates.
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: rivet-dev-unsubscribe@...
>> For additional commands, e-mail: rivet-dev-help@...
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@...
For additional commands, e-mail: rivet-dev-help@...


Re: apache_table command for Rivet access to notes table

by Massimo Manghi-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 1 May 2009 11:07:36 -0500, Karl Lehenbauer wrote
> So you would prefer for it to work like an array?  Have an  
> "apache_table exists tableName key" and make "apache_table get  
> tableName key" force an error ?
>

in a word: yes.

-- Massimo



---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@...
For additional commands, e-mail: rivet-dev-help@...


Re: apache_table command for Rivet access to notes table

by Karl Lehenbauer-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On May 2, 2009, at 10:16 AM, Massimo Manghi wrote:

> On Fri, 1 May 2009 11:07:36 -0500, Karl Lehenbauer wrote
>> So you would prefer for it to work like an array?  Have an
>> "apache_table exists tableName key" and make "apache_table get
>> tableName key" force an error ?
>>
>
> in a word: yes.

How about if "get" still returns an empty string when the key doesn't  
exist but I implement "exists" for people who want to clearly  
distinguish between missing and empty?

I also considered adding an optional argument to "get" of a variable  
name to load with the value and having it return 1 or 0 on whether or  
not the key exists...

   if {[apache_table get notes key valueVar]} {
   }

...but it seems like overkill.

-karl

PS - As an aside, Tcl arrays should have a settable default, "array  
default arrayName 0" would be cool, although newer incr will  
instantiate a nonexistent variable at 0.  Also there should be  
something like "array foreach arrayName var code".



---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@...
For additional commands, e-mail: rivet-dev-help@...


Re: apache_table command for Rivet access to notes table

by Massimo Manghi-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Karl Lehenbauer wrote:
> How about if "get" still returns an empty string when the key doesn't
> exist but I implement "exists" for people who want to clearly
> distinguish between missing and empty?
>
it might work out a compromise.

> I also considered adding an optional argument to "get" of a variable
> name to load with the value and having it return 1 or 0 on whether or
> not the key exists...
>
>   if {[apache_table get notes key valueVar]} {
>   }
>
> ...but it seems like overkill.
>

what if 'apache_table get notes key' returns an error if 'key' is not
existing or  returns $valueVar if  the last argument is present?

if {[catch {apache_table get notes key} errcode]} { ... }

if {[apache_table get notes key ""] == ""} { ... }

this would enable us to use also defaults that are numbers...
> -karl
>
> PS - As an aside, Tcl arrays should have a settable default, "array
> default arrayName 0" would be cool, although newer incr will
> instantiate a nonexistent variable at 0.  Also there should be
> something like "array foreach arrayName var code".
>

yes definitely. Will you bring up a proposal for this on Tclcore?


 -- Massimo

---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@...
For additional commands, e-mail: rivet-dev-help@...