Forum OpenACS Q&A: broken index.vuh still being served after file has been deleted...?

I put some code in an index.vuh to rewrite URL of the form:

file?file_id=1234
...into a more search engine friendly url such as /file/path/1234, and it was working great.

The code contained some DB queries so I put it into a proc named jt_display_file so that I could use util_memoize to cache it. About the same time, I mounted and activated Developer Support.

Apparently, jt_display_file was broken because the pages started returning this error:

    Error: can't read "file_id": no such variable
can't read "file_id": no such variable
    while executing
"set path "[ns_info pageroot]/file/path/file?file_id=$file_id""
    (procedure "jt_display_file" line 20)
    invoked from within
"jt_display_file"
    Notice: Querying '
            select 1
            where 't' = acs_permission__permission_p('659', '298', 'read');'

Then I noticed that all requests to the /file/path/ directory return the above error.

To try and debug it, I removed the index.vuh, and restarted the server; however, the error persists and I can't access any file under the path.

I don't understand how the error could persist since the index.vuh file is gone, it is the only file that contained the proc jt_display_file, and I have restarted the Web server many times.

Does OpenACS ever store code from index.vuh files in the DB?

Nevermind...someone else didn't know about index.vuh files and put an ns_register_proc of the same name in the global tcl directory -- it started interfering after I restarted the server.
Collapse
3: what is a .vuh file (response to 1)
Posted by Keith Paskett on
What is the purpose of a .vuh file and where are they documented? Are they an OpenACS thing or an AOLserver creation?

I've seen references to them but have never found documentation. (I'll have to admit I've not looked very hard.)

Collapse
4: Re: what is a .vuh file (response to 3)
Posted by Roberto Mello on
A .vuh is a Virtual URL Handler file, and it's OpenACS specific. The request processor looks for a .vuh in a page's directory when it can't find a certain page (AFAICR).

in a .VUH you can do processing, URL rewriting (for pretty URLs), redirection, etc. See the rp_internal_redirect and the rp_form_put (IIRC) procs in the api-browser.

I don't remember if .vuh's are handled in ACS Classic Keith. Also, you might want to take a look at Til's Redirect package.

-Roberto

Collapse
5: Re: what is a .vuh file (response to 4)
Posted by Randy O'Meara on
Keith,

Here are a couple of threads that discuss the use of index.vuh. They may be helpful in understanding and actually using this facility.

https://openacs.org/forums/message-view?message_id=121704
https://openacs.org/forums/message-view?message_id=115061

Keep in mind that the request processor (RP) serves up an index.vuh as a last-ditch effort. So, you can't have an "index" file in any of the standard places that the RP looks while resolving a request to a concrete file. For example, if you wanted to use an index.vuh file on the root of your service (/www) then you must be certain that you've moved packages/acs-subsite/www/index.* and /www/index.* out of the way first.

BTW, this is really a slick way to do anything that can be scripted in place of the standard tcl/adp or .html service. You can even do all of your scripted processing and then internally redirect (the user's browser does not receive a redirect response) *after* stuffing whatever values you want into the query var structure. These modified, or additional, query vars are available to the page that is the target of the internal redirect.

Another use would be to do some common processing on *every* page request within a package (or even the entire site, or a subsite).

Check out the edit-this-page package. It uses and index.vuh.

I believe openacs.org also makes use of an index.vuh to publish content on its front page. The openacs.org site is available in CVS.

Randy