From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 340DEBB91 for ; Sat, 11 Dec 2004 00:36:00 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iBANZxZB027813 for ; Sat, 11 Dec 2004 00:35:59 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA29244 for ; Sat, 11 Dec 2004 00:35:59 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iBANZsWO027806 for ; Sat, 11 Dec 2004 00:35:57 +0100 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id iBANZmDv017771; Sat, 11 Dec 2004 08:35:48 +0900 (JST) Date: Sat, 11 Dec 2004 08:35:33 +0900 (JST) Message-Id: <20041211.083533.126126293.garrigue@math.nagoya-u.ac.jp> To: rich@annexia.org Cc: caml-list@inria.fr, JEFHEN@safeco.com Subject: Re: [Caml-list] environment idiom From: Jacques Garrigue In-Reply-To: <20041210121306.GB29002@annexia.org> References: <9410EC84C0872141B27A2726613EF45D02A52E08@psmrdcex01.psm.pin.safeco.com> <41B97FD7.50309@andrej.com> <20041210121306.GB29002@annexia.org> X-Mailer: Mew version 4.0.64 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 41BA32DF.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 41BA32DA.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 rec:01 derives:01 caching:01 idiom:01 inefficient:01 dynamically:01 jacques:01 jacques:01 data:02 slightly:02 parameter:02 garrigue:03 garrigue:03 generally:03 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: From: Richard Jones > The specific data that Jeff wants to pass around are: > > cgi - The CGI environment > r - The Apache request_rec (in fact, cgi#request == request, > but sometimes it's slightly more convenient to have it as > a separate parameter) > dbh - The database handle > hostid - The host ID (COCANWIKI supports multiple virtual hosts) > host - The "host object" which contains other host-related info > user - The "user object" which contains info on the logged-in user > > In theory one can derive all of the above from just cgi and dbh, but > it's very inefficient to do this because it would require making > database requests. For practical and efficiency reasons COCANWIKI > derives the hostid, host and user with just 2 database queries at the > beginning of every HTTP request. But you could also make an object with all the methods, and caching the information it retrieves from the database. This way you have no efficiency problem. Andrej's point was that it is generally enough to collect all common information in one object, and you have not so much to move around after that. I think this is reasonable. If this is not the case, then it may mean that you really need to add information dynamically to your environment. In that case an approach like the one I suggested with records might provide more flexibility. Jacques Garrigue