Forum OpenACS Q&A: The filter does not work

Collapse
Posted by Xian Huang on
Hi!
I met problem when I tried to create my own filters. I add my own
filter in the /tcl/ad-security.tcl file, using the same style the
other filters use.

ad_register_filter trace GET /world.* ad_add_cookie

proc_doc ad_add_cookie{conn args why} {

set db [ns_db gethandle]
if ![catch {ns_db dml "insert into user_tracking values
(22 ,'wuwuu..')"} errmsg ] {}

ns_db releasehandle $db
return filter_ok

}

There is no error msg in log when I start aolserver by ./bin/nsd -kt
nsd.tcl. And have: [02/Oct/2001:17:07:31][20271.1024][-main-] Notice:
Registering trace filter ad_add_cookie for GET /world.html with
priority 10000

But when I access that page, seems the filter function does not work,
for I cannot see any change in the db.

what's the possible problem? How can I check whether it works?

Thanks

--Xian

Collapse
Posted by David Walker on
add an
ns_log notice "running filter"
as the first line in your procedure and check in the server log for that text. That will at least tell you if the filter is trying to run.
Collapse
Posted by Patrick Giagnocavo on
My guess is that a higher-priority filter is running and is catching the request before your filter gets it.  The docs on ad_register_filter mention a priority level, try bumping up the priority on your filter.  Alternatively, since the request processor be default does things with .tcl, .adp, and .html, try naming your file with a different extension, and modify the filter to catch that.  For instance, register a filter for *.xhdp and name your file world.xhdp .