I want to apologise for saying I was having trouble with extends.

When using extends,
$self->subroutinename(); worked fine,
while just subroutinename(); didn't - and that was my hiccup/mistake.
It's now working fine with $self->subroutinename(); to call the subroutine, 
although I've obviously had to anticipate the first value of @_ now being $self.

I'm new to Modern Perl, so still a bit iffy on things like $self (I know it's 
an object - and that's it),
so I'm intrigued to hear you mention simply using Use instead of extends.
I was searching through a lot of online tutorials, and all the older ones have 
use and use base as examples in base controller tutorials,
and the more recent ones mention extends instead.
The Definitive Guide to Catalyst states: "use base 'Catalyst::Controller' and 
use Moose; extends 'Catalyst Controller' are essentially the same,".
I also found a Catalyst Advent Calendar post (2008, Day 16) mentioning that in 
previous Catalysts you would use use, whereas in 5.80+ you could use use Moose, 
and then extends. I guess it's just another option - good to hear a plain old 
use could work also. KISS, =).

Yours,
Andrew.

  ----- Original Message ----- 
  From: Martin Thurn 
  To: The elegant MVC web framework 
  Sent: Friday, July 15, 2016 2:21 PM
  Subject: Re: [Catalyst] KISS - Base Subroutines.


  Don't bother with the extends stuff.  Just 


  use MyApp::CommonUse::FileOne;







   - - Martin 









------------------------------------------------------------------------------

  From: Andrew <[email protected]>
  Sent: Friday, July 15, 2016 9:10 AM
  To: The elegant MVC web framework
  Subject: Re: [Catalyst] KISS - Base Subroutines. 


  I'd have to look into how to do that, John.

  Right now, I've got something working, so I'll continue to build on that.

  One problem I have come across with my approach of a CommonUse folder, and 
.pm files within it,
  is when one of the .pm files needs to be used by another.

  I thought I could merely have the first file, extending 
Catalyst::Controller....

  BEGIN { extends 'Catalyst::Controller' }

  ....and the second file, extending the first file:

  BEGIN { extends 'MyApp::CommonUse::FileOne' }

  ...and then the controller that needs to use FileTwo, extending that...

  BEGIN { extends 'MyApp::CommonUse::FileTwo' }

  Unfortunately, when FileTwo tries to call a subroutine in FileOne, I get:
  "Undefined subroutine &MyApp::CommonUse::FileTwo::subroutinename"
  If I stop worrying about the BEGIN/extends block, and instead just type: 
MyApp::CommonUse::FileOne::subroutinename(); it executes fine. 

  In short:
  I've a base controller directory called CommonUse.
  There are two files in it.
  How can FileTwo use subroutines in FileOne, without typing the explicit 
package path each time?

  Many thanks,

  Yours,
  Andrew.








------------------------------------------------------------------------------


  _______________________________________________
  List: [email protected]
  Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
  Searchable archive: http://www.mail-archive.com/[email protected]/
  Dev site: http://dev.catalyst.perl.org/

_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to