From: Adam Dickmeiss Date: Thu, 28 Jun 2007 09:36:10 +0000 (+0000) Subject: Added parameter clear=1 for init command which makes the session not use X-Git-Tag: PAZPAR2.1.0.1~13 X-Git-Url: http://jsfdemo.indexdata.com/?a=commitdiff_plain;h=52793fbdcc6099f1c86e0b4c2c918767c22f7bcc;p=pazpar2-moved-to-github.git Added parameter clear=1 for init command which makes the session not use predefined databases from configuration. --- diff --git a/doc/pazpar2_protocol.xml b/doc/pazpar2_protocol.xml index 23ddc28..7befc40 100644 --- a/doc/pazpar2_protocol.xml +++ b/doc/pazpar2_protocol.xml @@ -8,7 +8,7 @@ %idcommon; ]> - + Pazpar2 @@ -61,7 +61,19 @@ The init command may take a number of setting parameters, similar to the 'settings' command described below. These settings are immediately - applied to the new session. + applied to the new session. Other parameters for init are: + + + clear + + + If this is defined and the value is non-zero, the session will + not use the predefined databases in the configuration; only those + specified in the settings parameters (per session databases). + + + + diff --git a/src/database.c b/src/database.c index dbcbf12..9228162 100644 --- a/src/database.c +++ b/src/database.c @@ -1,4 +1,4 @@ -/* $Id: database.c,v 1.28 2007-05-25 03:58:04 quinn Exp $ +/* $Id: database.c,v 1.29 2007-06-28 09:36:10 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -259,8 +259,8 @@ int session_grep_databases(struct session *se, struct database_criterion *cl, return i; } -int grep_databases(void *context, struct database_criterion *cl, - void (*fun)(void *context, struct database *db)) +int predef_grep_databases(void *context, struct database_criterion *cl, + void (*fun)(void *context, struct database *db)) { struct database *p; int i = 0; diff --git a/src/database.h b/src/database.h index 3efe9e7..8d8505a 100644 --- a/src/database.h +++ b/src/database.h @@ -1,4 +1,4 @@ -/* $Id: database.h,v 1.7 2007-04-22 15:00:56 adam Exp $ +/* $Id: database.h,v 1.8 2007-06-28 09:36:10 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -27,8 +27,8 @@ struct database *find_database(const char *id, int new); int database_match_criteria(struct session_database *db, struct database_criterion *cl); int session_grep_databases(struct session *se, struct database_criterion *cl, void (*fun)(void *context, struct session_database *db)); -int grep_databases(void *context, struct database_criterion *cl, - void (*fun)(void *context, struct database *db)); +int predef_grep_databases(void *context, struct database_criterion *cl, + void (*fun)(void *context, struct database *db)); int match_zurl(const char *zurl, const char *pattern); #endif diff --git a/src/http_command.c b/src/http_command.c index 9c56046..31e416a 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1,4 +1,4 @@ -/* $Id: http_command.c,v 1.54 2007-06-15 19:35:17 adam Exp $ +/* $Id: http_command.c,v 1.55 2007-06-28 09:36:10 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -20,7 +20,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA */ /* - * $Id: http_command.c,v 1.54 2007-06-15 19:35:17 adam Exp $ + * $Id: http_command.c,v 1.55 2007-06-28 09:36:10 adam Exp $ */ #include @@ -243,10 +243,15 @@ static void cmd_init(struct http_channel *c) { unsigned int sesid; char buf[1024]; + const char *clear = http_argbyname(c->request, "clear"); struct http_session *s = http_session_create(); struct http_response *rs = c->response; yaz_log(YLOG_DEBUG, "HTTP Session init"); + if (!clear || *clear == '0') + session_init_databases(s->psession); + else + yaz_log(YLOG_LOG, "No databases preloaded"); sesid = make_sessionid(); s->session_id = sesid; if (process_settings(s->psession, c->request, c->response) < 0) diff --git a/src/logic.c b/src/logic.c index d14da21..e131fb3 100644 --- a/src/logic.c +++ b/src/logic.c @@ -1,4 +1,4 @@ -/* $Id: logic.c,v 1.46 2007-06-19 10:16:15 adam Exp $ +/* $Id: logic.c,v 1.47 2007-06-28 09:36:10 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -594,7 +594,7 @@ static void session_database_destroy(struct session_database *sdb) void session_init_databases(struct session *se) { se->databases = 0; - grep_databases(se, 0, session_init_databases_fun); + predef_grep_databases(se, 0, session_init_databases_fun); } // Probably session_init_databases_fun should be refactored instead of @@ -701,7 +701,7 @@ struct session *new_session(NMEM nmem) session->session_nmem = nmem; session->nmem = nmem_create(); session->wrbuf = wrbuf_alloc(); - session_init_databases(session); + session->databases = 0; for (i = 0; i <= SESSION_WATCH_MAX; i++) { session->watchlist[i].data = 0; diff --git a/src/pazpar2.h b/src/pazpar2.h index 38f566b..96f2291 100644 --- a/src/pazpar2.h +++ b/src/pazpar2.h @@ -1,4 +1,4 @@ -/* $Id: pazpar2.h,v 1.43 2007-06-18 11:10:20 adam Exp $ +/* $Id: pazpar2.h,v 1.44 2007-06-28 09:36:10 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -170,6 +170,7 @@ struct hitsbytarget *hitsbytarget(struct session *s, int *count); int select_targets(struct session *se, struct database_criterion *crit); struct session *new_session(NMEM nmem); void destroy_session(struct session *s); +void session_init_databases(struct session *s); int load_targets(struct session *s, const char *fn); void statistics(struct session *s, struct statistics *stat); enum pazpar2_error_code search(struct session *s, char *query, diff --git a/src/settings.c b/src/settings.c index 8cc5e6c..61613ea 100644 --- a/src/settings.c +++ b/src/settings.c @@ -1,4 +1,4 @@ -/* $Id: settings.c,v 1.23 2007-06-06 11:49:48 marc Exp $ +/* $Id: settings.c,v 1.24 2007-06-28 09:36:10 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -352,7 +352,7 @@ static void update_database(void *context, struct database *db) // This is used in pass 2 to assign name/value pairs to databases static void update_databases(struct setting *set) { - grep_databases(set, 0, update_database); + predef_grep_databases(set, 0, update_database); } // This simply copies the 'hard' (application-specific) settings