Re: [Catalyst] Adding DBIC schema causes TT error

2007-06-21 Thread Matt S Trout
On Thu, Jun 21, 2007 at 09:01:03AM +1000, Charlie Garrison wrote:
 Good morning,
 
 On 20/6/07 at 7:49 AM +0100, Matt S Trout 
 [EMAIL PROTECTED] wrote:
 
 Most probable cause:
 
 You've got a mistyped $c-model(...) or c.model(...) declaration somewhere
 which is falling through to Catalyst's regex search, and -was- originally
 finding the right class because of that but the addition of the extra class
 has caused the hash order for the search to change and now you aren't.
 
 Likely candidates are either a typo or missing DB:: off a DB::Foo-style
 DBIC::Schema model reference.
 
 In an effort to eliminate possible spelling errors as the cause, 
 I removed all controllers except Root and changed Root.pm to 
 only have one action (index) which simply sets 
 $c-response-body. In that configuration the problem goes away.
 
 I slowly added controllers back and the problem didn't recur 
 until I added the last controller back. To determine if problem 
 was with that specific controller, I removed a different 
 controller and the errors goes away.
 
 So, I'm not having the same problem with controllers as with 
 models. There seems to be a limit on the number of controllers 
 or models. I add one more and I get the 'file not found' error, 
 it doesn't seem to matter which controller or model I add, only 
 the number of them.

There is no such limit.

We've seen this before and it's -always- turned out to be hash-order
related in terms of the fall-through component search, a certain number
of entries causes the keys to be searched in a different order.
 
 At this point rather than asking for specific solutions, does 
 anyone have suggestions on how to debug this problem? Bill 
 suggested enabling debugging in Template::Provider (see other 
 message in this thread) but I'm not having any luck with that.

Try, in your MyApp.pm, adding

sub _comp_search {
  my $c = shift;
  warn Fallthrough regex search called for @_;
  $c-NEXT::_comp_search(@_);
}

and looking for that warning being activated.

-- 
  Matt S Trout   Need help with your Catalyst or DBIx::Class project?
   Technical DirectorWant a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/ 

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Adding DBIC schema causes TT error

2007-06-21 Thread Matt S Trout
On Thu, Jun 21, 2007 at 10:30:17AM +1000, Charlie Garrison wrote:
 Good morning,
 
 On 20/6/07 at 4:32 PM +1000, Charlie Garrison 
 [EMAIL PROTECTED] wrote:
 
 I've run into a problem that I can't make any progress with; 
 hoping someone might be able offer suggestions.
 
 Development was moving along nicely and then I suddenly got the following 
 error in a response:
 
 Couldn't render template file error - welcome.tt2: not found
 
 I broke out the debugger and I think I found the cause of the 
 problem (at least *a* cause if not *the* cause). I have a custom 
 view that I use for creating email messages. That view is 
 getting found instead of the default View::TT.
 
 That also explains why the TT:P debug output was not being 
 printed; the TT view was not being used.
 
 So, what are my best options for fixing this? (I'd also like to 
 learn more and understand why adding another controller or 
 module causes a different view to be used.)
 
 I'm guessing the best solution is to specify which view 
 RenderView should be using. I have done that by adding 
 default_view = 'TT' to MyApp-config.
 
 __PACKAGE__-config(
 name = 'MyApp',
 default_view = 'TT',
 
 );
 
 I also tested by setting current_view in the end/RenderView action.
 
 $c-stash-{current_view} = 'TT';
 
 Is one of those a 'preferred' method for setting the default view?

Well, one is global and one is per-request.

So both are preferred for their specific purpose :)
 
 Is the problem I encountered symptomatic of a bug within 
 Catalyst that needs to be fixed? As a 'quick' solution can I 
 suggest the Catalyst debug output show which view is being used. 
 Knowing that a different view was being used would have saved me 
 many hours on this.

I think we'll probably make the fallthrough regex either warn or (if nobody's
actually relying on it, which I -hope- they aren't) simply not exist in 5.80.

I've never seen it mentioned in over a year except as a causer of bugs, so
I think it may be time to screw backcompat on that particular misfeature and
do something more sensible.

-- 
  Matt S Trout   Need help with your Catalyst or DBIx::Class project?
   Technical DirectorWant a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/ 

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Adding DBIC schema causes TT error

2007-06-21 Thread Charlie Garrison

Good morning,

On 21/6/07 at 6:31 PM +0100, Matt S Trout 
[EMAIL PROTECTED] wrote:



Is one of those a 'preferred' method for setting the default view?


Well, one is global and one is per-request.

So both are preferred for their specific purpose :)


I figured as much and I appreciate the clarification. I had 
already gone with the global (config) approach.


 Is the problem I encountered symptomatic of a bug within  
Catalyst that needs to be fixed? As a 'quick' solution can I  
suggest the Catalyst debug output show which view is being 
used.  Knowing that a different view was being used would have 
saved me  many hours on this.


I think we'll probably make the fallthrough regex either warn or (if nobody's
actually relying on it, which I -hope- they aren't) simply not exist in 5.80.

I've never seen it mentioned in over a year except as a causer of bugs, so
I think it may be time to screw backcompat on that particular misfeature and
do something more sensible.


Sounds good to me. I've been really impressed with Catalyst so 
far, and getting rid of 'unexpected' behaviour would be a good thing.


Thanks for all your help with this.


Charlie

--
   Charlie Garrison  [EMAIL PROTECTED]
   PO Box 141, Windsor, NSW 2756, Australia

O ascii ribbon campaign - stop html mail - www.asciiribbon.org
http://www.ietf.org/rfc/rfc1855.txt

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Adding DBIC schema causes TT error

2007-06-20 Thread Jon Schutz
On Wed, 2007-06-20 at 16:32 +1000, Charlie Garrison wrote:
 Good afternoon,
 
 I've run into a problem that I can't make any progress with; 
 hoping someone might be able offer suggestions.
 
 Development was moving along nicely and then I suddenly got the 
 following error in a response:

  Couldn't render template file error - welcome.tt2: not found
 

Looks like a side-effect of another error.  If $c-stash-{template} is
not set, it defaults to the action name.

Presumably you have a sub called 'welcome' in your controller class and
under normal processing you set $c-stash-{template} = something.
What happens if an error occurs with your DBIC schema manipulation -
does it bypass the setting of the template?

HTH.

-- 

Jon


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Adding DBIC schema causes TT error

2007-06-20 Thread Matt S Trout
On Wed, Jun 20, 2007 at 04:32:27PM +1000, Charlie Garrison wrote:
 Good afternoon,
 
 I've run into a problem that I can't make any progress with; 
 hoping someone might be able offer suggestions.
 
 Development was moving along nicely and then I suddenly got the 
 following error in a response:
 
 Couldn't render template file error - welcome.tt2: not found
 
 The only thing I could find that would stop the error was 
 removing the last DBIC schema class that I added to 
 load_classes. Since I couldn't see anything obviously wrong with 
 the class/module, I tried duplicating a known good class and 
 renaming it. When I add that class I get the same error. I 
 tested with a variety of different modules and the only 
 consistency I could find was that adding one more class caused 
 the above error.
 
 I tried changing the order of classes loaded and the problem persists.
 
 I leave the new class in place and remove one of the existing 
 classes, and the problem disappears. There seems to be a maximum 
 limit on the number of classes I can have loaded. I'm only at 19 
 classes and I find it hard to believe that would be a limit. So...

Most probable cause:

You've got a mistyped $c-model(...) or c.model(...) declaration somewhere
which is falling through to Catalyst's regex search, and -was- originally
finding the right class because of that but the addition of the extra class
has caused the hash order for the search to change and now you aren't.

Likely candidates are either a typo or missing DB:: off a DB::Foo-style
DBIC::Schema model reference.

-- 
  Matt S Trout   Need help with your Catalyst or DBIx::Class project?
   Technical DirectorWant a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/ 

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Adding DBIC schema causes TT error

2007-06-20 Thread Charlie Garrison

Good afternoon,

On 20/6/07 at 4:09 PM +0930, Jon Schutz 
[EMAIL PROTECTED] wrote:



Looks like a side-effect of another error.  If $c-stash-{template} is
not set, it defaults to the action name.

Presumably you have a sub called 'welcome' in your controller class and
under normal processing you set $c-stash-{template} = something.
What happens if an error occurs with your DBIC schema manipulation -
does it bypass the setting of the template?


Thanks for the suggestion, but I don't think this is it. The 
$c-stash-{template} is being set explicitly and I've tested 
against different controllers  actions and the error from TT 
always shows the expected template name.


Thanks,
Charlie

--
   Charlie Garrison  [EMAIL PROTECTED]
   PO Box 141, Windsor, NSW 2756, Australia

O ascii ribbon campaign - stop html mail - www.asciiribbon.org
http://www.ietf.org/rfc/rfc1855.txt

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Adding DBIC schema causes TT error

2007-06-20 Thread Charlie Garrison

Good afternoon,

On 20/6/07 at 7:49 AM +0100, Matt S Trout 
[EMAIL PROTECTED] wrote:



Most probable cause:

You've got a mistyped $c-model(...) or c.model(...) declaration somewhere
which is falling through to Catalyst's regex search, and -was- originally
finding the right class because of that but the addition of the extra class
has caused the hash order for the search to change and now you aren't.


This sounds like a possible cause, but I just did a search 
across all my app modules for 'model(' and none of them appear 
to be incorrect. And I don't reference any models directly from 
my template views.



Likely candidates are either a typo or missing DB:: off a DB::Foo-style
DBIC::Schema model reference.


I also checked all the relationship declarations for a typo and 
couldn't see anything there either. End of a long work day now 
so I'll leave it and hope for other suggestions. Or maybe fresh 
eyes in the morning will spot the typo.


Thanks for your assistance and if you have other suggestions, 
please let me know.


Thanks,
Charlie

--
   Charlie Garrison  [EMAIL PROTECTED]
   PO Box 141, Windsor, NSW 2756, Australia

O ascii ribbon campaign - stop html mail - www.asciiribbon.org
http://www.ietf.org/rfc/rfc1855.txt

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Adding DBIC schema causes TT error

2007-06-20 Thread Charlie Garrison

Good afternoon,

On 20/6/07 at 7:49 AM +0100, Matt S Trout 
[EMAIL PROTECTED] wrote:



You've got a mistyped $c-model(...) or c.model(...) declaration somewhere
which is falling through to Catalyst's regex search, and -was- originally
finding the right class because of that but the addition of the extra class
has caused the hash order for the search to change and now you aren't.


One other thing. With the test I'm doing now, there are no 
models being loaded (via $c-model or c.model), so would a 
misspelling have any effect anyway?



Charlie

--
   Charlie Garrison  [EMAIL PROTECTED]
   PO Box 141, Windsor, NSW 2756, Australia

O ascii ribbon campaign - stop html mail - www.asciiribbon.org
http://www.ietf.org/rfc/rfc1855.txt

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Adding DBIC schema causes TT error

2007-06-20 Thread Bill Moseley
On Wed, Jun 20, 2007 at 04:32:27PM +1000, Charlie Garrison wrote:
 Good afternoon,
 
 I've run into a problem that I can't make any progress with; 
 hoping someone might be able offer suggestions.
 
 Development was moving along nicely and then I suddenly got the 
 following error in a response:
 
 Couldn't render template file error - welcome.tt2: not found

What version of TT are you using?  Does it get fixed if you restart
the dev server?

Not too old versions of TT had a problem that once an error was found
in a template the template then always missing.  I don't see it
mentioned in Changes but I suspect you need 2.19 if that's the problem
you are hitting.

-- 
Bill Moseley
[EMAIL PROTECTED]


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Adding DBIC schema causes TT error

2007-06-20 Thread Charlie Garrison

Good morning,

On 20/6/07 at 6:31 AM -0700, Bill Moseley [EMAIL PROTECTED] wrote:


What version of TT are you using?  Does it get fixed if you restart
the dev server?


I *was* using 2.18. Yes, I have been restarting between tests.


Not too old versions of TT had a problem that once an error was found
in a template the template then always missing.  I don't see it
mentioned in Changes but I suspect you need 2.19 if that's the problem
you are hitting.


I saw recent messages in the archive regarding that (maybe from 
you). So I went looking for templates cached to disk. From what 
I can tell, templates will only be cached to disk if I set up my 
TT options accordingly, is that correct? So I should only be 
dealing with memory cache which should get cleared each time I 
restart the dev server.


Upgrading to TT 2.19 has not fixed my problem. If anyone else 
has suggestions I'd love to hear them. Development has ground to 
a halt here and I'm getting very anxious (deadlines and all that).


Thanks,
Charlie

--
   Charlie Garrison  [EMAIL PROTECTED]
   PO Box 141, Windsor, NSW 2756, Australia

O ascii ribbon campaign - stop html mail - www.asciiribbon.org
http://www.ietf.org/rfc/rfc1855.txt

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Adding DBIC schema causes TT error

2007-06-20 Thread Bill Moseley
On Thu, Jun 21, 2007 at 07:20:20AM +1000, Charlie Garrison wrote:
 I saw recent messages in the archive regarding that (maybe from 
 you). So I went looking for templates cached to disk. From what 
 I can tell, templates will only be cached to disk if I set up my 
 TT options accordingly, is that correct? So I should only be 
 dealing with memory cache which should get cleared each time I 
 restart the dev server.

That problem I was talking about was independent of disk caching.
It means you often had to restart the server after a template error
or else the template would not be found even after correcting the
error in the template.  Doesn't really sound like your problem,
although it's a bit odd that adding a schema class would effect
how TT finds templates.

But, yes, you have to enable disk caching of compiled templates
explicitly.

 Upgrading to TT 2.19 has not fixed my problem. If anyone else 
 has suggestions I'd love to hear them. Development has ground to 
 a halt here and I'm getting very anxious (deadlines and all that).

If you are getting a template not found error then maybe enabling
debugging in Template::Provider would help -- or just throw in a few
warn messages to see what paths it's looking for the template.





r1024 | abw | 2006-08-01 10:35:45 -0700 (Tue, 01 Aug 2006) | 5 lines

* Fixed bug in Template::Parser to ensure $self-{ DEFBLOCKS } is cleared
  each time a parse() begins.
* Fixed bug in Template::Provider to immediately invalidate the cache entry
  of any template that fails to compile.


-- 
Bill Moseley
[EMAIL PROTECTED]


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Adding DBIC schema causes TT error

2007-06-20 Thread Charlie Garrison

Good morning,

On 20/6/07 at 2:55 PM -0700, Bill Moseley [EMAIL PROTECTED] wrote:


Doesn't really sound like your problem,
although it's a bit odd that adding a schema class would effect
how TT finds templates.


I would agree with that.  :-|


If you are getting a template not found error then maybe enabling
debugging in Template::Provider would help -- or just throw in a few
warn messages to see what paths it's looking for the template.


Would you mind giving some specifics. I added DEBUG = '1' to 
__PACKAGE__-config in my View::TT but I'm not seeing any extra 
debug info. I am using a mostly default setup for View::TT,


__PACKAGE__-config({
CATALYST_VAR = 'Catalyst',
INCLUDE_PATH = [
RP-path_to( 'root', 'src' ),
RP-path_to( 'root', 'lib' )
],
PRE_PROCESS  = 'config/main',
WRAPPER  = 'site/wrapper',
ERROR= 'error.tt2',
TIMER= 0,
TEMPLATE_EXTENSION = '.tt2',
DEBUG= '1',
});

How do I enable debugging in Template::Provider? Following the 
man page, I also tried this:


use Template::Constants qw( :debug );
__PACKAGE__-config({
..
DEBUG= DEBUG_PROVIDER,
});

With that option I got this:

[Template::Provider] creating cache of unlimited slots for [ 
CODE(0x1d38890) ]


But no other debugging output that I could see.

Thanks,
Charlie

--
   Charlie Garrison  [EMAIL PROTECTED]
   PO Box 141, Windsor, NSW 2756, Australia

O ascii ribbon campaign - stop html mail - www.asciiribbon.org
http://www.ietf.org/rfc/rfc1855.txt

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Adding DBIC schema causes TT error

2007-06-20 Thread Charlie Garrison

Good morning,

On 20/6/07 at 7:49 AM +0100, Matt S Trout 
[EMAIL PROTECTED] wrote:



Most probable cause:

You've got a mistyped $c-model(...) or c.model(...) declaration somewhere
which is falling through to Catalyst's regex search, and -was- originally
finding the right class because of that but the addition of the extra class
has caused the hash order for the search to change and now you aren't.

Likely candidates are either a typo or missing DB:: off a DB::Foo-style
DBIC::Schema model reference.


In an effort to eliminate possible spelling errors as the cause, 
I removed all controllers except Root and changed Root.pm to 
only have one action (index) which simply sets 
$c-response-body. In that configuration the problem goes away.


I slowly added controllers back and the problem didn't recur 
until I added the last controller back. To determine if problem 
was with that specific controller, I removed a different 
controller and the errors goes away.


So, I'm not having the same problem with controllers as with 
models. There seems to be a limit on the number of controllers 
or models. I add one more and I get the 'file not found' error, 
it doesn't seem to matter which controller or model I add, only 
the number of them.


At this point rather than asking for specific solutions, does 
anyone have suggestions on how to debug this problem? Bill 
suggested enabling debugging in Template::Provider (see other 
message in this thread) but I'm not having any luck with that.


Some very anxious people mulling around on this end. All 
assistance is appreciated.


Thanks,
Charlie

--
   Charlie Garrison  [EMAIL PROTECTED]
   PO Box 141, Windsor, NSW 2756, Australia

O ascii ribbon campaign - stop html mail - www.asciiribbon.org
http://www.ietf.org/rfc/rfc1855.txt

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Adding DBIC schema causes TT error

2007-06-20 Thread Charlie Garrison

Good morning,

On 20/6/07 at 4:32 PM +1000, Charlie Garrison 
[EMAIL PROTECTED] wrote:


I've run into a problem that I can't make any progress with; 
hoping someone might be able offer suggestions.


Development was moving along nicely and then I suddenly got the following error 
in a response:

Couldn't render template file error - welcome.tt2: not found


I broke out the debugger and I think I found the cause of the 
problem (at least *a* cause if not *the* cause). I have a custom 
view that I use for creating email messages. That view is 
getting found instead of the default View::TT.


That also explains why the TT:P debug output was not being 
printed; the TT view was not being used.


So, what are my best options for fixing this? (I'd also like to 
learn more and understand why adding another controller or 
module causes a different view to be used.)


I'm guessing the best solution is to specify which view 
RenderView should be using. I have done that by adding 
default_view = 'TT' to MyApp-config.


__PACKAGE__-config(
name = 'MyApp',
default_view = 'TT',

);

I also tested by setting current_view in the end/RenderView action.

$c-stash-{current_view} = 'TT';

Is one of those a 'preferred' method for setting the default view?

Is the problem I encountered symptomatic of a bug within 
Catalyst that needs to be fixed? As a 'quick' solution can I 
suggest the Catalyst debug output show which view is being used. 
Knowing that a different view was being used would have saved me 
many hours on this.


Anyway, back to work now. Even with this loss of time I'm still 
getting this project done much faster with Catalyst than using 
my old home-made framework. It's really good kit.


Thanks,
Charlie

--
   Charlie Garrison  [EMAIL PROTECTED]
   PO Box 141, Windsor, NSW 2756, Australia

O ascii ribbon campaign - stop html mail - www.asciiribbon.org
http://www.ietf.org/rfc/rfc1855.txt

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/