On Jan 18, 2007, at 3:44 AM, Nico Verwer wrote:
Steven D. Majewski wrote:
Looking for an alternative way of solving my problem:
What is the working directory for a flowscript ?
If it's based on the directory of the script or the sitemap,
then I can probably just construct a relative path.
I wrote an input module for this, which might help. See http://
wiki.apache.org/cocoon/SitemapPathModule .
The version on the wiki is not up-to-date, so I will update the
code in the attachment.
Best regards,
Nico
Thanks, Nico.
I had seen your module when I was googling this problem in the
mailing list
archives, but I was trying to avoid having to deal with any
customizations outside
of my sitemaps -- I'm not the one who does the builds ( except for my
test server )
so it's simpler if I don't have to touch cocoon.xconf or the libraries.
But after a bit of testing and crawling thru the sources, I
discovered that
ContextPathModule does what I want. And, in fact, looks like it does
it the same
way as your code, except that it is conditional on the path it is
given, depending
on whether the path starts with a "/" :
try {
if(name.startsWith("/")) {
return m_resolver.resolveURI
("context:/"+name).getURI().substring("file:".length());
}
return m_resolver.resolveURI(name).getURI().substring
("file:".length());
} catch( final IOException mue ) {
throw new ConfigurationException( "Cannot resolve
realpath", mue);
}
So {contextpath:./work} gets me the work directory in my (externally
mounted) cocoon app.
The module naming is confusing: realpath doesn't return a Real path.
ContextPathModule, in the docs, is called both ContextPathModule and
ContextRealPathModule in the same paragraph -- and the examples use
{contextrealpath:./path}, which doesn't actually seem to work.
<http://cocoon.apache.org/2.1/userdocs/concepts/modules-ref.html>
I think I tried this earlier in the project, before I had figured
out how to
navigate the sources.
I see the error message above from ContextPathModule says "Cannot
resolve realpath" :
maybe the author wanted to name it realpath and then discovered there
was already
an existing (and misnamed) realpath module. And to add more
confusion to the new
cocoon user, there's also {request:contextPath}, which is, I guess,
cocoon's applet
context, which is something yet again!
And, for the record, I tried creating a file from flowscript with a
relative pathname,
just to see what the current working directory was, and it seems to
leave the file in
my home directory. ( which is where I was when I ran the tomcat
startup script in
/usr/local/java/jakarta-tomcat.../bin ).
-- Steve Majewski
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]