You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Thorsten Scherler <th...@juntadeandalucia.es> on 2007/11/06 13:32:05 UTC

Input module to return absolute file location of a block

Hi all,

I found BlockPathModule.java and BlockCompletePathModule to return the
servlet path for a block.

However I need an input module which returns me the full file path
location of the base dir of a block.

Like {block-filepath:blockName} e.g. {block-filepath:myBlock1} would
return /home/me/myCocoon/blocks/myblock1.

Not sure whether I have not found the module or whether there is not yet
such a module.

TIA for any information.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Input module to return absolute file location of a block

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Fri, 2007-11-09 at 15:36 +0100, Grzegorz Kossakowski wrote:
> Thorsten Scherler pisze:
> > 
> > which was working fine since I was testing the dispatcher-block, but now
> > since I am in my webapp now the relative path is resolved to the current
> > app and not to the dispatcher block any more. 
> > 
> > Meaning the resources cannot be found anymore.
> 
> That's something weird I think. Crucial question is how do you call dispatcher-block? By using
> cocoon: protocol?

No, not with the cocoon protocol:
<map:match pattern="**.html">
  <map:generate src="servlet:dispatcher:/{1}.html"/>
  <map:serialize type="xhtml"/>
</map:match>

> 
> I also trying to understand your architecture. Does dispatcher-block work the way that it lets to
> override some resources in myWebapp and if they are not defined it fall-backs to some standard ones?

Exactly. The dispatcher has its origin in forrest where you need to be
able to override default configuration easily. We use the locationmap
for this (if no project.dispatcher.home property is set we are using the
dispatcher block):

<!-- Base location of the dispatcher-->
    <match pattern="dispatcher.home">
      <select>
        <location src="{global:project.dispatcher.home}"/>
        <location src="{block-filepath:dispatcher/}"/>
      </select>
    </match>

...



> 
> > I could not find the block-context: which Grzegorz has recommended.
> > 
> > Anybody has an idea, since I am running out of them?
> 
> I've seen that you created an issue resolving your problems with getting absolute path
> (COCOON-2145). However I will insist on asking question about your use-case because I fear that you
> are reinventing the wheel somehow or at least you are basing your architecture on non-standard
> contract. 

http://forrest.apache.org/pluginDocs/plugins_0_80/org.apache.forrest.plugin.internal.dispatcher/

I would not saying reinventing just making it rounder. ;) Well the
classic model in cocoon is to have an aggregation of different parts of
a page (navigation, header, footer, ...) in the sitemap and then use one
or more transformer to do the presentational part.

The disadvantage in the classic model is that you cannot easily extend
the aggregation without touching the sitemap. The dispatcher allows you
define contracts (transformation snippets) and dataUri (data models
which should be transformed by contracts) within a format independent
template (called structurer).

> I have in mind block-context which is *NOT* recommended solution (only quick work-around)
> because it's internal and may change in the future.

Hmm, till now the block-context is returning exactly what I need.
Further I think one import feature of cocoon was always context:// and
cocoon:// protocol. The first to use resources that have not been
exposed via the sitemap and the other use the whole sitemap construct
(incl. all map:mounts).  

Thanks for your feedback.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Input module to return absolute file location of a block

Posted by Grzegorz Kossakowski <gk...@apache.org>.
Thorsten Scherler pisze:
> 
> which was working fine since I was testing the dispatcher-block, but now
> since I am in my webapp now the relative path is resolved to the current
> app and not to the dispatcher block any more. 
> 
> Meaning the resources cannot be found anymore.

That's something weird I think. Crucial question is how do you call dispatcher-block? By using
cocoon: protocol?

I also trying to understand your architecture. Does dispatcher-block work the way that it lets to
override some resources in myWebapp and if they are not defined it fall-backs to some standard ones?

> I could not find the block-context: which Grzegorz has recommended.
> 
> Anybody has an idea, since I am running out of them?

I've seen that you created an issue resolving your problems with getting absolute path
(COCOON-2145). However I will insist on asking question about your use-case because I fear that you
are reinventing the wheel somehow or at least you are basing your architecture on non-standard
contract. I have in mind block-context which is *NOT* recommended solution (only quick work-around)
because it's internal and may change in the future.

-- 
Grzegorz Kossakowski
Committer and PMC Member of Apache Cocoon
http://reflectingonthevicissitudes.wordpress.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Input module to return absolute file location of a block

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Wed, 2007-11-07 at 08:45 +0100, Thorsten Scherler wrote: 
> On Tue, 2007-11-06 at 21:08 +0100, Grzegorz Kossakowski wrote:
> > Thorsten Scherler pisze:
> > > Hi all,
> > > 
> > > I found BlockPathModule.java and BlockCompletePathModule to return the
> > > servlet path for a block.
> > > 
> > > However I need an input module which returns me the full file path
> > > location of the base dir of a block.
> > > 
> > > Like {block-filepath:blockName} e.g. {block-filepath:myBlock1} would
> > > return /home/me/myCocoon/blocks/myblock1.
> > > 
> > > Not sure whether I have not found the module or whether there is not yet
> > > such a module.
> > > 
> > > TIA for any information.
> > 
> > There is a block-context: module AFAIR but it's meant for internal use only.
> > 
> > My question is: why do you need such module?
> 
... 
> The idea is to allow the user to override certain properties and
> locations via the project locationmap. There is one principal property
> (in the dispatcher) which points to the full uri (most likely in the
> file system). 
> 
> <!-- Base location of the builded dispatcher plugin-->
>     <match pattern="dispatcher.home">
>       <location src="{global:dispatcher.home}"/>
>     </match>
> 
> ...but I thought about it and I think I can solve the problem a wee bit
> different since it is caused by a slight overkill of customization. 

No, it is not working without an absolute path. :(

Let me explain why and maybe there is a solution that I do not see.

I have a block and my main webapp, where I only define some contracts.
All requests are passed to the block which is using my project specific
contracts for doing transformations and alike. 

The request/response circle is something like the following:

request -> myWebapp -> dispatcher-block -> locationmap-resolving ->
dispatcher-block -> myWebapp -> response

The problem is with this invocation that 
<match pattern="dispatcher.home"> 
  <location src="{global:dispatcher.home}"/>
</match>
needs to be absolute.

Will developing I had 
<match pattern="dispatcher.home">
  <location src=""/>
</match>
...
<match pattern="hooks-to-*.xsl">
  <location src="{lm:dispatcher.home}resource/stylesheets/{0}"/>
</match>

which was working fine since I was testing the dispatcher-block, but now
since I am in my webapp now the relative path is resolved to the current
app and not to the dispatcher block any more. 

Meaning the resources cannot be found anymore.

I could not find the block-context: which Grzegorz has recommended.

Anybody has an idea, since I am running out of them?

TIA

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


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Input module to return absolute file location of a block

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Tue, 2007-11-06 at 21:08 +0100, Grzegorz Kossakowski wrote:
> Thorsten Scherler pisze:
> > Hi all,
> > 
> > I found BlockPathModule.java and BlockCompletePathModule to return the
> > servlet path for a block.
> > 
> > However I need an input module which returns me the full file path
> > location of the base dir of a block.
> > 
> > Like {block-filepath:blockName} e.g. {block-filepath:myBlock1} would
> > return /home/me/myCocoon/blocks/myblock1.
> > 
> > Not sure whether I have not found the module or whether there is not yet
> > such a module.
> > 
> > TIA for any information.
> 
> There is a block-context: module AFAIR but it's meant for internal use only.
> 
> My question is: why do you need such module?

I am porting ATM the dispatcher (forrest plugin) to a cocoon block. This
forrest plugin makes use of different contracts. 

This contracts can be stored in different locations and the dispatcher
makes use of the locationmap to resolve the contract we are going to
use.

Till now forrest projects have been very open to be overridden via our
properties system and we offer a elaborated fallback mechanism via the
locationmap to the user.

The idea is to allow the user to override certain properties and
locations via the project locationmap. There is one principal property
(in the dispatcher) which points to the full uri (most likely in the
file system). 

<!-- Base location of the builded dispatcher plugin-->
    <match pattern="dispatcher.home">
      <location src="{global:dispatcher.home}"/>
    </match>

...but I thought about it and I think I can solve the problem a wee bit
different since it is caused by a slight overkill of customization. 

Will keep you informant which route I finally took.

Thanks for the pointer.

salu2


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


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Input module to return absolute file location of a block

Posted by Grzegorz Kossakowski <gk...@apache.org>.
Thorsten Scherler pisze:
> Hi all,
> 
> I found BlockPathModule.java and BlockCompletePathModule to return the
> servlet path for a block.
> 
> However I need an input module which returns me the full file path
> location of the base dir of a block.
> 
> Like {block-filepath:blockName} e.g. {block-filepath:myBlock1} would
> return /home/me/myCocoon/blocks/myblock1.
> 
> Not sure whether I have not found the module or whether there is not yet
> such a module.
> 
> TIA for any information.

There is a block-context: module AFAIR but it's meant for internal use only.

My question is: why do you need such module?

-- 
Grzegorz Kossakowski
Committer and PMC Member of Apache Cocoon
http://reflectingonthevicissitudes.wordpress.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org