The session value of baseweb and basetopic in extensions

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

The session value of baseweb and basetopic in extensions

BramVanOosterhout
[hidden email]

Dear Foswikiers,
I am extending the CopyContrib extension with a function that will copy a
class a a stub. For details see Task.Item14089.
http://foswiki.org/Tasks/Item14089. I believe the questions below are of a
more general nature.

I would like to have access to the name of the web from where the user is
activating the request. I expected that the $session->{baseweb} value would be
the answer. But that value turns out always to be Main, regardless which page
I place the form with the url http://.../bin/copy on.

I can rationalise this by assuming that the context of the invocation has no
relevance to the copy script and so is not set. The protocol is stateless
after all. But it does beg the question:
  ---> "Why does the view script have that context?"

So now I am left with working the starting web out for myself. I have found
that the only item in session that knows about the topic that started the
invocation is the "referer". I can retrieve the referer from the
Foswiki::Reguest as $referer = $request->header('Referer'). That provides the
refering web page like:
http://192.168.1.170/devwiki/bin/view/Applications/Appweb/AppTopic. From that
I can extract the refering web: Applications/Appweb which is equivalent to the
baseweb.

But what in the case of a command line invocation?
Like:  cd ${CORE}/bin; ./copy.

In that case there is no referer and hence no baseweb, even if it was provided
in session.
   ---> Is the conclusion that a copy script must have a -source parameter to
be sure a sane source web can be provided to a list of topics?

Can you please shed some light on the puzzles above?

Thanks in advance.

--
Bram van Oosterhout


------------------------------------------------------------------------------
_______________________________________________
Foswiki-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/foswiki-discuss
Reply | Threaded
Open this post in threaded view
|

Re: The session value of baseweb and basetopic in extensions

Michael Daum-2
Hi Bram,

during initialization of the request the {webName} and {topicName} properties of the $session object are computed by
decomposing the path info of the call to the script as well as taking the url parameter "topic" under consideration.
Your example seems to lack this pointer, so Foswiki defaults to Main.WebHome.

For a form using the copy script this would look like this:

<form action="%SCRIPTURLPATH{"copy"}%/SomeWeb/SomeTopic">
...
</form>

or more explicitly

<form action="%SCRIPTURLPATH{"copy"}%">
<input type="..." name="topic" value="SomeWeb.SomeTopic">
...
</form>

Michael.

--
-- Michael Daum Consulting
-- Wissensmanagement und Intranet-Technologie
-- https://michaeldaumconsulting.com
-- Tel: +49 (0)40 21 99 27 51

------------------------------------------------------------------------------
_______________________________________________
Foswiki-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/foswiki-discuss