Quoting Koen Deforche <[EMAIL PROTECTED]>:

> Hey Pau,
>
>> While testing the Ubuntu/Debian packages, I've noticed in the examples
>> files (for instance, localization XMLs) are opened assuming they are
>> in the same folder the application binary is when it is started.
>
> True. And many of them make the additional assumption that you have
> 'ln -s'ed the Wt's resources folder into the example's source
> directory too.

I "fixed" that in the Debian/Ubuntu packages by removing the symlink  
and copying the 'resources' folder to the location where the examples  
expect to find it.

By the way, the 'witty' package was uploaded to Debian today (it's  
currently sitting in ftp-master, will be transitioned to the archive  
when the ftp-masters review it). I expect Wt to flow to Debian  
derivatives such as Ubuntu soon.

>> cmake -DWT_SOURCE_DIR=/usr/share/doc/witty-doc/
>> -DEXAMPLES_CONNECTOR="wt;wthttp" /usr/share/doc/witty-doc/examples
>
> Just curious, what does "wt;wthttp" do (versus "wthttp") ?

It links to libwt and libwthttp instead of just to libwthttp. Weird  
syntax but it works :-)

>> Then you run make in /home/user/dev/wtexamples
>>
>> Now, if you want to run the charts example, you can either:
>>
>> - Run /home/user/dev/wtexamples/charts/charts.wt --docroot
>> /usr/share/doc/witty-doc/examples/charts --http-port 10000 --http-addr
>> 0.0.0.0
>>
>> - Or go into the /home/user/dev/wtexamples/charts directory, then run
>> ./charts.wt --docroot /usr/share/doc/witty-doc/examples/charts
>> --http-port 10000 --http-addr 0.0.0.0
>>
>> Either way, your XML files, CSS files, etc are not found because they
>> are not opened taking the directory you specified with --docroot as
>> the "." directory for open, std::istream, etc. The "." directory is
>> the directory from where you run the binary (not even the directory
>> the binary is in).
>
> Would the following not work ?
>
> $ cd usr/share/doc/witty-doc/examples/charts;
> $ /home/user/dev/wtexamples/charts/charts.wt --docroot . --http-port
> 10000 --http-addr 0.0.0.0

Yes, that's exactly what I'm recommending in the  
/usr/share/doc/witty-doc/README.Debian:

* To build the examples, call CMake this way:

   cmake -DWT_SOURCE_DIR=/usr/share/doc/witty-doc/  
-DEXAMPLES_CONNECTOR="wt;wthttp" /usr/share/doc/witty-doc/examples

* Then go to /usr/share/doc/witty-doc/examples and enter the directory of the
   example you want to run. When running the example, set the docroot to "."
   For instance, if you compiled the examples in  
/home/user/dev/wtexamples, you would do:

   $ mkdir /home/user/dev/wtexamples
   $ cd /home/user/dev/wtexamples
   $ cmake -DWT_SOURCE_DIR=/usr/share/doc/witty-doc/  
-DEXAMPLES_CONNECTOR="wt;wthttp" /usr/share/doc/witty-doc/examples
   $ make
   $ cd /usr/share/doc/witty-doc/examples/charts
   $ /home/user/dev/wtexamples/charts/charts.wt --http-port 10000  
--http-addr 0.0.0.0 --docroot .


>> Am I wrong? Shouldn't "--docroot" be enforced? Or maybe something like
>> BinReloc ( http://autopackage.org/docs/binreloc/ ) to use the
>> directory where the binary is as the root? (I like docroot enforced
>> better, FWIW)
>
> I think docroot is enforced? At least, an empty value is not allowed.
>
> I have a /etc/wt/wthttpd that reads like this:
> docroot = .
> http-address = 0.0.0.0
> http-port = 8080
>
> And in this way I can run all the examples without any arguments from
> within their source directory. What exactly do you mean with
> enforcing?

Sorry, I didn't explain exactly well :-)

Look for instance at the 'composer' example, in ComposeExample.C:

   WApplication *app = new WApplication(env);
   app->messageResourceBundle().use("composer");
   app->useStyleSheet("composer.css");

As no path is specified, WApplication::useStyleSheet looks for  
'composer.css' in the directory you are when you start the  
application, not in docroot, not where the binary is. Same thing for  
WMessageResourceBundle::use. That's the problem I found: I was  
expecting Wt to look for composer.xml and composer.css in docroot.

Same thing happens for the CSV file for the 'charts' example and others.

While it would be easy to make WApplication::useStyleSheet and  
WMessageResourceBundle::use look for the CSS file and the XML file in  
docroot, it wouldn't be so easy for the CSV file in the 'charts'  
example, as the CSV file is used as std::istream << file.csv (you'd  
need to intercept all file calls, too messy, complex and error-prone)

Maybe the right way to do that would be to have a  
WApplication::docroot returning a string with the docroot, then  
loading the XML, CSS, CSV files, etc like this:

   WApplication *app = new WApplication(env);
   app->messageResourceBundle().use(app->docroot() + "composer");
   app->useStyleSheet(app->docroot() + "composer.css");

Then, in the 'charts' example, you'd do:
   std::istream << ( app->docroot() + "file.csv" )

-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to