From: Eric Hodel Date: 2004-05-08T01:06:55-07:00 Subject: Re: What is Borges? --tuYRN1zEaS85jg/Y Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Kirk Haines (khaines@enigo.com) wrote: > On Sat, 8 May 2004 05:33:02 +0900, Julian Fitzell wrote >=20 > > Seaside=20 > > (and I believe Borges for Ruby implements this piece too) has a=20 > > concept of transactions or isolate blocks. The way this works is=20 > > that you execute a section of code inside a block. When that block=20 > > terminates, all the pages in that session get expired. So in the=20 > > case of a shopping cart, you would likely start an isolate block=20 > > when they begin the payment process and expire all those pages as=20 > > soon as they press "Purchase". >=20 > Now THAT is a cool idea. I need to think about how to steal that and=20 > implement it in Iowa to selectively expire pages from the page cache. Th= at=20 > would be a useful capability. Inside Borges' Session class, the guts of the request handler do this: 1) wait for a request 2) when we have a request, pass it to our current filters 3) when the filters are done with the request, do the 'normal' processing work. 4) go back to (1) Transaction is implemented like this: So long as the transaction is active, pages within. When the transaction is closed, all references to those pages are redirected outside of the transaction. class Borges::Transaction < Borges::Filter def initialize @active =3D true end def close @active =3D false end def handle_request_in(req, session) if @active then req else session.page_expired end end end You may have noticed that there is no storage of pages inside the transaction itself. Borges knows which filters where used with a particular request, and restores them appropriately. There also is a 'Once' filter, which only allows a page to be shown a single time: class Borges::Once < Borges::Filter def initialize @seen_keys =3D [] end def handle_request_in(req, session) if @seen_keys.include? req.action_key then session.page_expired else @seen_keys << req.action_key end end end Both types of filters have handy helper methods on Session to let you instantiate them easily. --=20 Eric Hodel - drbrain@segment7.net - http://segment7.net All messages signed with fingerprint: FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 --tuYRN1zEaS85jg/Y Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (FreeBSD) iD8DBQFAnJUfMypVHHlsnwQRAlCJAKDxqK651UuABTIWOdZQr4/m+ne0GACfdMI7 ViqjxqZOs8v8GDbfM/9GaOE= =SuBs -----END PGP SIGNATURE----- --tuYRN1zEaS85jg/Y--