RE: [cgiapp] Calling external modules?

2003-10-30 Thread Brian Cassidy
Hi Clint,

Correct me if I'm wrong, but I believe $self is already passed to the
sub.

package MyApp;

use base 'CGI::Application';
use strict;
use warnings;

sub setup {
my $self = shift;
$self-run_modes( mode1 = 'Module1::mode1' );
}

package Module1;

sub mode1 {
ref $_[0];
}

1;

prints:
C:\cgiappperl i.pl rm=mode1
Content-Type: text/html; charset=ISO-8859-1

MyApp

HTH,

-Brian

 -Original Message-
 From: Clint Moore [mailto:[EMAIL PROTECTED]
 Sent: Thursday, October 30, 2003 10:59 AM
 To: [EMAIL PROTECTED]
 Subject: [cgiapp] Calling external modules?
 
 
   I swear that it is probably something that I am doing but I
can't
 for
 the life of me figure out where I'm going wrong.  I have some
run_modes
 defined in a separate file and referenced like this:
 
 sub setup {
   my $self = shift;
   $self-run_modes(
   'mode1' = 'Module::method(\$self)',
   'mode2' = 'Module::method2(\$self)',
   );
 }
 
   In 5.6.0 this worked no problem.  Now that I have upgraded to
5.8.x,
 I
 cannot get this to work for anything.
 
   Now the modules 'use' just fine.  But I get ye olde cannot
locate
 object method method(\$self) in package Module error when I
 actually try to use that run mode in the program.  I'm, of course,
 'use'ing the Module in the CGI::App subclass package.
 
   The curious thing is that, in setup... i've not tried it
elsewhere,
 I
 can call new and run the methods off of the module no problem.   I
 cannot find any reference to possible changes in how 'use' is handled
 in 5.8.x that might be relevant to this but maybe I'm looking in the
 wrong places or something.
 
   Can someone tell me what I'm doing wrong?  I can post more
complete
 code if required.
 
 -cm
 
 
 -
 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]


http://www.gordano.com - Messaging for educators.

-
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]



Re: [cgiapp] Calling external modules?

2003-10-30 Thread Darin McBride
On October 30, 2003 07:58 am, Clint Moore wrote:
 I swear that it is probably something that I am doing but I can't for
 the life of me figure out where I'm going wrong.  I have some run_modes
 defined in a separate file and referenced like this:

 sub setup {
   my $self = shift;
   $self-run_modes(
   'mode1' = 'Module::method(\$self)',
   'mode2' = 'Module::method2(\$self)',
   );
 }

   In 5.6.0 this worked no problem.  Now that I have upgraded to 5.8.x, I
 cannot get this to work for anything.

You probably also upgrade C::A at the same time.  You probably were
getting this to work due to some accident of design where the older
versions of C::A used eval STRING to run the runmodes.  Current
versions use eval EXPR because it's way faster.

This could be looked at as a regression in functionality, except that
what you're doing was never intended to work from what I can tell in
the docs..  So I'd like to think of this as a tightening of
functionality rather than a regression ;-

You'll probably want to do something like these:

$self-run_modes(
  'mode1' = sub { Module::method1(@_); },
  'mode2' = sub { Module::method2(@_); },
);

or

$self-run_modes(
  'mode1' = \Module::method1,
  'mode2' = \Module::method2,
);

Both of these are untested, but should give you enough of an idea to go
on with.  The point is that you're supposed to pass in either the name
of a function inside your C::A-derived object, or a code ref.  The
above two examples both use the code-ref idea - the first uses anon
code refs, the second uses named code refs.

I'm sure there's a way to get this to work with strings, too, but I've
not tried.  For example, this might work, too:

$self-run_modes(
  'mode1' = 'Module::method1',
  'mode2' = 'Module::method2',
);

I prefer the code refs myself ;-)


-
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]



Re: [cgiapp] Calling external modules?

2003-10-30 Thread Jeff MacDonald
Here's what i do..


run_modes (
  'mode1' = 'module::method';
);

been doing that for ages, works like a charm.

Jeff.


On Thu, 2003-10-30 at 11:20, Darin McBride wrote:
 On October 30, 2003 07:58 am, Clint Moore wrote:
  I swear that it is probably something that I am doing but I can't for
  the life of me figure out where I'm going wrong.  I have some run_modes
  defined in a separate file and referenced like this:
 
  sub setup {
my $self = shift;
$self-run_modes(
'mode1' = 'Module::method(\$self)',
'mode2' = 'Module::method2(\$self)',
);
  }
 
In 5.6.0 this worked no problem.  Now that I have upgraded to 5.8.x, I
  cannot get this to work for anything.
 
 You probably also upgrade C::A at the same time.  You probably were
 getting this to work due to some accident of design where the older
 versions of C::A used eval STRING to run the runmodes.  Current
 versions use eval EXPR because it's way faster.
 
 This could be looked at as a regression in functionality, except that
 what you're doing was never intended to work from what I can tell in
 the docs..  So I'd like to think of this as a tightening of
 functionality rather than a regression ;-
 
 You'll probably want to do something like these:
 
 $self-run_modes(
   'mode1' = sub { Module::method1(@_); },
   'mode2' = sub { Module::method2(@_); },
 );
 
 or
 
 $self-run_modes(
   'mode1' = \Module::method1,
   'mode2' = \Module::method2,
 );
 
 Both of these are untested, but should give you enough of an idea to go
 on with.  The point is that you're supposed to pass in either the name
 of a function inside your C::A-derived object, or a code ref.  The
 above two examples both use the code-ref idea - the first uses anon
 code refs, the second uses named code refs.
 
 I'm sure there's a way to get this to work with strings, too, but I've
 not tried.  For example, this might work, too:
 
 $self-run_modes(
   'mode1' = 'Module::method1',
   'mode2' = 'Module::method2',
 );
 
 I prefer the code refs myself ;-)
 
 
 -
 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]
 


-
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]



Re: [cgiapp] Calling external modules?

2003-10-30 Thread Clint Moore
On Oct 30, 2003, at 7:12 AM, Brian Cassidy wrote:
Correct answer!
On Oct 30, 2003, at 7:19 AM, Darin McBride wrote:
Correct answer spelled out a little more.


On Oct 30, 2003, at 7:25 AM, Jeff MacDonald wrote:
This list rocks.  I'm up to my ass in right answers =)


Yes.  That was it.  What probably happened is that back when I started 
working with CGI::App I found a way that worked and stuck to it without 
giving it much further thought.  That'll learn me!

Thanks guys =)

-cm
 

-
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] Problem with cgiapp_postrun method

2003-10-30 Thread nicolovi
Hi everyone,

I'm currently trying to use the cgiapp_postrun method to modify the body the run mode 
method creates.

Now, my problem is that I'm unable to make this function works. Here is the code I use 
within the cgiapp_postrun method:

sub cgiapp_postrun {
  my $self = shift;
  my $output_ref = shift;

  my $new_output = h3;#.$$output_ref./h3;
  $output_ref = \$new_output;
}

The result I have in my web browser is always the text pointed by the $output_ref 
reference, but no way to see the $new_output result.

Any idea? What am I doing wrong?

Thanks in advance for the help,

Xavier Nicolovici


-
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]



Re: [cgiapp] Problem with cgiapp_postrun method

2003-10-30 Thread Steve Comrie
Xavier,

Have you tried

sub cgiapp_postrun
{
my $self= shift;
my $html= shift;

return 'h3' . $$html . '/h3';
}

Is that the functionality that you're looking for? To surround everything in
an h3 tag?

 sub cgiapp_postrun {
   my $self = shift;
   my $output_ref = shift;

   my $new_output = h3;#.$$output_ref./h3;
   $output_ref = \$new_output;


-
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]



Re: [cgiapp] Problem with cgiapp_postrun method

2003-10-30 Thread Greg Marr
At 11:43 AM 10/30/2003, [EMAIL PROTECTED] wrote:
Now, my problem is that I'm unable to make this function works. Here 
is the code I use within the cgiapp_postrun method:

sub cgiapp_postrun {
  my $self = shift;
  my $output_ref = shift;
  my $new_output = h3;#.$$output_ref./h3;
  $output_ref = \$new_output;
}
That last line should be $$output_ref = $new_output;
Yes, there are some incorrect docs out there that show the form you 
used.

--
Greg Marr
[EMAIL PROTECTED]
-
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]


Re: [cgiapp] Re: directory structure and static pages

2003-10-30 Thread Darin McBride
On October 27, 2003 08:30 pm, Mark Stosberg wrote:
 On 2003-10-28, Darin McBride [EMAIL PROTECTED] wrote:
  But of course, no CGI.  So all pages must exist on the server as static
  HTML.  How does one create static HTML from dynamic content?
 
  I now use CGI::Application::StaticGenerator.  Which I would look
  forward to comments on from other users of C::A.  You cannot find it on
  CPAN - I would like comments first ;-).  You can, however, find it on
  my ISP's webserver:
 
  http://members.shaw.ca/darin.mcbride/CGI-Application-StaticGenerator-0.01
 .tar.gz
 
  If things go well with this, I will put it on CPAN later.

 Darin,

 This is an interesting idea. Here's some feedback:

 - The static_filename needs some more documentation. What is passed
 into the subroutine that I can use to construct a dynamic file name?

Fair enough.

 - I think the dynamic case may be used rather frequently. For
   example, in Cascade, It's designed to work in both dynamic and
   static modes. In the static mode, it's possible to generate a lot of
   static pages. Hundreds of pages are generated from just a few distinct
   templates.

Depends on your needs - that's why there are so many modules with
similar themes doing significantly different things.  We have Net::FTP,
LWP, etc.

 To accomodate this, I would design your module to accomodate any
 possible CGI::App input as something that could influence the output.
 This would include all the parameters passed into an instance script, as
 well as the query object.

 I would also expect that fancy page names will want to be used
 frequently. For example, in Cascade all the category pages are using the
 same template. The page name for a category might be:

 /Top_Level/Mid_Level/Category_Name/Index.html

 The file name generation is complex. It involves putting together
 several category names and encoding them in a particular scheme.

Yes - I'm giving some flexibility to that end so far.

 You may enjoy looking at Cascade::Admin::write_static_pages to see how I
 tackled this. I now want to refactor this code to not use the global
 %FORM for CGI param data and make some other stylistic changes, but you
 get the idea.

 Cascade home page: http://summersault.com/software/cascade/

Looked too complex for me.  ;-)

 Overall, it seems like your module is targeted at a CGI::Application
 project that was designed to be rendered as a bunch of static pages. For

Well, that was my first project with it, yes.  Part of my problem is
that my pages refer to each other, and that's hard to do when sometimes
they should refer to dynamic pages (e.g.
http://my.domain.net/app.cgi?rm=mode1;) vs static pages (e.g.
http://my.domain.net/mode1.html;)  I'd like to figure out a good way
to do this, but it hasn't hit me yet.

 complex projects that may be rendered as dynamic or static content, I
 think I would still be inclined to cook up a custom solution.

I humbly offer this as a place to start, or at least get ideas from :-)

 It may also be worth nothing one of the standard website mirroring tools
 may play a role here. I don't use these frequently, but I believe tools
 like w3mir are good at creating a copy of a dynamic website and
 storing it as static pages.

Different problem space solved here.  In my case, I'm writing code at
home to put on my ISP's webspace.  I don't have access to a webserver
to host this on as an intermediary.  Or at least that's what I was
thinking of.  Of course, I should put some of this in the description
so that people searching cpan may be able to find it :-)


-
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]