How best to implement sub-sites with the < site > tag?

What is the best way to implement sub-sites with eliom and ocsigenserver?

I notice that I can define additional < site > tags under one < host > tag and then define < eliom module=… > tags within each < site > tag in the conf.in file. And I found that I can create two completely independent parallel eliom projects (let us call them A and B), and merely symbolically link to the A.cma file compiled in project A from project B alongside it’s own B.cma generated by its own B.eliom file. I did this under the local/lib/ directory, in this case local/lib/B. Then I added a second < site > tag with a nested < eliom module=… > tag to the conf.in file, with the module attribute of the < eliom > tag pointing to the local/lib/B/symbolic-link-to-A.cma.

Everything seems to work, but I just guessed that it would work and tried it. Is this ok? Is this the intended manner of implementing additional sub-sites with eliom? Does this present any issues now or in the future for security if I implement TLS on the server, or Authbasic for just one of the sites, etc? As far as I can tell, against, everything seems ok, but I do not know the internals of ocsigenserver nor the implications of doing what I did.

And as far as I can tell we can only work with one .eliom file per project, so I cannot see how to get a second .eliom file into one project. The only other alternative might be to combine the contents of two .eliom files to define one larger site with all the services defined in both, but that is not always optimal or desired.

Thank you.

Hi,

I don’t fully understand what you want to do, but here are a few explanations on how it works:

Ocsigen server uses Dynlink to load all the modules from the configuarton file. First it loads all <extensions>, then all <eliommodule> in the context described by <host> and <site> tags.
You can use several <eliommodule> tags in the same <site> (and each of them corresponds to a cmo and a cma, compiled from one or several .eliom files).

Tag <eliom/> (usually without attributes) is used to indicate the precise moment when the page must be generated (e.g. after <staticmod> and before <deflate>. Ocsigen server takes the directives from config file in order when it wants to generate a page).

Obviously <eliommodule module="local/lib/B/symbolic-link-to-A.cma"/> is equivalent to <eliommodule module="local/lib/A/A.cma"/>. You can load several times the same module in different sites.
If you want several sites to use common functions or references, you must load them before (exactly as if you were using #load in toplevel).

Hope this helps,
Vincent

Vincent,
Your answer is helpful to a point. You state that “You can use several
tags in the same (and each of them corresponds to a
cmo and a cma, compiled from one or several .eliom files).” My confusion
stems from how to compile multiple .eliom files into more than one set of
cmo and cma files? The conf.in and Makefile.options use and define a
PROJECT_NAME variable that determines the names of the set of cmo and cma
files. So it seems we cannot compile more than one set of project_name.cmo
and cma files regardless of how many .eliom files we have as input. Is it
possible to configure a project to output N sets of cmo and cma files from
N .eliom files with different names for use by N < eliom module=…> tags?
Or do I have to have compile each .eliom file in turn? Or compile each
.eliom in it’s own project and then link or copy the cma and cmo files?

Multiple .eliom files in one project do get compiled but into just one
resulting set of project_name.cmo and cma files. This is not ideal for me
at present since I have defined some resources for < site > A that should
be protected by < authbasic > while resources in < site > B should NOT be
protected by < authbasic >. Here’s the relevant portion for what I envision
in my conf.in and it is not readily apparent to me how to generate and
provide the B < site > cma other than copying or linking from elsewhere
(which I am willing to do but I don’t know if that is the optimal
solution):
< host … >
< site path=“A” >
< authbasic realm=“Arealm” >
< plain login=“Alogin” password=“Apassword” / >
< /authbasic >
< eliom module="%%LIBDIR%%/%%PROJECT_NAME%%.cma" / >
< / site >
< site path=“B” >
< static dir="%%STATICDIR%%" / >
< static dir="%%ELIOMSTATICDIR%%" / >
< eliom module="%%LIBDIR%%/B.cma" / >
< /site >
< /host >

Thank you.

http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
Virus-free.
www.avg.com
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

It is possible indeed to create several cma from several sets of .eliom files.
Of course you’ll have to modify the Makefile to do that.
Use ocamlc -a to create a cma from several cmo (located in directory _server) (see OCaml Manual).
Be careful to include them in the right order.

Vincent