Forum OpenACS Q&A: Re: files not found in package

Collapse
Posted by Dave Bauer on
Is the classrequestvalidator.tcl is in the same directory as index.tcl?

Using watch all files or reload changed only works on tcl libraries in the package /tcl directory. You would not need to source those files since they are sourced on startup and the procedures within they are available.

If your file is not in the tcl directory for the package, I would recommend putting reusable code there, and putting the code into tcl procedures for easier reuse.

Collapse
Posted by Matthew Smith on
Yes, the file is in the same directory as index.tcl. I guess I can move the code into the tcl directory, but I would really like to know why this isn't working.

thank you.

Collapse
Posted by Matthew Smith on
The problem I have run into is that there are actually four files being sourced. Two are for procs, which I guess will work fine, but the other two are classes.

I am now getting this error:
invalid command name "backendrequestclass"

So I guess the class declaration won't work from the tcl directory. I would rather get the source command to work.

Collapse
Posted by Derick Leony on
When you refer to files located in the file system, the paths are relative to the AOLserver homedir parameter. Using absolute paths is usually the best.

As Dave mentioned, having your procs in the tcl directory is the way to go.

Collapse
Posted by Matthew Smith on
But what about class declarations? Is my only option to have all the code declaring the class in the file that uses it? That would seem to hamper reusability...

Could you give an example of what the absolute path might look like?

Collapse
Posted by Derick Leony on
First, a correction: the parameter is "home", AOLserver's home directory.

I'm not sure where would be the best place to store your class declarations but I guess a -proc file in the tcl directory would work well. Check the files in xowiki/tcl, for example the Page class definition in xowoki-procs.tcl.

About absolute paths, something like /home/user/myfile.ext, check the api-doc to find some procs to get the server and package important directories, but you might not need this anyways :)

Collapse
Posted by Stefan Sobernig on
Matthew,


Is my only option to have all the code declaring the class in the file that uses it?

Definitely not, XOTcl object declarations (as Tcl procs) go into tcl/*-procs.tcl files and are provided to all request-serving threads ("connection threads") through the AOLserver blueprinting mechanism. As for the development cycle, stage your code in www/* scripts, once consolidated, move them to *-procs.tcl to have them served for a wider scope.

Btw., may I give you an advise. Try to manage your code in a publicly browsable location, so when posting questions, you may refer to your package structure/ code. this opens many opportunities to help out more effectively.

Collapse
Posted by Matthew Smith on
I have moved the files into the tcl directory and renamred them to end with -proc.tcl. However I am still getting an error:invalid command name "backendrequestclass".
Collapse
Posted by Matthew Smith on
Where in the api doc should I be looking? I looked around but didn't see anything?

Thanks.

Collapse
Posted by Stefan Sobernig on
Matthew


-proc.tcl

Either this is a typo in your posting or you simply got it wrong: it is supposed to be *-proc>s<.tcl, don't forget about the "s".

Again, if you could make your package structure/ code available for browsing, it would be tremendously easier and would save time (at both ends ;)

//s

Collapse
Posted by Matthew Smith on
Sorry, I'm behind a firewall that makes what you suggest impossible.

I did have it wrong, I forgot the s.

Thanks for the help.