--- parser3/src/classes/hashfile.C 2001/11/23 12:56:37 1.16 +++ parser3/src/classes/hashfile.C 2002/02/08 08:30:10 1.22 @@ -1,10 +1,10 @@ /** @file Parser: @b hashfile parser class. - Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://paf.design.ru) + Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexandr Petrosian (http://paf.design.ru) - $Id: hashfile.C,v 1.16 2001/11/23 12:56:37 paf Exp $ + $Id: hashfile.C,v 1.22 2002/02/08 08:30:10 paf Exp $ */ #include "pa_config_includes.h" @@ -38,7 +38,7 @@ static void _open(Request& r, const Stri VHashfile& self=*static_cast(r.self); self.assign( - params->as_string(0, "DB_HOME must be string"), + r.absolute(params->as_string(0, "DB_HOME must be string")), params->as_string(1, "filename must be string") ); } @@ -53,17 +53,8 @@ static void _transaction(Request& r, con // table DB_Table_ptr table_ptr=self.get_table_ptr(&method_name); - // transaction - DB_Transaction transaction(pool, *table_ptr, self.current_transaction); - // execute body - try { - r.write_assign_lang(r.process(body_code)); - } catch(...) { // process/commit problem - transaction.mark_to_rollback(); - - /*re*/throw; - } + r.write_assign_lang(r.process(body_code)); } static void _hash(Request& r, const String& method_name, MethodParams *params) { @@ -85,35 +76,27 @@ static void _cache(Request& r, const Str time_t lifespan=(time_t)params->as_double(1, "lifespan must be number", r); Value& body_code=params->as_junction(2, "body must be code"); - // transaction - DB_Transaction transaction(pool, *self.get_table_ptr(&method_name), self.current_transaction); + DB_Table_ptr table_ptr=self.get_table_ptr(&method_name); - // execute body - try { - if(lifespan) { // 'lifespan' specified? try cached copy... - if(String *cached_body=transaction.get(key, lifespan)) { // have cached copy? - r.write_assign_lang(*cached_body); - // happy with it - return; - } - } else // 'lifespan'=0, forget cached copy - transaction.remove(key); - - // save - Autosave_marked_to_cancel_cache saved(self); - - // process - Value& processed_body=r.process(body_code); - r.write_assign_lang(processed_body); - - // put it to cache if 'lifespan' specified & never called ^delete[] - if(lifespan && !self.marked_to_cancel_cache()) - transaction.put(key, processed_body.as_string(), lifespan); - } catch(...) { // process/commit problem - transaction.mark_to_rollback(); - - /*re*/throw; - } + if(lifespan) { // 'lifespan' specified? try cached copy... + if(String *cached_body=table_ptr->get(pool, key, lifespan)) { // have cached copy? + r.write_assign_lang(*cached_body); + // happy with it + return; + } + } else // 'lifespan'=0, forget cached copy + table_ptr->remove(key); + + // save + Autosave_marked_to_cancel_cache saved(self); + + // process + Value& processed_body=r.process(body_code); + r.write_assign_lang(processed_body); + + // put it to cache if 'lifespan' specified & never called ^delete[] + if(lifespan && !self.marked_to_cancel_cache()) + table_ptr->put(key, processed_body.as_string(), lifespan); } static void _delete(Request& r, const String& method_name, MethodParams *params) { @@ -126,16 +109,14 @@ static void _delete(Request& r, const St // key const String &key=params->as_string(0, "key must be string"); // remove - self.get_table_ptr(&method_name)->remove(self.current_transaction, key); + self.get_table_ptr(&method_name)->remove(key); } } static void _clear(Request& r, const String& method_name, MethodParams *) { Pool& pool=r.pool(); VHashfile& self=*static_cast(r.self); - DB_Cursor cursor( - *self.get_table_ptr(&method_name), - self.current_transaction, &method_name); + DB_Cursor cursor(*self.get_table_ptr(&method_name), &method_name); while(true) { if(!cursor.move(DB_NEXT)) @@ -159,9 +140,7 @@ static void _foreach(Request& r, const S VString& vkey=*new(pool) VString(pool); VString& vvalue=*new(pool) VString(pool); - DB_Cursor cursor( - *self.get_table_ptr(&method_name), - self.current_transaction, &method_name); + DB_Cursor cursor(*self.get_table_ptr(&method_name), &method_name); while(true) { String *key; String *data;