RE: [cgiapp] HTML::Template Question and where is list archive?
I am just starting out using CGI::Application and would like to see an example of how to call HTML::Template and pass it param's? I was also looking for a cgiapp list archive that I could search to see if anyone else may have posted this and gotten a response. Is there a web based archive? The following code gives me HTML::Template=HASH(0x822f464) When I access www.securitysaint.com/cgi-bin/saint.cgi sub show_main { my $self = shift; # Get CGI query object my $q = $self-query(); my $tmpl_obj = $self-load_tmpl('main.tmpl'); my $output = ''; $tmpl_obj-param(HOME = $ENV{HOME}); $tmpl_obj-param(PATH = $ENV{PATH}); $output .= $tmpl_obj; return $output; } Any pointer in the right direction would be helpful. Thanks zack It should be $output .= $tmpl_obj-output; Roy Irubin Consulting http://www.irubin.com - Web Archive: http://www.mail-archive.com/cgiapp@lists.vm.com/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[cgiapp] CGI::App and CGI::Session
What is the best way to combine CGI::Session and CGI::Application It was recommended that I use the cgiapp_init, which I am attempting to do. But do I set the $self-header_props inside the cgiapp_init sub then do nothing else. Or should I follow the CGI::Session docs and initialize a new instance of CGI.pm and print the header directly from the cgiapp_init sub? Doing it as listed below does set the cookie and creates a session , but the header is sent and mixed with the output from the rest of the module. Thus giving me: Content-Type: text/html; charset=ISO-8859-1 html headtitleTest Template/title body My Home Directory is p My Path is set to /usr/local/sbin:/usr/sbin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin :/usr/local/sbin:/usr/bin/X11:/usr/X11R6/bin:/root/bin /body /html sub cgiapp_init { my $self = shift; # Optional Pre-Setup Initalization code use CGI; my $cgi = new CGI; my $c_sid = $cgi-cookie(COOKIE) || undef; my $session = new CGI::Session::File($c_sid, { LockDirectory = '/tmp/locks', Directory = '/tmp/sessions' }); my $new_cookie = $cgi-cookie(-name=COOKIE, -value=$session-id); print $cgi-header(-cookie=$new_cookie); } Any examples would be appreciated, and any links to online examples would also be helpful. Searching deja for these two modules did not return any posts I could learn from. Thanks zack - Web Archive: http://www.mail-archive.com/cgiapp@lists.vm.com/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [cgiapp] CGI::App and CGI::Session
Hi But do I set the $self-header_props inside the cgiapp_init sub then do nothing else. Or should I follow the CGI::Session docs and initialize a new instance of CGI.pm and print the header directly from the cgiapp_init sub? If you are using CGI::Application, then you don't have to create new instance of CGI.pm, because CGI::Application's query() method retruns it for you. I don't quite use CGI::Application, but as Jesse once explained, you don't need to use header(), but use header_props() instead. CGI::Session's documentation makes use of CGI.pm for making working with cookies and queries easier. So you don't have to use CGI.pm if you don't want to, it still does it's job without it (except load_param() and save_param() methods) For complete documentation of CGI::Session refer to http://modules.ultracgis.com/CGI/Session.html, http://modules.ultracgis.com/CGI/Session/File.html. Other drivers include, http://modules.ultracgis.com/CGI/Session/DB_File.html and http://modules.ultracgis.com/CGI/Session/MySQL.html. Note: If your CGI::Session is older then 2.1, please upgrade is ASAP. -- Sherzod - Web Archive: http://www.mail-archive.com/cgiapp@lists.vm.com/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [cgiapp] CGI::App and CGI::Session
Sorry to be a little slow about this, the code below does appear to working now. But I am concerned that it might not be the correct way of doing it. I seem to have a little disfunctional code at the end; last two lines. Is that right? sub cgiapp_init { my $self = shift; my $q = $self-query(); my $c_sid = $q-cookie(COOKIE) || $q-param(c_sid) || undef; my $session = new CGI::Session::File($c_sid, { LockDirectory = '/tmp/locks', Directory = '/tmp/sessions' }); my $new_cookie = $self-header_props(-name=COOKIE, -value=$session-id); $self-header_props(-cookie=$new_cookie); } - Web Archive: http://www.mail-archive.com/cgiapp@lists.vm.com/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [cgiapp] CGI::App and CGI::Session
Thanks for your feedback, I am using the cookie constant as follows package Saint::WebApp; use base 'CGI::Application'; use strict; use CGI::Session::File; use constant COOKIE = saint; But I should propably be using .securitysaint.com - Original Message - From: Sherzod B. Ruzmetov [EMAIL PROTECTED] To: Zachary Buckholz [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, May 16, 2002 3:10 PM Subject: Re: [cgiapp] CGI::App and CGI::Session my $new_cookie = $self-header_props(-name=COOKIE, -value=$session-id); $self-header_props(-cookie=$new_cookie); } $new_cookie is not returned from the header(), it is returned from the CGI.pm's cookie() method. First you create PROPER HTTP cookie, then pass it to header_props(): $new_cookie = $q-cookie(-name=COOKIE, -value=$session-id); $self-header_props(-cookie=$new_cookie); But let's ask Jesse for more insights on this, since I'm not quite familiar with CGI::Application. Another thing, you are using COOKIE constant from the CGI::Session manual, and I assume you have a line something like: use constant COOKIE = 'MY_SITE_SID'; at the top of your program, do you? If you were using 'strict' pragma it would let you know. ttyl Sherzod - Web Archive: http://www.mail-archive.com/cgiapp@lists.vm.com/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Web Archive: http://www.mail-archive.com/cgiapp@lists.vm.com/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [cgiapp] CGI::App and CGI::Session
use constant COOKIE = saint; But I should propably be using .securitysaint.com No, COOKIE constant was just a name of the cookie to be sent. It has nothing to do with the domain name. Alternative for using constant is to give the name for the cookie on the fly: $new_cookie = $q-cookie(-name=SESSION_ID, -value=$session-id()); So the name of the cookie can be anything. For other options availabel for CGI::cookie() method refere to CGI.pm online documentation. I guess I should include some demo scripts to the CGI-Session distribution. ttyl Sherzod - Web Archive: http://www.mail-archive.com/cgiapp@lists.vm.com/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]