You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by Thorsten Scherler <th...@juntadeandalucia.es> on 2007/05/23 09:38:37 UTC

Re: Global configuration parameters

Moving thread to dev.

On Tue, 2007-05-22 at 23:45 +0200, Markus Angst wrote:
> Joern Nettingsmeier wrote:
> > Markus Angst wrote:
>  >>
> >> My first attempt was to use lenya.properties.xml. Since this works only 
> >> globally and on a module level, I have to create a module to smuggle the 
> >> file into our publication. It works, but it feels like using a big tool 
> >> for a small task and I would need a new module for every publication 
> >> that needs its own lenya.properties.xml. I think it would be a nice 
> >> feature to have a lenya.properties.xml on a publication level (just drop 
> >> it into $PUB_HOME).
> > 
> > +1. neat idea. thorsten, iirc you came up with that feature in the first 
> > place, right? how difficult could this be?
> 
> My Java knowledge is very limited, but I feel that tweaking 
> modules-core/properties/.../PropertiesModule.java would do.

Yeah, the only problem was that at the time I wrote the code when doing
initialize() I did not had any information about which pubs are builded.

We can implement the following PSEUDO (!!!) code (in the spirit of the
modules properties):
in service(...):
publicationManager = (PublicationManager)
manager.lookup(PublicationManager.ROLE);

in initialize():
String[] pub2src = publicationManager.getPubsIds();
for (int i = 0; i < publication2src.length; i++) {
      String id = publication2src[i];
      Object value = publicationManager.getBaseURI(id);
      if (value != null) {
        lenyaPropertiesStringURI = value + SystemUtils.FILE_SEPARATOR
            + PROPERTY_NAME;
        filteringProperties =
loadXMLPropertiesFromURI(filteringProperties,
            lenyaPropertiesStringURI);
      }
    }

Where PublicationManager is not working this way. You need to change the
code using Publication[] getPublications(DocumentFactory factory)
instead getPubsIds() and some other changes.

After we fixed the proxy issue I will have a look if no patch submission
beats me to it.

salu2
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Global configuration parameters

Posted by Markus Angst <ma...@inventec.ch>.
Thorsten Scherler wrote:
> On Wed, 2007-05-23 at 16:40 +0200, Markus Angst wrote:
>>> On Tue, 2007-05-22 at 23:45 +0200, Markus Angst wrote:
>>>> Joern Nettingsmeier wrote:
>>>>> Markus Angst wrote:
>>>>>>
>>>>>> My first attempt was to use lenya.properties.xml. Since this works only 
>>>>>> globally and on a module level, I have to create a module to smuggle the 
>>>>>> file into our publication. It works, but it feels like using a big tool 
>>>>>> for a small task and I would need a new module for every publication 
>>>>>> that needs its own lenya.properties.xml. I think it would be a nice 
>>>>>> feature to have a lenya.properties.xml on a publication level (just drop 
>>>>>> it into $PUB_HOME).
>>>>> +1. neat idea. thorsten, iirc you came up with that feature in the first 
>>>>> place, right? how difficult could this be?
>>>> My Java knowledge is very limited, but I feel that tweaking 
>>>> modules-core/properties/.../PropertiesModule.java would do.
>>> Yeah, the only problem was that at the time I wrote the code when doing
>>> initialize() I did not had any information about which pubs are builded.
>> By no means I wanted to be a know-it-all.
> 
> I never understood it like this. You saved time pointing out the class
> where I needed to look again. Above was an explanation why it have not
> been in it the first place.
> 
> Nice to see the module in use. :)
> 
>>> After we fixed the proxy issue I will have a look if no patch submission
>>> beats me to it.
>> I am glad to hear that it can be done. Thanks for taking care of it.
> 
> jeje, I guess you did not get the wink. ;) 

Well, I was trying to wink back :-)

> Feel free to save some more of my time submitting a patch. 

I would love to do that but my Java/Lenya knowledge is really not up to the 
point where I would submit patches (I even have to find out first how to make 
one in Eclipse). Well, one has to start somewhere... I will try to come up with 
something (resembling closely to what you have proposed), but don't hold your 
breath. It will take me some time to read all the API docs of Lenya... ;-)

Regards,
Markus Angst

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Global configuration parameters

Posted by Markus Angst <ma...@inventec.ch>.
Andreas Hartmann wrote:
> Thorsten Scherler schrieb:
> 
> [...]
> 
>> One thing is:
>>      Publication[] getPublications(DocumentFactory factory) throws PublicationException;
>> +
>> +    /**
>> +     * @return All publication directories.
>> +     * @throws PublicationException if an error occurrs.
>> +     */    
>> +    File[] getPublicationDirs() throws PublicationException;
>>
>> I will hear Andreas say that we should not use File[] since that would force that a publication is 
>> implemented in a file system. How about Publication[] getPublications() instead?
>>
>> Then later on using publication.getDirectory() to determine the uri.
> 
> +1
> 
> We should try to keep the API minimal - getPublicationDirs() is just a
> convenience method and doesn't provide any additional functionality.

I understand. See also my reply to Thorsten.

Thanks!
Markus Angst

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Global configuration parameters

Posted by Andreas Hartmann <an...@apache.org>.
Thorsten Scherler schrieb:

[...]

> One thing is:
>      Publication[] getPublications(DocumentFactory factory) throws PublicationException;
> +
> +    /**
> +     * @return All publication directories.
> +     * @throws PublicationException if an error occurrs.
> +     */    
> +    File[] getPublicationDirs() throws PublicationException;
> 
> I will hear Andreas say that we should not use File[] since that would force that a publication is 
> implemented in a file system. How about Publication[] getPublications() instead?
> 
> Then later on using publication.getDirectory() to determine the uri.

+1

We should try to keep the API minimal - getPublicationDirs() is just a
convenience method and doesn't provide any additional functionality.

-- Andreas

> 
> WDYT?
> 
> The other thing is that it is easier if the patch comes in one file instead of a zip. 
> This way we can see it directly in the browser and it is easier to apply 
> (one file instead of 3 in this case).
> 
> salu2


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Global configuration parameters

Posted by Andreas Hartmann <an...@apache.org>.
Thorsten Scherler schrieb:

[...]

>> getDocumentFactory wants a session or a request. Can I create
>> or access one of
>> the two? I was guessing (without knowing how to find out myself) that
>> PropertiesModule.initialize() runs at a point in time where
>> neither is
>> available, that's why I tried to find my way around it...
>
> Yeah and you did a nice job.

+1 :)


> Try in in service(ServiceManager manager):
> ContextUtility context = null;
> context = (ContextUtility) manager.lookup(ContextUtility.ROLE);
> Request request = context.getRequest();
> DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager,
> request);


BTW, just a little note on this: Whenever you acquire a service, you
have to release it in the finally block:

Request request;
ContextUtility context = null;

try {
    context = (ContextUtility) manager.lookup(ContextUtility.ROLE);
    request = context.getRequest();
}
finally {
    manager.release(context);
}

DocumentFactory factory =
        DocumentUtil.getDocumentFactory(this.manager, request);


-- Andreas

> Should work, where factory should be a field.
> 
>>> The other thing is that it is easier if the patch comes in one file instead of a zip. 
>>> This way we can see it directly in the browser and it is easier to apply 
>>> (one file instead of 3 in this case).
>> I see. Is it ok to just concatenate the separate patch files? Or is there a 
>> special way of doing this?
> 
> No, concatenate them is fine.
> 
> Thanks.
> 
> salu2
> 
>> Thanks!
>> Markus Angst
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
>> For additional commands, e-mail: dev-help@lenya.apache.org
>>


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Global configuration parameters

Posted by Thorsten Scherler <th...@apache.org>.
On Mon, 2007-06-04 at 20:46 +0200, Markus Angst wrote:
> Thorsten Scherler wrote:
>  >> On Thu, 2007-05-31 at 17:55 +0200, Markus Angst wrote:
> >> I submitted a patch: http://issues.apache.org/bugzilla/show_bug.cgi?id=42558
> >>
> >> It works for me but I don't know if my code changes are politically correct, so 
> >> please review. Any changes and comments welcome.
> > 
> > I had a quick look. 
> > Nice work Markus.
> > 
> > One thing is:
> >      Publication[] getPublications(DocumentFactory factory) throws PublicationException;
> > +
> > +    /**
> > +     * @return All publication directories.
> > +     * @throws PublicationException if an error occurrs.
> > +     */    
> > +    File[] getPublicationDirs() throws PublicationException;
> > 
> > I will hear Andreas say that we should not use File[] since that would force that a publication is 
> > implemented in a file system. 
> 
> I get the point.
> 
> > How about Publication[] getPublications() instead?
> 
> Yes I know, that's what you suggested in the first place. I guess you mean 
> something like this:
> 
> DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
> Publication[] pubs = publicationManager.getPublications(factory);
> 
> getDocumentFactory wants a session or a request. Can I create or access one of 
> the two? I was guessing (without knowing how to find out myself) that 
> PropertiesModule.initialize() runs at a point in time where neither is 
> available, that's why I tried to find my way around it...

Yeah and you did a nice job. 

> So I really need a little hint for this. :-)


Try in in service(ServiceManager manager):
ContextUtility context = null;
context = (ContextUtility) manager.lookup(ContextUtility.ROLE);
Request request = context.getRequest();
DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager,
request);

Should work, where factory should be a field.

> 
> > The other thing is that it is easier if the patch comes in one file instead of a zip. 
> > This way we can see it directly in the browser and it is easier to apply 
> > (one file instead of 3 in this case).
> 
> I see. Is it ok to just concatenate the separate patch files? Or is there a 
> special way of doing this?

No, concatenate them is fine.

Thanks.

salu2

> 
> Thanks!
> Markus Angst
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
> For additional commands, e-mail: dev-help@lenya.apache.org
> 
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Global configuration parameters

Posted by Markus Angst <ma...@inventec.ch>.
Thorsten Scherler wrote:
 >> On Thu, 2007-05-31 at 17:55 +0200, Markus Angst wrote:
>> I submitted a patch: http://issues.apache.org/bugzilla/show_bug.cgi?id=42558
>>
>> It works for me but I don't know if my code changes are politically correct, so 
>> please review. Any changes and comments welcome.
> 
> I had a quick look. 
> Nice work Markus.
> 
> One thing is:
>      Publication[] getPublications(DocumentFactory factory) throws PublicationException;
> +
> +    /**
> +     * @return All publication directories.
> +     * @throws PublicationException if an error occurrs.
> +     */    
> +    File[] getPublicationDirs() throws PublicationException;
> 
> I will hear Andreas say that we should not use File[] since that would force that a publication is 
> implemented in a file system. 

I get the point.

> How about Publication[] getPublications() instead?

Yes I know, that's what you suggested in the first place. I guess you mean 
something like this:

DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
Publication[] pubs = publicationManager.getPublications(factory);

getDocumentFactory wants a session or a request. Can I create or access one of 
the two? I was guessing (without knowing how to find out myself) that 
PropertiesModule.initialize() runs at a point in time where neither is 
available, that's why I tried to find my way around it...
So I really need a little hint for this. :-)

> The other thing is that it is easier if the patch comes in one file instead of a zip. 
> This way we can see it directly in the browser and it is easier to apply 
> (one file instead of 3 in this case).

I see. Is it ok to just concatenate the separate patch files? Or is there a 
special way of doing this?

Thanks!
Markus Angst

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Global configuration parameters

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Thu, 2007-05-31 at 17:55 +0200, Markus Angst wrote:
> > On Wed, 2007-05-23 at 16:40 +0200, Markus Angst wrote:
> >>> On Tue, 2007-05-22 at 23:45 +0200, Markus Angst wrote:
> >>>> Joern Nettingsmeier wrote:
> >>>>> Markus Angst wrote:
> >>>>  >>
> >>>>>> My first attempt was to use lenya.properties.xml. Since this works only 
> >>>>>> globally and on a module level, I have to create a module to smuggle the 
> >>>>>> file into our publication. It works, but it feels like using a big tool 
> >>>>>> for a small task and I would need a new module for every publication 
> >>>>>> that needs its own lenya.properties.xml. I think it would be a nice 
> >>>>>> feature to have a lenya.properties.xml on a publication level (just drop 
> >>>>>> it into $PUB_HOME).
> >>>>> +1. neat idea. thorsten, iirc you came up with that feature in the first 
> >>>>> place, right? how difficult could this be?
> >>>> My Java knowledge is very limited, but I feel that tweaking 
> >>>> modules-core/properties/.../PropertiesModule.java would do.
> >>> Yeah, the only problem was that at the time I wrote the code when doing
> >>> initialize() I did not had any information about which pubs are builded.
> 
> > Feel free to save some more of my time submitting a patch.
> 
> I submitted a patch: http://issues.apache.org/bugzilla/show_bug.cgi?id=42558
> 
> It works for me but I don't know if my code changes are politically correct, so 
> please review. Any changes and comments welcome.
> 
> Thanks!
> Markus Angst

I had a quick look. 
Nice work Markus.

One thing is:
     Publication[] getPublications(DocumentFactory factory) throws PublicationException;
+
+    /**
+     * @return All publication directories.
+     * @throws PublicationException if an error occurrs.
+     */    
+    File[] getPublicationDirs() throws PublicationException;

I will hear Andreas say that we should not use File[] since that would force that a publication is 
implemented in a file system. How about Publication[] getPublications() instead?

Then later on using publication.getDirectory() to determine the uri.

WDYT?

The other thing is that it is easier if the patch comes in one file instead of a zip. 
This way we can see it directly in the browser and it is easier to apply 
(one file instead of 3 in this case).

salu2
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Global configuration parameters

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Thu, 2007-05-31 at 17:55 +0200, Markus Angst wrote:
> > On Wed, 2007-05-23 at 16:40 +0200, Markus Angst wrote:
> >>> On Tue, 2007-05-22 at 23:45 +0200, Markus Angst wrote:
> >>>> Joern Nettingsmeier wrote:
> >>>>> Markus Angst wrote:
> >>>>  >>
> >>>>>> My first attempt was to use lenya.properties.xml. Since this works only 
> >>>>>> globally and on a module level, I have to create a module to smuggle the 
> >>>>>> file into our publication. It works, but it feels like using a big tool 
> >>>>>> for a small task and I would need a new module for every publication 
> >>>>>> that needs its own lenya.properties.xml. I think it would be a nice 
> >>>>>> feature to have a lenya.properties.xml on a publication level (just drop 
> >>>>>> it into $PUB_HOME).
> >>>>> +1. neat idea. thorsten, iirc you came up with that feature in the first 
> >>>>> place, right? how difficult could this be?
> >>>> My Java knowledge is very limited, but I feel that tweaking 
> >>>> modules-core/properties/.../PropertiesModule.java would do.
> >>> Yeah, the only problem was that at the time I wrote the code when doing
> >>> initialize() I did not had any information about which pubs are builded.
> 
> > Feel free to save some more of my time submitting a patch.
> 
> I submitted a patch: http://issues.apache.org/bugzilla/show_bug.cgi?id=42558
> 
> It works for me but I don't know if my code changes are politically correct, so 
> please review. Any changes and comments welcome.
> 
> Thanks!
> Markus Angst

To you Markus, nice.

Will have a look soonish and apply it. 
Need to get some other projects finished atm first.

Thanks for your contribution. 

salu2
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Global configuration parameters

Posted by Markus Angst <ma...@inventec.ch>.
> On Wed, 2007-05-23 at 16:40 +0200, Markus Angst wrote:
>>> On Tue, 2007-05-22 at 23:45 +0200, Markus Angst wrote:
>>>> Joern Nettingsmeier wrote:
>>>>> Markus Angst wrote:
>>>>  >>
>>>>>> My first attempt was to use lenya.properties.xml. Since this works only 
>>>>>> globally and on a module level, I have to create a module to smuggle the 
>>>>>> file into our publication. It works, but it feels like using a big tool 
>>>>>> for a small task and I would need a new module for every publication 
>>>>>> that needs its own lenya.properties.xml. I think it would be a nice 
>>>>>> feature to have a lenya.properties.xml on a publication level (just drop 
>>>>>> it into $PUB_HOME).
>>>>> +1. neat idea. thorsten, iirc you came up with that feature in the first 
>>>>> place, right? how difficult could this be?
>>>> My Java knowledge is very limited, but I feel that tweaking 
>>>> modules-core/properties/.../PropertiesModule.java would do.
>>> Yeah, the only problem was that at the time I wrote the code when doing
>>> initialize() I did not had any information about which pubs are builded.

> Feel free to save some more of my time submitting a patch.

I submitted a patch: http://issues.apache.org/bugzilla/show_bug.cgi?id=42558

It works for me but I don't know if my code changes are politically correct, so 
please review. Any changes and comments welcome.

Thanks!
Markus Angst

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Global configuration parameters

Posted by Thorsten Scherler <th...@apache.org>.
On Wed, 2007-05-23 at 16:40 +0200, Markus Angst wrote:
> > On Tue, 2007-05-22 at 23:45 +0200, Markus Angst wrote:
> >> Joern Nettingsmeier wrote:
> >>> Markus Angst wrote:
> >>  >>
> >>>> My first attempt was to use lenya.properties.xml. Since this works only 
> >>>> globally and on a module level, I have to create a module to smuggle the 
> >>>> file into our publication. It works, but it feels like using a big tool 
> >>>> for a small task and I would need a new module for every publication 
> >>>> that needs its own lenya.properties.xml. I think it would be a nice 
> >>>> feature to have a lenya.properties.xml on a publication level (just drop 
> >>>> it into $PUB_HOME).
> >>> +1. neat idea. thorsten, iirc you came up with that feature in the first 
> >>> place, right? how difficult could this be?
> >> My Java knowledge is very limited, but I feel that tweaking 
> >> modules-core/properties/.../PropertiesModule.java would do.
> > 
> > Yeah, the only problem was that at the time I wrote the code when doing
> > initialize() I did not had any information about which pubs are builded.
> 
> By no means I wanted to be a know-it-all.

I never understood it like this. You saved time pointing out the class
where I needed to look again. Above was an explanation why it have not
been in it the first place.

Nice to see the module in use. :)

> 
> > After we fixed the proxy issue I will have a look if no patch submission
> > beats me to it.
> 
> I am glad to hear that it can be done. Thanks for taking care of it.

jeje, I guess you did not get the wink. ;) 

Feel free to save some more of my time submitting a patch. 

TIA

salu2
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Global configuration parameters

Posted by Markus Angst <ma...@inventec.ch>.
> On Tue, 2007-05-22 at 23:45 +0200, Markus Angst wrote:
>> Joern Nettingsmeier wrote:
>>> Markus Angst wrote:
>>  >>
>>>> My first attempt was to use lenya.properties.xml. Since this works only 
>>>> globally and on a module level, I have to create a module to smuggle the 
>>>> file into our publication. It works, but it feels like using a big tool 
>>>> for a small task and I would need a new module for every publication 
>>>> that needs its own lenya.properties.xml. I think it would be a nice 
>>>> feature to have a lenya.properties.xml on a publication level (just drop 
>>>> it into $PUB_HOME).
>>> +1. neat idea. thorsten, iirc you came up with that feature in the first 
>>> place, right? how difficult could this be?
>> My Java knowledge is very limited, but I feel that tweaking 
>> modules-core/properties/.../PropertiesModule.java would do.
> 
> Yeah, the only problem was that at the time I wrote the code when doing
> initialize() I did not had any information about which pubs are builded.

By no means I wanted to be a know-it-all.

> After we fixed the proxy issue I will have a look if no patch submission
> beats me to it.

I am glad to hear that it can be done. Thanks for taking care of it.

Regards,
Markus Angst

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org