Site variants

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

Site variants

Colin O'Brien
Hi,

I want to be able to use the same code (java/xslt/xpl) to serve sites
for a number of clients.
I can use the Request Generator to get the domain name and I'm thinking
from that I can create a path to where that client's files exist
(everything is still in plain files, not database).

I'm wondering what the best (ops) way would be to then make that path
available to subsequent path-flows/pipelines etc?
There would be other client specific information that would also need
to travel along with the path.

Thanks & regards
Colin




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Site variants

Alessandro  Vernet
Administrator
--- Colin O'Brien <[hidden email]> wrote:

> I want to be able to use the same code (java/xslt/xpl) to serve sites
> for a number of clients.
> I can use the Request Generator to get the domain name and I'm thinking
> from that I can create a path to where that client's files exist
> (everything is still in plain files, not database).
>
> I'm wondering what the best (ops) way would be to then make that path
> available to subsequent path-flows/pipelines etc?
> There would be other client specific information that would also need
> to travel along with the path.
Hi Colin,

In web applications, you often have this concept of configuration: i.e.
parameters which values are unknown to the programmer. You can have "user
configuration" (it role, full name, etc) and "application configuration"
(the path in your example would fall in this category).

This is a common pattern and one solution here is to create a pipeline
(get-user-configuration.xpl or get-application-configuration.xpl). This
pipeline tries to get an XML document containing the configuration data
using the scope generator (respectively from the session or the
application scope). If it finds it, it returns that document, otherwise it
creates it (e.g. using this request generator in your case), stores it in
the scope, and returns it. You then use this pipeline everywhere you need
information stored in the configuration.

Alex

--
Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Site variants

Colin O'Brien
On Aug 9, 2005, at 3:04 PM, Alessandro Vernet wrote:

> --- Colin O'Brien <[hidden email]> wrote:
>> I want to be able to use the same code (java/xslt/xpl) to serve sites
>> for a number of clients.
>> I can use the Request Generator to get the domain name and I'm
>> thinking
>> from that I can create a path to where that client's files exist
>> (everything is still in plain files, not database).
>>
>> I'm wondering what the best (ops) way would be to then make that path
>> available to subsequent path-flows/pipelines etc?
>> There would be other client specific information that would also need
>> to travel along with the path.
>
> Hi Colin,
>
> In web applications, you often have this concept of configuration: i.e.
> parameters which values are unknown to the programmer. You can have
> "user
> configuration" (it role, full name, etc) and "application
> configuration"
> (the path in your example would fall in this category).
>
> This is a common pattern and one solution here is to create a pipeline
> (get-user-configuration.xpl or get-application-configuration.xpl). This
> pipeline tries to get an XML document containing the configuration data
> using the scope generator (respectively from the session or the
> application scope). If it finds it, it returns that document,
> otherwise it
> creates it (e.g. using this request generator in your case), stores it
> in
> the scope, and returns it. You then use this pipeline everywhere you
> need
> information stored in the configuration.
>
> Alex
Hi Alex,

thanks for the response. Yes, I can get the domain name and from that
generate a path.
Given that I cannot do anything until I know this, I have been
experimenting with the idea of a "prologue" that someone mentioned on
the list a while back.
I was also going that way, because I didn't (think I) wanted to be
repeatedly calling on the generator.
As you say, I could have a sub-pipeline that I call at the start of a
pipeline, but then I would have to duplicate that across each pipeline,
something (I think) I would want to avoid.

You say "store it in scope", but then that is my question ;-)
What is the best way to do that?

Perhaps create an xforms instance (xml submission?) in the same way
that the page-flow controller can now do?
This though seems to imply that a page-flow be able to take two xml
submissions and pass them on to a pipeline?

I have looked at the scope generator.
Application scope is not applicable, because the aim is for one
application to serve (publish) many different sites.
Session scope I don't think is applicable, since in most instances the
user will not have logged in.
The request scope obviously looks relevant, but I fear that I cannot
see how I get something in there (say in my "prologue" or the PFC) in
order to retrieve it later?

Or maybe it is most efficient to simply call this pipeline that gets
that domain name and then accesses a file for that client's site
parameters?

Thanks again
Colin




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Site variants

Alessandro  Vernet
Administrator
--- Colin O'Brien <[hidden email]> wrote:
> I have looked at the scope generator.
> Application scope is not applicable, because the aim is for one
> application to serve (publish) many different sites.
> Session scope I don't think is applicable, since in most instances the
> user will not have logged in.
> The request scope obviously looks relevant, but I fear that I cannot
> see how I get something in there (say in my "prologue" or the PFC) in
> order to retrieve it later?

Hi Colin,

Yes, in your case it seems like the request scope is your best option.

You could imagine that the PFC would support a concept of prologue, which
is called at every request and can populate the request scope. But you
don't need that concept here: just implement that pipeline I was
describing (return data from request scope, or compute and store it in the
request scope if it is not there yet), and call that pipeline in every
place you need that information. This is just a processor call, which
takes as many lines of XPL as calling the scope generator.

Alex

--
Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Site variants

Colin O'Brien
Hi,

I now have a pipeline that extracts the domain name from the request
and creates a path to the files (outside of oxf:) that provide the
content for the current site.

Then I want to get the xml from one of these files, just using the
url-generator.
When I type the full filepath in by hand in the url tag, the content is
correctly loaded into the output.
If if try to construct a filepath from my path element in my parameter
set, using xpointer and concatenating with the filename, then the
output from the url-generator is *the text of the current pipeline*

?

Thanks & regards
Colin




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Site variants

Alessandro  Vernet
Administrator
--- Colin O'Brien <[hidden email]> wrote:
> Then I want to get the xml from one of these files, just using the
> url-generator.
> When I type the full filepath in by hand in the url tag, the content is
> correctly loaded into the output.
> If if try to construct a filepath from my path element in my parameter
> set, using xpointer and concatenating with the filename, then the
> output from the url-generator is *the text of the current pipeline*

Hi Colin,

Can you give us the "href" expression that you are using?

Alex

--
Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Site variants

Colin O'Brien
Hi Alex,

I was testing this in my current project (based on 2.8) and have now  
verified the same behavior in a new project with 3.0b2...
<url>#filespath#xpointer(concat(string(/*/filespath),string("../
siteparams.xml")))</url>

filespath is both the name of previously generated data and the element  
within it that is the path to the file.
I have tried a few variations, such as adding a protocol (file:).
There are no errors reported.
The url-generator is followed by a file-serializer.
As I said, that file is output looking identical (apart from some  
formatting) to the pipeline being executed.

If I instead substitute this line
<url>file:////www/docs/testsite/review/../siteparams.xml</url>
then I get the contents of siteparams.xml
/www/docs/testsite/review/ is the content of filespath element

I am more than willing to believe I am completely on the wrong track  
with my efforts with xpointer, but my experiments came to an end when  
pipeline code started becoming my output!

Thanks for your help
Colin


On Aug 12, 2005, at 2:55 PM, Alessandro Vernet wrote:

> --- Colin O'Brien <[hidden email]> wrote:
>> Then I want to get the xml from one of these files, just using the
>> url-generator.
>> When I type the full filepath in by hand in the url tag, the content  
>> is
>> correctly loaded into the output.
>> If if try to construct a filepath from my path element in my parameter
>> set, using xpointer and concatenating with the filename, then the
>> output from the url-generator is *the text of the current pipeline*
>
> Hi Colin,
>
> Can you give us the "href" expression that you are using?
>
> Alex
>
> --
> Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/
>
>
> --
> You receive this message as a subscriber of the  
> [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Site variants

Erik Bruchez
Administrator
Colin O'Brien wrote:

 > I was testing this in my current project (based on 2.8) and have now
 > verified the same behavior in a new project with 3.0b2...
 > <url>#filespath#xpointer(concat(string(/*/filespath),string("../
 > siteparams.xml")))</url>
 >
 > filespath is both the name of previously generated data and the element
 > within it that is the path to the file.
 > I have tried a few variations, such as adding a protocol (file:).
 > There are no errors reported.
 > The url-generator is followed by a file-serializer.
 > As I said, that file is output looking identical (apart from some
 > formatting) to the pipeline being executed.
 >
 > If I instead substitute this line
 > <url>file:////www/docs/testsite/review/../siteparams.xml</url>
 > then I get the contents of siteparams.xml
 > /www/docs/testsite/review/ is the content of filespath element
 >
 > I am more than willing to believe I am completely on the wrong track
 > with my efforts with xpointer, but my experiments came to an end when
 > pipeline code started becoming my output!

Any chance you can send the whole XPL pipeline? Also, try to put a
debug attribute on the processor input with the XPointer href, and to
send the XML document which is logged out.

I am sure it is in fact a very simple problem!

-Erik




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Site variants

Erik Bruchez
Administrator
All,

I attach an example of OPS "prologue" which, based on a virtual server
name, stores a server configuration into the request scope and then
calls the regular Page Flow.

-Erik


<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
          xmlns:oxf="http://www.orbeon.com/oxf/processors"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <!-- Obtain server name  -->
    <p:processor name="oxf:request">
        <p:input name="config">
            <config>
                <include>/request/server-name</include>
            </config>
        </p:input>
        <p:output name="data" id="request"/>
    </p:processor>

    <!-- Format URL generator config based on server name -->
    <p:processor name="oxf:xslt">
        <p:input name="config">
            <config xsl:version="2.0">
                <xsl:variable name="request" select="/request" as="element()"/>
                <xsl:variable name="server-names" select="('localhost', 'www.example.org')" as="xs:string+"/>
                <xsl:variable name="server-paths" select="('c:\my\path\to\localhost', 'c:\my\path\to\example.org')" as="xs:string+"/>
                <url>
                    <xsl:value-of select="concat('file:///', $server-paths[index-of($server-names, $request/server-name)], '/server-config.xml')"/>
                </url>
            </config>
        </p:input>
        <p:input name="data" href="#request"/>
        <p:output name="data" id="url-generator-config"/>
    </p:processor>

    <!-- Read server config -->
    <p:processor name="oxf:url-generator">
        <p:input name="config" href="#url-generator-config"/>
        <p:output name="data" id="server-config"/>
    </p:processor>

    <!-- Store server config into request scope -->
    <p:processor name="oxf:scope-serializer">
        <p:input name="config">
            <config>
                <key>server-config</key>
                <scope>request</scope>
            </config>
        </p:input>
        <p:input name="data" href="#server-config"/>
    </p:processor>

    <!-- Execute regular page flow -->
    <p:processor name="oxf:page-flow">
        <p:input name="controller" href="page-flow.xml"/>
    </p:processor>

</p:config>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws