cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@localbar.com>
Subject Re: ClientAddressChooser
Date Thu, 06 Jul 2000 03:17:20 GMT
Stefano Mazzocchi wrote:

> > Hostnames are matched to the domain/host names in the allow and deny
> > sections, by check-and-remove-left sequence, and IP number is by
> > check-and-remove-right. It means that if you give;
> > <host>202.190.60</host>, all hosts from 202.190.60.1 to 202.190.60.254
> > is matched true.
>
> Hmmmm, use wildcards, they are easier to read.
>
> <host>202.190.60.*</host>

OK.

> and allow higher classes such as
>
> <host>202.190.*.*</host>

I Already do.
<host>202.190</host>

>
>
> > In the Sitemap;
> >
> > definition
> >    <map:chooser type="clientaddress"
> > src="class:///org.apache.cocoon.choosers.ClientAddressChooser">
> >      <param name="order" value="allow,deny" />
> >      <param name="all" value="false" />
>
> Why this?
>
> Look at what this forces you to do in the code..
>
> >     /** Sets the Configuration for the Chooser. */
> >     public void setConfiguration(Configuration conf)
> >         throws ConfigurationException
> >     {
> >         Enumeration params = conf.getConfigurations("param");
> >         while (params.hasMoreElements())
> >         {
> >             Configuration param = (Configuration)params.nextElement();
> >             String name = param.getAttribute("name");
> >             String value = param.getAttribute("value");
> >             if ( "order".equals(name) )
> >                 allowThenDeny = "allow,deny".equalsIgnoreCase(value);
> >             if ( "all".equals(name) )
> >                 all = "true".equalsIgnoreCase(value);
> >         }
>
> This code _knows_ the parameter schema and configuration have no notion
> of precedence, to me it's much simpler to write
>
>    <map:chooser type="clientaddress"
>  src="class:///org.apache.cocoon.choosers.ClientAddressChooser">
>      <order>allow,deny</order>
>      <all map:value="false"/>
>
> then write
>
>  String order = conf.getConfiguration("order").getValue();
>  boolean all = conf.getConfiguration("all").getBoolean();
>
> which simplified _both_ parameter readability _and_ code readability.
>
> NOTE: since
>
>  <all map:value="false"/>
>
> is transformed into
>
>  <all>false</all>
>
> by the sitemap compilation phase, you can always assume the most
> important things is the element text (even if attributes are available
> in Configuration but less important)

Thanks.
Well, All things new, there are things you learn everyday, and over time all
your mistakes are called "experience".

Niclas


Mime
View raw message