[cgiapp] ValidateRM with complex dependencies

2004-01-19 Thread Stewart C. Russell
If I had parameters withdrawal_amount and margin_available, how would I 
define a Data::FormValidator clause to check that 
withdrawal_amount=margin_available?

It seems that all the examples assume that the parameters are simple, 
and the D::FV documentation on validating complex dependencies seems to 
point off to a part of D::FV::Results documentation that doesn't exist.

thanks,
 Stewart
-
Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
 http://marc.theaimsgroup.com/?l=cgiappr=1w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


[cgiapp] CGI::Application::Session - session plugin for CGI::Application

2004-01-19 Thread Cees Hek
Mark Stosberg wrote:
Since so many of us use DBI database handles and session management, I
would love to see some plug-in modules to add these kind new methods.
Perhaps something in the spirit of ::ValidateRM would work. (I think
that technique is called mix-in module.
Well, I found a couple of spare hours late last night and threw together 
a CGI::Application::Session module that provides CGI::Session support 
for CGI::Application.  It works in a similar way that 
CGI::Application::ValidateRM does (in fact I used much of the structure 
of that module as a base... thanks Mark).

The module is simple to use.  Just add 'use CGI::Application::Session;' 
to your base class or your runmode module, and you have access to a 
$self-session method/object.  Then all you need to do is set an 
outgoing cookie with the session ID (this could be done automatically 
once the header_props patches make it into the CGI::Application core). 
See the docs for more config options and examples.

I haven't put this on CPAN, because I would like some comments on the 
usefulness of this module, and more importantly, on the 
implementation...  Also, what about the name (should there be a 
CGI::Application::Plugin:: namespace for modules like this and 
CGI::Application::ValidateRM?)  What if someone wants to create a 
CGI::Application::Session module based on Apache::Session?

Anyway, here is the module:

http://cees.crtconsulting.ca/perl/modules/CGI-Application-Session-0.01.tgz

Cheers,

Cees

-
Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
 http://marc.theaimsgroup.com/?l=cgiappr=1w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


[cgiapp] Re: ValidateRM with complex dependencies

2004-01-19 Thread Mark Stosberg
On 2004-01-19, Stewart C. Russell [EMAIL PROTECTED] wrote:
 If I had parameters withdrawal_amount and margin_available, how would I 
 define a Data::FormValidator clause to check that 
 withdrawal_amount=margin_available?

 It seems that all the examples assume that the parameters are simple, 
 and the D::FV documentation on validating complex dependencies seems to 
 point off to a part of D::FV::Results documentation that doesn't exist.

First, since this question is specific to Data::FormValidator, it is
better discussed on the DFV list. I'm cc'ing it now.

The documentation you need is about validating constraints based on
multiple fields. It's here:

http://search.cpan.org/~markstos/Data-FormValidator-3.50/lib/Data/FormValidator.pm#VALIDATING_INPUT_BASED_ON_MULTIPLE_FIELDS

I think there is a problem with the documentation-- it should point to
::Constraints instead of ::Results.

The other example you want is here: 
http://search.cpan.org/~markstos/Data-FormValidator-3.50/lib/Data/FormValidator/Constraints.pm#WRITING_YOUR_OWN_CONSTRAINT_ROUTINES

Put it together and you get something like this:

withdrawal_amount = {
name   = 'withdrawal_less_than_margin',
params = [ 'withdrawal_amount', 'margin_available' ],
constraint = sub {
my ($w,$m) = @_;
return ($w  $m );
},
}

###

I didn't test that, but maybe it works. :) The name part is not
essential, but may make it easier to reference later from the msgs()
system.

Mark
 
--
 . . . . . . . . . . . . . . . . . . . . . . . . . . . 
   Mark StosbergPrincipal Developer  
   [EMAIL PROTECTED] Summersault, LLC 
   765-939-9301 ext 202 database driven websites
 . . . . . http://www.summersault.com/ . . . . . . . .


-
Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
  http://marc.theaimsgroup.com/?l=cgiappr=1w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[cgiapp] Re: CGI::Application::Session - session plugin for CGI::Application

2004-01-19 Thread Mark Stosberg
On 2004-01-19, Cees Hek [EMAIL PROTECTED] wrote:

 I haven't put this on CPAN, because I would like some comments on the 
 usefulness of this module, and more importantly, on the 
 implementation... 

Thanks for putting this together Cees.

I've now reviewed the POD and code for this. I find it very useful. 
Sure, it's very simple. That means I can focus on CGI::App and
CGI::Session and this little glue module will just work and be easy to
use. So I give the usefulness two thumbs up. 

I have one suggestion for the interface: I would rename session_config
to be session_new. This is more consistent with the CGI::Session,
which also calls it new. Assumming people will need to be a familiar
with CGI::Session, I think having the same name will be helpful.

 Also, what about the name (should there be a 
 CGI::Application::Plugin:: namespace for modules like this and 
 CGI::Application::ValidateRM?)  

I think of a plug-in as something that some kind of special plug-in
interface. Your module and ::ValidateRM don't work through a special
interface, they just work. I would save the ::Plugin namespace for 
something like a plug-in system that someone else here developed-- it  
auto-loads modules it finds in a directory, I believe.

 What if someone wants to create a 
 CGI::Application::Session module based on Apache::Session?

Good question. Should the names be:

CGI::Application::Session::CGISession
CGI::Application::Session::ApacheSession

or

CGI::Application::Session::CGI
CGI::Application::Session::Apache

In either case, it seems redundant to include CGI in the name 
twice. For that reason, your original name of ::Session has some
appeal to me...even if it's less clean how future session handling
extensions might be named.

I think I would start using this when it's own CPAN. I'm passing the
session object around through the 'param' system, and this seems
cleaner.

Mark

-- 
 . . . . . . . . . . . . . . . . . . . . . . . . . . . 
   Mark StosbergPrincipal Developer  
   [EMAIL PROTECTED] Summersault, LLC 
   765-939-9301 ext 202 database driven websites
 . . . . . http://www.summersault.com/ . . . . . . . .


-
Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
  http://marc.theaimsgroup.com/?l=cgiappr=1w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]