Re: [Catalyst] Bugzilla REST API in Catalyst

2010-01-17 Thread Gervase Markham
On 16/01/10 18:29, Adam Taylor wrote:
 Any chance of making the constructive criticism public, it may be of
 benefit to others (like me).

Every chance, although Kiffin Gish is the only person who has kindly
agreed to look at the code, and I haven't heard back yet.

Gerv

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


Re: [Catalyst] Mocking for Catalyst testing

2010-01-17 Thread Stuart Watt
On 2010-01-16, at 10:31 PM, Tomas Doran wrote:

 I tend to just use Moose directly to construct mock classes for me:

Things are improving, t0m. I tried

use Class::MOP;
use Class::MOP::Class;
my $meta_refreshes = Class::MOP::Class-create('ARMAdmin::Model::Refreshes');
$meta_refreshes-add_method('get_profiles' = sub { die(Failed to get 
profiles); });

Then I start the app in the test framework. I'm just after getting the 
get_profiles mocked method called here, later I want it to return values I can 
test in the generated page. 

However, Catalyst then calls:

Catalyst::Utils::ensure_class_loaded( $component, { ignore_loaded = 1 } );

The ignore_loaded seems to bypass everything and overwrite my newly mocked 
class just when I need it. I get the method redefined, and a warning about it. 
The comment in the code here says this is needed for some Schema::Loader 
functionality dependent on loading even when the class exists. Doesn't this 
make mocking impossible?

The ignore_loaded = 1 setting seems a somewhat heavy assumption to make for 
all components. 

Can anyone offer a way around this that doesn't involve too much patching?

All the best
Stuart
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Mocking for Catalyst testing

2010-01-17 Thread Tomas Doran


On 17 Jan 2010, at 18:36, Stuart Watt wrote:


On 2010-01-16, at 10:31 PM, Tomas Doran wrote:


I tend to just use Moose directly to construct mock classes for me:


Things are improving, t0m. I tried

use Class::MOP;
use Class::MOP::Class;
my $meta_refreshes = Class::MOP::Class- 
create('ARMAdmin::Model::Refreshes');
$meta_refreshes-add_method('get_profiles' = sub { die(Failed to  
get profiles); });


Then I start the app in the test framework. I'm just after getting  
the get_profiles mocked method called here, later I want it to  
return values I can test in the generated page.


However, Catalyst then calls:

Catalyst::Utils::ensure_class_loaded( $component, { ignore_loaded =  
1 } );


Right, hang on.. Why are you mocking things and then loading the  
entire application?


Usually you either run the full app for system testing (with test  
config that points at a test DB or whatever), or you mock _lots of  
stuff_ (like the context class, the request and response) and unit  
test one component..


Trying to mangle methods then load the full app won't work..

If you reay need to do this - use Catalyst::Test 'MyApp', then  
manipulate the class after catalyst has loaded it (e.g my $meta =  
MyApp::Model::Foo-meta; $meta-remove_method('bar'); $meta- 
add_method('bar' = sub { die(New bar) }); )


but I'd not recommend it..

Cheers
t0m
 
 


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


Fwd: [Catalyst] Selecting from more tables (DBIC - bug?)

2010-01-17 Thread Thomas L. Shinnick
Trying again to forward to DBIC list, which rejected my previous try 
at forwarding with additions...



From: Octavian Rasnita orasn...@gmail.com
To: The elegant MVC web framework catalyst@lists.scsys.co.uk
Date: Sun, 17 Jan 2010 15:22:57 +0200
Subject: [Catalyst] Selecting from more tables (DBIC - bug?)

Hi,

Sorry for not writing to the DBIC mailing list, but it rejects my messages
as SPAM.

I have tried the following select from the table user:

return $self-search_rs({},{
prefetch = {blogs = 'blog_comments'},
'+select' = ['me.id'],
'+as' = ['user_id'],
});

The table user has_many blogs and it also has_many blog_comments.

The table blog has_many blog_comments and belongs_to user.

The table blog_comment belongs_to user and belongs_to blog.

The problem is that the +select and +as options have no effect, and the
query above returns all the columns from all 3 tables, no matter what
columns I select.

It seems to work only if I use join instead of prefetch and select and
as instead of +select and +as.

I use ActivePerl 5.10.1 and the latest versions of DBIx::Class and
SQL::Abstract.

Is there a bug or I am missing something obvious, or it is just not possible
what I want?

Thank you.

Octavian


I'm having some of the same questions regarding +select and +as .  It
seems that using '+select' and '+as' does not stop other columns from
being returned.  I'm using DBIC 0.08115.

I've got a 3 table test setup, which might be confusing, but please just
look at the SELECT lines below.

First I use the syntax as documented, with the '+' in front of 'select'
and 'as'.

  $rs1 = $schema-resultset('Users')
-search( { 'me.is_admin' = '1' },
{ join  = { 'users_roots' = 'root_id' },
  '+select' = [ 'me.user_id',
 'me.user_name',
 'root_id.rootpath',
   ],
  '+as' = [ 'admin_id',
 'admin_name',
 'admin_rootpath',
   ],
  'order_by' = ['root_id.rootpath'],

When I query a returned row using get_column() I get something for every
name queried, table column or 'as' specified name.

  #   ( I see '2' for user_id )
  #   ( I see '1admin' for password )
  #   ( I see '2' for admin_id )

And looking at the SELECT line you can see that what is being requested
isn't just what was asked for, and some columns are requested twice!

SELECT me.user_id, me.user_name, me.password, me.is_admin, me.info,
   me.user_id, me.user_name, root_id.rootpath
  FROM users me
  LEFT JOIN users_roots users_roots ON users_roots.user_id = me.user_id
  LEFT JOIN roots root_id ON root_id.root_id = users_roots.root_id
 WHERE ( me.is_admin = ? ) ORDER BY root_id.rootpath: '1'


Here I just take the '+' out of '+select' and '+as':

  'select' = [ 'me.user_id',
 'me.user_name',
 'root_id.rootpath',
   ],
  'as' = [ 'admin_id',
 'admin_name',
 'admin_rootpath',
   ],

And now some of the unrequested columns are now gone or renamed as requested:

  #   ( I see 'undef' for user_id )
  #   ( I see 'undef' for password )
  #   ( I see '2' for admin_id )

And that is the story that the SELECT line tells also - only the 3 columns
I've asked for are requested:

SELECT me.user_id, me.user_name, root_id.rootpath
  FROM users me
  LEFT JOIN users_roots users_roots ON users_roots.user_id = me.user_id
  LEFT JOIN roots root_id ON root_id.root_id = users_roots.root_id
 WHERE ( me.is_admin = ? ) ORDER BY root_id.rootpath: '1'

So while I'm not seeing a difference with 'join' and 'prefetch' with
Octavian (and that is probably because my debug tests aren't good enough),
I am seeing a concrete difference about retrieved columns.  What is
supposed to be true? 



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


Re: [Catalyst] Mocking for Catalyst testing

2010-01-17 Thread Stuart Watt
Excellent!!! Just what I'd needed and never found - dunno why. I kind of 
improvised part of this (I used remote and local versions of a model 
elsewhere), but this work work just fine for me, and I can use it to simplify 
the other usages as well. I can then fake everything I need through 
configuration.

All the best
Stuart  


On 2010-01-17, at 8:56 PM, Tomas Doran wrote:

 
 On 17 Jan 2010, at 22:07, Stuart Watt wrote
 
 What I wanted to be able to do was mock out the remote job queue web 
 service, so at least I could check out that the front end render stuff 
 without to put an entire web server temporarily in place. Basically, I'd 
 hoped to replace the model that implements the web service and check that 
 the right stuff goes in and out.
 
 Right - and _THIS_ is why you implement your model classes outside of 
 Catalyst, and bind them in.
 
 If you are using Catalyst::Model::Adaptor to bind an external class, then 
 changing the implementation of the model class to a mock class in your test 
 suite is a simple case of providing some config to change the name of the 
 class which is adapted...
 
 Cheers
 t0m
 
 
 ___
 List: Catalyst@lists.scsys.co.uk
 Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
 Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
 Dev site: http://dev.catalyst.perl.org/
 
 --
 This message was scanned by ESVA and is believed to be clean.
 Click here to report this message as 
 spam.http://antispam.infobal.com/cgi-bin/learn-msg.cgi?id=358052807F.E175C
 


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


[Catalyst] Enabling debug mode with fastcgi..

2010-01-17 Thread Toby Corkindale

Hi guys,
If you're running a Catalyst app with the fastcgi script (as found in 
scripts/myapp_name_fastcgi.pl), then is there a way to enable the debug 
mode. (eg. like running scripts/myapp_server.pl -d)


I've tried setting CATALYST_DEBUG and MYAPP_DEBUG in the shell 
environment, but that doesn't seem to work. Either that or else fastcgi 
is discarding the output somewhere in our case. (I've messed with the 
-keeperr option too)


Cheers,
Toby

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


RE: [Catalyst] Re: modules for conditional GET ?

2010-01-17 Thread Dami Laurent (PJ)
 

-Message d'origine-
De : Aristotle Pagaltzis [mailto:pagalt...@gmx.de] 
Envoyé : samedi, 16. janvier 2010 15:34
À : catalyst@lists.scsys.co.uk
Objet : [Catalyst] Re: modules for conditional GET ?

* Dami Laurent (PJ) laurent.d...@justice.ge.ch [2010-01-14 16:05]:
 For some actions of a Catalyst app, I would like to implement
 conditional GET (using If-Modified-Since HTTP header), where
 the timestamp of one config file decides whether the page
 should be refreshed or not  --- this is because that page is
 quite expensive to compute.

I agree with the others who have responded, but they didn't
explain why theirs was the right answer, so:

You're not checking whether any state has changed since the
last GET to decide whether to recompute. That is the case in
which conditional GET would be appropriate. That would allow
you to avoid recomputing the page indefinitely as long as no
state changes necessitate it, but it requires that the clients
keep asking.


Indeed, this is exactly what I want to do. The app has a config file (not a 
Catalyst
config file, but another file having to do with business logic), and some 
super-users
have a mechanism for hot uploading of a new config to the server, at any time. 
A few app pages are expensive to compute, and they depend on the client and on 
that config file. So clients should keep asking for those pages at each 
request, and depending on the If-Modified-Since header and on the timestamp for 
the config file, the server can decide if it's worth recomputing the page for 
that client, or rather send a cheap 304 Not Modified.

Cheers, L. Dami

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