Re: [Catalyst] Help Deploying on mod-fcgi Rather than mod_fastcgi

2011-02-13 Thread Francisco Obispo
Is there a reason why you need it to be fast_cgi and not mod_perl ?




On Feb 13, 2011, at 10:38 AM, Mark Hughes wrote:

 I should have added that this is a sample of my error.log:
 
 [root@mayfly log]# cat error.log
 [Sun Feb 13 11:29:45 2011] [warn] (104)Connection reset by peer: mod_fcgid: 
 read data from fastcgi server error.
 [Sun Feb 13 11:29:45 2011] [error] [client 192.168.123.102] Premature end of 
 script headers: sumo_fastcgi.pl
 [Sun Feb 13 11:29:50 2011] [warn] (104)Connection reset by peer: mod_fcgid: 
 read data from fastcgi server error.
 [Sun Feb 13 11:29:50 2011] [error] [client 192.168.123.102] Premature end of 
 script headers: sumo_fastcgi.pl
 [Sun Feb 13 11:33:11 2011] [warn] (104)Connection reset by peer: mod_fcgid: 
 read data from fastcgi server error.
 [Sun Feb 13 11:33:11 2011] [error] [client 192.168.123.102] Premature end of 
 script headers: sumo_fastcgi.pl
 [Sun Feb 13 11:33:15 2011] [warn] (104)Connection reset by peer: mod_fcgid: 
 read data from fastcgi server error.
 [Sun Feb 13 11:33:15 2011] [error] [client 192.168.123.102] Premature end of 
 script headers: sumo_fastcgi.pl
 
 This is when using the hjksolutions setup linked in my original message.
 
 Thanks.
 
 
 On 02/13/2011 11:24 AM, Mark Hughes wrote:
 I am trying to work through deployng a Catalyst app on an apache2 server
 with mod_fcgi installed. I don't know what I am doing, and I have spent
 an embarrassingly long time accomplishing nothing.
 
 The app runs okay when I run the standalone myapp_server.pl on the
 server. Requests from sitename:3000 generate charming debug messages and
 pages appear in the browser -- just as when I run the app locally.
 
 The trouble is that I cannot get myapp_fastcgi.pl to serve pages. When I
 try to use myapp_fastcgi.pl, the standard debug status messages appear,
 followed by this:
 
 [info] sumo powered by Catalyst 5.80031
 FastCGI: manager (pid 14119): initialized
 FastCGI: manager (pid 14119): server (pid 14120) started
 FastCGI: server (pid 14120): initialized
 
 Seems fine. But requests result only in 404 errors.
 
 I am stumped and out of things to try.
 
 I have looked at a large number of pages on deploying Catalyst apps,
 including the wiki, advent calendar (several days),
 Catalyst::Engine::FastCGI docs (all three modes), and tried most of
 them. The only thing I have really discovered is that most of the
 instructions seem to be for mod_fastcgi rather than mod_fcgi. And most
 of what I have found and tried prevent apache from starting. (I think
 because mod_fcgi breaks on ExternalServer directives.)
 
 The most promising, because it deals specifically with mod_fcgid, might
 be
 http://blog.hjksolutions.com/articles/2007/07/19/catalyst-deployment-with-apache-2-and-mod_fcgid
 but I don't understand even the basics of how it works. It doesn't seem
 to tell anything to listen anywhere, and I don't know how to
 successfully start myapp_fastcgi.pl without telling it to listen someplace.
 
 Any suggestions would help. Thanks.
 
 ___
 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/
 .
 
 
 
 ___
 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/

Francisco Obispo 
Hosted@ Programme Manager
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
Key fingerprint = 532F 84EB 06B4 3806 D5FA  09C6 463E 614E B38D B1BE





___
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] URI-new() with utf8 string and Unicode::Encoding will not work (but URI-new() with utf8 octets will work)

2011-03-03 Thread Francisco Obispo
I believe what's happening is that Catalyst is converting the UTF-8 string into 
perl format (decoding), and in that particular example, is working for you 
because the string is forced back into UTF-8 with the encode_utf8 function.

This is a code I wrote and use to test unicode issues:

#!/usr/bin/env perl
use Encode;

#my @list = Encode-encodings(q{:all});

#printf(Encodings Available:\n);
#map {printf(\t-%s\n,$_)}@list;


foreach (@ARGV) {
  printf( Word is %s\n, $_ );
  my $i = 0;
  my $string=decode('utf8',$_);
  my @chr = split( q{}, $string);
  printf( Length decoded is %d\n, length(decode_utf8($_)) );
  printf( Length as bytes is %d\n, length($_) );
  map {
printf( '%d] +U%.4X - %2$04d - %s' . \n,
++$i, ord($_), encode_utf8($_) )
  } @chr;
}

In order to get the correct length, I have to decode the UTF-8 string into 
internal Perl's format, otherwise it will just count bytes:

$ ./test_unicode.pl español
Word is español
Length decoded is 7
Length as bytes is 8
1] +U0065 - 0101 - e
2] +U0073 - 0115 - s
3] +U0070 - 0112 - p
4] +U0061 - 0097 - a
5] +U00F1 - 0241 - ñ
6] +U006F - 0111 - o
7] +U006C - 0108 - l

As you can see, perl interprets the string (len()) as either a UTF-8 string or 
as bytes depending whether the string has been decoded or not.

So, if you don't decode the string, the result is a disaster when using string 
functions (such as split()).

Hope this helps.

Francisco


On Mar 3, 2011, at 11:26 PM, Eisenberger Tamás wrote:

 Hy!
 
 Yes using encode_utf8 makes the test works.
 
 But anyway, this looks like a problem with the test, because we have
 tests to compare the entire captures / arguments / params strings with
 their originals, and if these tests pass the length of the strings must
 be ok!
 
 So Erik, can you please review your test, or explain a real word
 situation of the problem you facing?
 
 I actually use utf8 strings in url's now without problems :)
 -- 
 Eisenberger Tamás ta...@eisenberger.hu
 
 On Thu, 2011-03-03 at 21:33 -0800, Bill Moseley wrote:
 Does this help?
 
 On Thu, Mar 3, 2011 at 2:38 PM, Erik Wasser erik.was...@iquer.net
 wrote:
foreach my $u ('http://localhost/test/%E3%81%8B',
http://localhost/test/\x{304b}; )
{
   my $request = HTTP::Request-new(
   'GET'= encode_utf8($u), [ 'Content-Type' =
'text/html; charset=utf8', ],
   );
   print $request-as_string();
   my $response = request( $request );
   is( $response-content, 'length = 1', 'length = 1' );
}
 
 
 -- 
 Bill Moseley
 mose...@hank.org
 ___
 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/
 ___
 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/

Francisco Obispo 
Hosted@ Programme Manager
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
Key fingerprint = 532F 84EB 06B4 3806 D5FA  09C6 463E 614E B38D B1BE





___
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] How to do .htaccess?

2011-03-07 Thread Francisco Obispo
You can safely use Location /xxx based control's (if using apache)

Francisco



On Mar 7, 2011, at 2:22 AM, John M. Dlugosz wrote:

 I want to make one path in my app password protected, and a very simple way 
 will be fine.  Also, while in development, I want to make the whole think 
 password protected.
 
 I thought I'd just use .htaccess.  But, since this isn't really an appache 
 directory (except for static files), where would I put this information?
 
 
 ___
 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/

Francisco Obispo 
Hosted@ Programme Manager
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
Key fingerprint = 532F 84EB 06B4 3806 D5FA  09C6 463E 614E B38D B1BE





___
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] Updating a database entry

2011-04-03 Thread Francisco Obispo
Remember that Catalyst uses DBIx::Class as an ORM, so it must be able to 
uniquely identified each row with a Primary Key.

If you're going to update the primary key (which is not usually a good idea), 
make sure that you have 'ON UPDATE CASCADE' on referencing child tables, 
otherwise the operation will fail.

Francisco

On Apr 3, 2011, at 12:25 PM, Adam Jimerson wrote:

 I managed to find my error that was causing my problem:
 
 DBIx::Class::DynamicDefault::update(): Operation requires a primary key
 to be declared on 'TickIt::Schema::Result::Tech' via set_primary_key at
 /home/vendion/Projects/TickIt/script/../lib/TickIt/Controller/Admin.pm
 line 114
 
 Does it make a difference that none of the fields that I am updating is
 my primary_key on my database?  Or is it complaining about the lack of a
 primary key all together?
 
 Rohan M wrote:
 Hi Adam,
 
 Did you try putting result-set in the variable rather than directly
 putting it into stash?
 
 my $user = $c-model('DB::Tech')-find({id = $userid});
 $user-update({ id = $username,
   firstname = $fname,
   lastname = $lname,
   email = $email,
   phone = $phone,});
 
 Try this and let us know
 
 On Sun, Apr 3, 2011 at 12:07 AM, Adam Jimerson vend...@gmail.com
 mailto:vend...@gmail.com wrote:
 
 First of all hello people of the list!
 
 I am working on my first Catalyst app and need some help updating an
 entry from my database.
 
 $c-stash( users_rs = $c-model('DB::Tech'));
 my $user = $c-stash-{users_rs}-find({ id = $userid });
  die No such user: $userid\n if (!$user);
 $c-stash(user = $user);
 $c-log-debug('Before update');
 $user-update({
   id = $username,
   firstname = $fname,
   lastname = $lname,
   email = $email,
   phone = $phone,
   });
 $c-log-debug('After update');
 
 In the debug output from Catalyst I can see where the Before update
 gets printed but fails with no error that I can see during the update.
 Any help or advice in this matter would be greatly appreciated.
 
 ___
 List: Catalyst@lists.scsys.co.uk mailto: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/
 
 
 
 
 -- 
 रोहन मल्लेल्रवार
 
 
 
 
 ___
 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/
 
 
 ___
 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/

Francisco Obispo 
Hosted@ Programme Manager
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
Key fingerprint = 532F 84EB 06B4 3806 D5FA  09C6 463E 614E B38D B1BE





___
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] TT2 multiple subtemplates

2011-08-10 Thread Francisco Obispo
Look at the INCLUDE directive in perldoc Template::Manual::Directives

   INCLUDE
   The INCLUDE directive is used to process and include the output of 
another template file or block.

   [% INCLUDE header %]


Francisco



On Aug 10, 2011, at 12:00 PM, Stefan wrote:

 Hi,
 I’m new at the catalyst framework and using Template Toolkit.
 
 What is the best practice to load a template like the following:
 
 html
 body
 div class“left“
 [% content %]
 /div
 div class“right“
 [% right_content %]
 /div
 /body
 /html
 
 ‚content‘ should be replaced with left_content.tt2
 ‚right_content‘ with right_content.tt2
 
 If I use a Wrapper, only content is automatically replaced. How can I also 
 replace right_content?
  
 Thanks for your Help!!
 Stefan
 ___
 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/

Francisco Obispo 
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
Key fingerprint = 532F 84EB 06B4 3806 D5FA  09C6 463E 614E B38D B1BE






___
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] Double encoding of UTF8 strings

2011-10-07 Thread Francisco Obispo
JSON will try to encode in UTF-8 format and if the data is already in UTF-8, 
most likely it will be double encoded.

This could be fixed in two ways:

1) when loading your UTF-8 data, convert it to perl's internal encoding with:

use Encoding qw(decode_utf8);

my $perl_encoded=decode_utf8($utf_encoded_string);

and then use JSON-enconde to encode the data


or:

2) instruct JSON to avoid converting a string if it's already
in UTF-8 by using is_utf8() from the Encode module.


You might want to look at the documentation of DBD::Mysql (I haven't used it in 
a while), and consult at the section regarding encodings., it seems like there 
might be flags that need to be raised to do the right encoding/decoding on 
serialization.

Cheers,

Francisco





On Oct 7, 2011, at 2:21 AM, jul@gmail.com wrote:

 Hi,
 
 I have installed and ran successfully the AutoCRUD plugin, I set up a
 mysql database tables to use UT8 charset, the charset in the ajax
 requests is utf-8, everything seems correct, except the data in the
 grids are double encoded, that means é instead of é.
 
 I am pretty sure that the data in the database are correct, and the
 json data are also correctly displayed (the raw data received contains
 the wrong characters). The double encoding seems then to appear in the
 View of AutoCRUD, that is just a Catalyst::JSON::View simply used
 without any customization.
 
 I have hacked around this AutoCRUD JSON view, and end up with a solution :
 - overload the encode_json method in the view to call directly
 JSON::XS without the utf8 call, ie a simple
 JSON::XS-new-encode($data);
 - and overload the process method in order to remove the  $json =
 Encode::encode($encoding, $json);
 
 In short : don't touch my data, they are already in utf8, just send
 them to the browser. It works, but I don't know why...
 
 It is probably a bad solution, as I can't imagine that
 Catalyst::JSON::View is wrong, but I wonder what is the correct way to
 do it.
 Couldn't it be a problem in DBIx::Class that does not correctly handle
 ut8 columns ?
 
 --
 Julien Gilles.
 
 ___
 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/

Francisco Obispo 
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
Key fingerprint = 532F 84EB 06B4 3806 D5FA  09C6 463E 614E B38D B1BE






___
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] RESTful response codes.

2012-02-23 Thread Francisco Obispo
I think your API needs to provide a mapping between HTTP response codes and 
your intended response codes.. that should be enough to keep them happy..


201- created
401- access denied
…

etc.


On Feb 23, 2012, at 3:25 PM, Bill Moseley wrote:

 Here's a discussion I'm having with a consumer of an API.
 
 For a RESTful service they would like the API to ALWAYS include a response 
 body that includes a { status_block = { status = 'success } }.I, of 
 course, point out that HTTP already provides a complete list of http status 
 codes.  But, they suggest that there might be a time when additional status 
 is needed.   I cannot think of case where that would happen.  PUT a resource 
 and it's either successful or not -- there's no gray area.
 
 The HTTP spec http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html seems 
 pretty clear.
 
 Can anyone think of a reason to always return a status?  Or better, any 
 references that would be more helpful or convincing than the spec listed 
 above?
 
 Thanks,
 
 -- 
 Bill Moseley
 mose...@hank.org
 ___
 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/

Francisco Obispo 
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] Catalyst and LDAP with sessions

2012-02-27 Thread Francisco Obispo
Hi Birger,

Once you've authenticated with LDAP, or with any backend, it is important that 
you store the session information somewhere.. Some people use a database, 
memcached, tmp file, or any other method.

That way, when the client comes with the next request, he will offer a cookie 
that can be verified for authorization purposes.

francisco



On Feb 27, 2012, at 2:30 AM, Birger Burkhardt wrote:

 Hello Peter,
 
 thank you for your reply. 
 
 no, i am not storing these credentials as i thought the module would do this. 
 I also tried to use the following package, but it doesn't work either:
 
 http://cpansearch.perl.org/src/BOBTFISH/Catalyst-Model-LDAP-FromAuthentication-0.02/README
 
 According to this changelog (see entry in Version 1.007):
 http://cpan.uwinnipeg.ca/htdocs/Catalyst-Authentication-Store-LDAP/Changes.html
 the user object has to be serialized and stored in the session. Do you have 
 an idea how to do this?
 
 Best regards,
 Birger
 
 
 On Sat, Feb 25, 2012 at 3:41 AM, Peter Karman pe...@peknet.com wrote:
 Birger Burkhardt wrote on 2/24/12 7:22 AM:
 
  After successful authentication, all further request
  should be executed via the credentials of the logged in user.
 
 
 are you somehow storing those credentials so that they persist over the life 
 of
 the session? The LDAP authn plugin does not do that for you, afaik. The
 credentials exist only for the life of that particular login HTTP request.
 
 or maybe I'm misunderstanding what you're trying to do?
 
  In the login controller the user is authenticated
  [...]
  # Get the username and password from form
  my $username =3D $c-request-params-{username};
  my $password =3D $c-request-params-{password};
 
  # If the username and password values were found in form
  if ($username  $password) {
  # Attempt to log the user in
  if ($c-authenticate({ username =3D $username,
 password =3D $password })) {
  [...]
 
  But when I do a new request from within another controller, i get an ldap
  error meaning the credentials are invalid:
 
  code in other controller:
  [...]
  my $ldapconn =3D $c-user-ldap_connection();
  my $mesg =3D $ldapconn-search( base =3D ou=3Dusers,dc=3Dexample,=
  dc=3Dcom,
  filter =3D (uid=3D*));
  my @entries =3D $mesg-sorted('uid');
  $c-stash(users =3D \@entries,);
  $c-stash(template =3D 'userList.tt2');
  [...]
 
 
 
 --
 Peter Karman  .  http://peknet.com/  .  pe...@peknet.com
 
 ___
 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/
 
 ___
 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/

Francisco Obispo 
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] Catalyst and LDAP with sessions

2012-02-27 Thread Francisco Obispo
You don't need to store the password... You just need to have a session id that 
has a short lifetime while you browse..  


You can tie that session id with an ip address for additional security .

Francisco

On Feb 27, 2012, at 1:06 PM, Birger Burkhardt sysde...@googlemail.com wrote:

 Hi Francisco,
 
 thank you for your reply. I already use sessions (FastMmap for Storage and 
 Cookies for State). I can login to the GUI via my LDAP credentials. But the 
 problem is: every further request has to be done with my personal 
 credentials. Therefore the password should be stored somewhere safe. I don't 
 want to store the userpassword in a unencrypted sessionvariable.
 
 Best regards,
 Birger
 
 
 On Mon, Feb 27, 2012 at 6:52 PM, Francisco Obispo fobi...@isc.org wrote:
 Hi Birger,
 
 Once you've authenticated with LDAP, or with any backend, it is important 
 that you store the session information somewhere.. Some people use a 
 database, memcached, tmp file, or any other method.
 
 That way, when the client comes with the next request, he will offer a cookie 
 that can be verified for authorization purposes.
 
 francisco
 
 
 
 On Feb 27, 2012, at 2:30 AM, Birger Burkhardt wrote:
 
  Hello Peter,
 
  thank you for your reply.
 
  no, i am not storing these credentials as i thought the module would do 
  this. I also tried to use the following package, but it doesn't work either:
 
  http://cpansearch.perl.org/src/BOBTFISH/Catalyst-Model-LDAP-FromAuthentication-0.02/README
 
  According to this changelog (see entry in Version 1.007):
  http://cpan.uwinnipeg.ca/htdocs/Catalyst-Authentication-Store-LDAP/Changes.html
  the user object has to be serialized and stored in the session. Do you have 
  an idea how to do this?
 
  Best regards,
  Birger
 
 
  On Sat, Feb 25, 2012 at 3:41 AM, Peter Karman pe...@peknet.com wrote:
  Birger Burkhardt wrote on 2/24/12 7:22 AM:
 
   After successful authentication, all further request
   should be executed via the credentials of the logged in user.
  
 
  are you somehow storing those credentials so that they persist over the 
  life of
  the session? The LDAP authn plugin does not do that for you, afaik. The
  credentials exist only for the life of that particular login HTTP request.
 
  or maybe I'm misunderstanding what you're trying to do?
 
   In the login controller the user is authenticated
   [...]
   # Get the username and password from form
   my $username =3D $c-request-params-{username};
   my $password =3D $c-request-params-{password};
  
   # If the username and password values were found in form
   if ($username  $password) {
   # Attempt to log the user in
   if ($c-authenticate({ username =3D $username,
  password =3D $password })) {
   [...]
  
   But when I do a new request from within another controller, i get an ldap
   error meaning the credentials are invalid:
  
   code in other controller:
   [...]
   my $ldapconn =3D $c-user-ldap_connection();
   my $mesg =3D $ldapconn-search( base =3D 
   ou=3Dusers,dc=3Dexample,=
   dc=3Dcom,
   filter =3D (uid=3D*));
   my @entries =3D $mesg-sorted('uid');
   $c-stash(users =3D \@entries,);
   $c-stash(template =3D 'userList.tt2');
   [...]
  
 
 
  --
  Peter Karman  .  http://peknet.com/  .  pe...@peknet.com
 
  ___
  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/
 
  ___
  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/
 
 Francisco Obispo
 email: fobi...@isc.org
 Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
 PGP KeyID = B38DB1BE
 
 
 ___
 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/
 
 ___
 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/
___
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] Catalyst and LDAP with sessions

2012-02-27 Thread Francisco Obispo
I see what the problem is now.

I would store it locally using a Memcached server, and would use the session_id 
as the key..

That way you can use the auto-expire feature, thus functioning like a key-ring.

In case you have multiple servers handling the requests, they can always 
connect to the memcached server and share the info.

Francisco

On Feb 27, 2012, at 1:43 PM, Birger Burkhardt wrote:

 Hi Francisco,
 
 sorry, but i think we are not talking about the same.
 1.) The GUI uses its own LDAP Bind credentals for Directory search purposes.
 2.) On user login, the catalyst app binds to LDAP via the credentials of the 
 user. On success, session is established, user is logged in. So far so good 
 everything working up to here.
 3.) After succesful login, the user performs some actions on the LDAP server 
 via the GUI. This has to be done with the (somewhere) stored credentials of 
 the user. In a new request, $c-user-ldap_connection tries to establish a 
 connection with the ldap-server and fails, because the password is gone. So 
 somewhere the password has to be stored ...
 
 Best regards,
 Birger
 
 
 On Mon, Feb 27, 2012 at 10:20 PM, Francisco Obispo fobi...@isc.org wrote:
 You don't need to store the password... You just need to have a session id 
 that has a short lifetime while you browse..  
 
 
 You can tie that session id with an ip address for additional security .
 
 Francisco
 
 On Feb 27, 2012, at 1:06 PM, Birger Burkhardt sysde...@googlemail.com wrote:
 
 Hi Francisco,
 
 thank you for your reply. I already use sessions (FastMmap for Storage and 
 Cookies for State). I can login to the GUI via my LDAP credentials. But the 
 problem is: every further request has to be done with my personal 
 credentials. Therefore the password should be stored somewhere safe. I don't 
 want to store the userpassword in a unencrypted sessionvariable.
 
 Best regards,
 Birger
 
 
 On Mon, Feb 27, 2012 at 6:52 PM, Francisco Obispo fobi...@isc.org wrote:
 Hi Birger,
 
 Once you've authenticated with LDAP, or with any backend, it is important 
 that you store the session information somewhere.. Some people use a 
 database, memcached, tmp file, or any other method.
 
 That way, when the client comes with the next request, he will offer a 
 cookie that can be verified for authorization purposes.
 
 francisco
 
 
 
 On Feb 27, 2012, at 2:30 AM, Birger Burkhardt wrote:
 
  Hello Peter,
 
  thank you for your reply.
 
  no, i am not storing these credentials as i thought the module would do 
  this. I also tried to use the following package, but it doesn't work 
  either:
 
  http://cpansearch.perl.org/src/BOBTFISH/Catalyst-Model-LDAP-FromAuthentication-0.02/README
 
  According to this changelog (see entry in Version 1.007):
  http://cpan.uwinnipeg.ca/htdocs/Catalyst-Authentication-Store-LDAP/Changes.html
  the user object has to be serialized and stored in the session. Do you 
  have an idea how to do this?
 
  Best regards,
  Birger
 
 
  On Sat, Feb 25, 2012 at 3:41 AM, Peter Karman pe...@peknet.com wrote:
  Birger Burkhardt wrote on 2/24/12 7:22 AM:
 
   After successful authentication, all further request
   should be executed via the credentials of the logged in user.
  
 
  are you somehow storing those credentials so that they persist over the 
  life of
  the session? The LDAP authn plugin does not do that for you, afaik. The
  credentials exist only for the life of that particular login HTTP request.
 
  or maybe I'm misunderstanding what you're trying to do?
 
   In the login controller the user is authenticated
   [...]
   # Get the username and password from form
   my $username =3D $c-request-params-{username};
   my $password =3D $c-request-params-{password};
  
   # If the username and password values were found in form
   if ($username  $password) {
   # Attempt to log the user in
   if ($c-authenticate({ username =3D $username,
  password =3D $password })) {
   [...]
  
   But when I do a new request from within another controller, i get an ldap
   error meaning the credentials are invalid:
  
   code in other controller:
   [...]
   my $ldapconn =3D $c-user-ldap_connection();
   my $mesg =3D $ldapconn-search( base =3D 
   ou=3Dusers,dc=3Dexample,=
   dc=3Dcom,
   filter =3D (uid=3D*));
   my @entries =3D $mesg-sorted('uid');
   $c-stash(users =3D \@entries,);
   $c-stash(template =3D 'userList.tt2');
   [...]
  
 
 
  --
  Peter Karman  .  http://peknet.com/  .  pe...@peknet.com
 
  ___
  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/
 
  ___
  List: Catalyst@lists.scsys.co.uk
  Listinfo: http://lists.scsys.co.uk

Re: [Catalyst] Requests get rendered twice.. TT-Template (View::HTML-process)

2012-03-06 Thread Francisco Obispo
Could it be your browser attempting to pre-fetch content?




On Mar 6, 2012, at 9:38 AM, Martin Gillmaier wrote:

 Hello to All!
 
 First, I am a perl-programmer and I am about to accomplish my first 
 catalyst-project.
 Catalyst is really nice and flexible, and I am happy to get used to it.
 However, I kindly like you ask you about an issue, that I just can't 
 understand and that is driving me mad:
 
 I view the debug output in the terminal/bash:
 $ script/expert_server.pl -r
 
 And each time I do a request to the browser, I see an output like this in my 
 bash: 
 
 [info] *** Request 14 (0.560/s) [1678] [Tue Mar  6 15:12:59 2012] ***
 [debug] Found sessionid 6f332e165af682b03622e1b74318d5a646e69a22 in cookie
 [debug] Restored session 6f332e165af682b03622e1b74318d5a646e69a22
 [debug] GET request for person/login from 192.168.56.1
 [debug] Path is person/login
 [debug] Rendering template person/login.tt
 [debug] Found sessionid 6f332e165af682b03622e1b74318d5a646e69a22 in cookie
 [debug] Restored session 6f332e165af682b03622e1b74318d5a646e69a22
 [debug] Response Code: 200; Content-Type: text/html; charset=utf-8; 
 Content-Length: 7723
 [info] Request took 0.077044s (12.980/s)
 .+---.
 | Action | Time  |
 ++---+
 | /auto  | 0.003336s |
 | /person/auto   | 0.002680s |
 | /person/login  | 0.000187s |
 | /end   | 0.006762s |
 |  - expert::View::HTML-process| 0.005926s |
 '+---'
 
 [info] *** Request 15 (0.600/s) [1678] [Tue Mar  6 15:12:59 2012] ***
 [debug] Found sessionid 6f332e165af682b03622e1b74318d5a646e69a22 in cookie
 [debug] Restored session 6f332e165af682b03622e1b74318d5a646e69a22
 [debug] GET request for person/login from 192.168.56.1
 [debug] Path is person/login
 [debug] Rendering template person/login.tt
 [debug] Found sessionid 6f332e165af682b03622e1b74318d5a646e69a22 in cookie
 [debug] Restored session 6f332e165af682b03622e1b74318d5a646e69a22
 [debug] Response Code: 200; Content-Type: text/html; charset=utf-8; 
 Content-Length: 7723
 [info] Request took 0.026152s (38.238/s)
 .+---.
 | Action | Time  |
 ++---+
 | /auto  | 0.002289s |
 | /person/auto   | 0.001404s |
 | /person/login  | 0.000108s |
 | /end   | 0.004584s |
 |  - expert::View::HTML-process| 0.003944s |
 '+---'
 
 So I have the same rendering process twice. Always and everywhere. Even the 
 install on the production-server (fastcgi) has the same problem.
 This leads to several problems, as you will know. Can you tell me where to 
 search for that issue or do you have an idea what the problem might be?
 
 Regards,
 Martin 
 
 ___
 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/

Francisco Obispo 
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] Noob hoping for help encoding mysql datetime fields for JSON

2012-03-15 Thread Francisco Obispo
try:


$_-created-ymd

created is most likely a DateTime object.

more info: perldoc DateTime

Francisco


On Mar 15, 2012, at 2:38 PM, Steve Seremeth wrote:

 Hello - 
 
 I am semi new to Perl and Catalyst.  I have walked through the Catalyst 
 tutorial a couple times and have also picked up a couple books and done much 
 googling that always seem to get me close but leave me hanging.
 
 Have been looking at tons of docs for catalyst::controller::rest and 
 catalyst::view::json amongst many others and can't find joy.
 
 Anyway -- I think I would be on the right track if someone solved this basic 
 inquiry:
 
 Working from this example:
 http://www.catalystframework.org/calendar/2009/22# An AJAX CRUD Interface 
 with Catalyst and jQuery
 
 which I have working fine, fwiw...
 
 How would you expose the created column from the db (schema came from here: 
 http://search.cpan.org/~bobtfish/Catalyst-Manual-5.9003/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod
  and is, in this example, a sqlite TIMESTAMP col) in the JSON generated by 
 the API controller's grid_POST method? 
 
 If I simply add the column to the API controller here:
 
 snip
 $data{rows}  = [
 map { +{
 id = $_-id,
 cell = [
 $_-id,
 $_-title,
 $_-rating,
 $_-author_list,
 $_-created,
 ]
 } } $paged_rs-all
 ];
 /snip
 
 The app throws this:
 
 Content-Type application/json had a problem with your
   request.
 
 ***ERROR***
 encountered object '2012-02-29T17:16:27', but neither
   allow_blessed enabled nor TO_JSON method available on it at
   /usr/local/share/perl/5.12.4/Catalyst/Action/Serialize/JSON.pm
   line 39.
 
 
 And I realize I'm not serializing the timestamp appropriately (and how data 
 with colons are bound to cause issues in JSON)...  but this simple thing is 
 what I haven't been able to solve.
 
 Any guidance greatly appreciated.
 
 Thanks - 
 
 Steve
 
 P.S.  For penance I will create some documentation of the working example and 
 check it in somewhere useful or host a living doc on one of my websites to 
 help others.
 
 Steve Seremeth | Release Engineer
 
 steve.serem...@dealer.com
 V : 877.327.8422 x 1391
 
 FOLLOW US: 
  
 
 
 ___
 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/

Francisco Obispo 
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] Error loading data from schema

2012-04-04 Thread Francisco Obispo
The error is because $c-model('dbms::ACCOUNT_VIEW') is not defined.

Did you create the view after creating the model? if so, try re-running the 
create script so it can pick up the changes.

Also, to avoid fatal errors, you should attempt to load the model first, and 
then send to the template a data structure only if it loads properly.



On Apr 4, 2012, at 7:28 AM, Kenneth S Mclane wrote:

 I am getting the following error: Caught exception in 
 dbms::Controller::AccountView-list Can't call method all on an undefined 
 value at /tmp/catalyst/dbms/script/../lib/dbms/Controller/AccountView.pm line 
 7. 
 
 this is the referenced sub: 
 
 sub list : Local { 
 my ($self, $c) = @_; 
 $c-stash(accounts = $c-model('dbms::ACCOUNT_VIEW')-all); 
 $c-stash(template = 'accountview/list.tt2'); 
 } 
 
 I have seen quite a few posts about this error but no real explanations of 
 what is causing the issue.  I created a view in the DB containing the data I 
 need to display on the page.  The error is occurring at this line: 
 $c-stash(accounts = $c-model('dbms::ACCOUNT_VIEW')-all); which I have 
 tried several different things. If I remove the -all I get no error and my 
 header row appears. I cannot find anything that tells me specifically what 
 this should be composed of. Any pointers to help figure this out are 
 appreciated.
 
 Regards 
 
 ___
 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/

Francisco Obispo 
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] How to sudo using the Authentication plugin

2012-05-12 Thread Francisco Obispo
No need to use a plugin, just use an authentication realm that requires no 
password.

Store the current user in a persistent session cookie and go back and forth 
with a single -authenticate method

Sent from my iPhone

On May 12, 2012, at 6:01 AM, Robert Rothenberg rob...@gmail.com wrote:

 
 Actually, I came across
 
  Catalyst::Plugin::Authentication::Credential::NoPassword
 
 in the latest version, which is apparently intended for the purpose of 
 sudoing.
 
 With a bit of fiddling, I was able to get it to work.
 
 
 ___
 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/

___
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] How to sudo using the Authentication plugin

2012-05-12 Thread Francisco Obispo
Using the standard Authentication plugin:

Plugin::Authentication
default_realm default
default
class SimpleDB
user_model MySchema::Login
id_field name
password_field password
password_type crypted
/default

admin
  class SimpleDB
  user_model MySchema::Login
  id_field name
  password_type none
/admin

/Plugin::Authentication


Then, whenever you need to 'sudo', just:

sub LoginAs : Private {
  my ( $self, $c ) = @_;

  my $user = $c-request-param('email') || q{};

  if ($user) {
my $real = $c-user-name;
$c-delete_session;
$c-session-{real_user} = $real;
$c-authenticate( { name = $user }, 'admin' );
$c-response-redirect('/account/manage');
  }

  return 1;

}


Hope that helps.




On May 12, 2012, at 9:06 AM, Francisco Obispo wrote:

 No need to use a plugin, just use an authentication realm that requires no 
 password.
 
 Store the current user in a persistent session cookie and go back and forth 
 with a single -authenticate method
 
 Sent from my iPhone
 
 On May 12, 2012, at 6:01 AM, Robert Rothenberg rob...@gmail.com wrote:
 
 
 Actually, I came across
 
 Catalyst::Plugin::Authentication::Credential::NoPassword
 
 in the latest version, which is apparently intended for the purpose of 
 sudoing.
 
 With a bit of fiddling, I was able to get it to work.
 
 
 ___
 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/
 
 ___
 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/

Francisco Obispo 
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] Vagrant / Developing with VM / NFS performance

2012-05-14 Thread Francisco Obispo
What I usually do (on MacOS) is use SSHFS, with ExpanDrive ($25),

It works very nicely, the restarter doesn't complain, and it works with 
multiple OSes.

Francisco


On May 14, 2012, at 5:04 AM, Drew Taylor wrote:

 Hi Toby,
 
 I'm not (yet) using a VM with my new job, but at my last position I
 was running Parallels which hosted a VM running FreeBSD. In order to
 be able to use my OS X text editor of choice, I hosted the files on
 the OS X side and exported via NFS to the FreeBSD VM. The performance
 was good enough and it solved my problem. The catalyst restarter
 didn't seem to have any problems with this approach, though it
 sometimes took a couple seconds to see file changes.
 
 I suspect when I do begin using a local VM I'll take the same
 approach, though this time it will be using MacVIM instead of
 TextMate. :)
 
 Thanks,
 Drew
 
 On Mon, May 14, 2012 at 9:53 PM, Tobias Kremer tobias.kre...@gmail.com 
 wrote:
 I'm playing around with Vagrant[1] to manage my development VMs and
 I'm running into some NFS-troubles and just wanted to hear if and how
 you guys are developing with a guest OS.
 
 The thing is that Vagrant by default configures the VM to export a
 shared directory (where my Catalyst app lives) from the host OS (OS X
 in my case) to the guest VM (Debian). I'm using the alternative NFS
 mount option because VirtualBox's shared folder support is known to be
 super slow. Problem is, Catalyst::Restarter doesn't pick up changes to
 my files. I suppose this is due to NFS doing attribute caching. If I
 turn this off (with noac in the NFS mount options), the Catalyst
 server picks up the changes more quickly but it also takes a full
 minute to start (as opposed to 3-4 seconds when the files are local).
 
 Having the app locally on my host and exporting it into the VM feels
 more natural to me, but the performance issues really make this a
 deal-breaker. Does anyone have any advice on how to improve things?
 How do you share your files between your VM and your host system?
 
 Thanks a lot!
 --Toby
 
 
 [1] http://vagrantup.com/
 
 ___
 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/
 
 
 
 -- 
 Opera2Parliament - a 3 day bike ride to support Lymphoma Australia.
 Please consider donating using the link below.
 http://lymphomafundraising.org.au/opera2parliament_2012
 
 ___
 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/

Francisco Obispo 
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] Do not save session under certain conditions

2012-05-21 Thread Francisco Obispo
can you get the monitor to initiate a session and re-use it?

That way, you can monitor other portions of the site and not just a no-op URL.


On May 21, 2012, at 8:49 AM, Duncan Garland wrote:

 Hi,
  
 We’ve got some monitoring software installed which is accessing the home page 
 of my catalyst app every couple of seconds and flooding the sessions table.
  
 I can recognise the monitor based on the user agent, so I’d like to stop it 
 saving the session. Something like:
  
 if ($c-request-user_agent =~ m/HTTP-Monitor/ ) {
   Don’t save the session.
 }
  
 What’s the best way to do this?
  
 Thanks
  
 Duncan
 ___
 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/

Francisco Obispo 
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] Best-practices question: caching a search

2012-09-15 Thread Francisco Obispo
Some databases provide means to return a specific set of records, and even an 
offset,

In DBIx::Class, when you search, you can actually specify the page as an 
option [1], 

if you're not querying against a database, you might want to use something like 
Memcached or the like to store your resultset and paginate accordingly.




[1] 
http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/ResultSet.pm#ATTRIBUTES


On Sep 15, 2012, at 11:41 AM, will trillich will.trill...@serensoft.com wrote:

 User enters some search parameters (location, date-range, etc). Gets 500 
 results which we paginate. Once the user pages to the item of interest, 
 he/she can then click thru to edit or see more detail.
 
 It'd be nice to have 'breadcrumbs' that take the user back to that page of 
 that search.
 
 What's the recommended way of doing that?
 
 A) stash the whole recordset into the session (can you even 
 serialize/deserialize a recordset object?)
 
 B) stash the search params and page-no and page-size and recreate the 
 recordset each time
 
 C) ...something else?
 
 
 
 -- 
  Will Trillich :: 812.454.6431
 
 “Waiting for perfect is never as smart as making progress.”  -- Seth Godin
 ___
 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/

Francisco Obispo 
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] Catalyst DBIX stash, getting at the data

2012-10-15 Thread Francisco Obispo
You don't need to store the data in $c-session.

if you're using Catalyst::View::TT, you just be able to:

$c-stash-{project}=$c-model('DB::Project')-find($project_id);

and then in your view:

h3[% project.project_name %]/h3

regards



On Oct 15, 2012, at 12:28 PM, Tadhg tadhg.da...@gmail.com wrote:

 Catalyst Controller Code:
 sub Project :Local {
 my ($self, $c, $project_id) = @_;
 
 $c-stash(projects = [$c-model('DB::Project')-find({'Project_id', 
 $project_id })]);
 die App $project_id not found! if !$c-stash-{projects}; # 
 This all works fine
 
 # This is a guess and doesn't work ;-)
 $c-session{Project} = $c-stash-{projects}-project_name;
 # Where project_name is an accessor in the DBIx result set.
 }
 

Francisco Obispo 
Director of Applications and Services - ISC
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] I'm loosing the plot here? - Controller behaviour that makes no sense

2012-10-30 Thread Francisco Obispo
I have found with time that enjoying a good meal is the best debugging tool.

Sent from my iPhone

On Oct 30, 2012, at 1:27 PM, Craig Chant cr...@homeloanpartnership.com wrote:

 I had a hunch, so I uploaded the template to 'root' and bingo it found it
  
 so this in MyApp.pm isn't working...
  
 'View::HTML' = {
 #Set the location for TT files
 INCLUDE_PATH = [
 __PACKAGE__-path_to( 'root', 'src' ),
 ],
 }
  
 So does this attribute only work for TT template tool kit?
  
 What's the flag for HTML::Template ? (this is the problem I'm having trying 
 to follow the tutorial!!!)
  
 Also I now get the following error
  
 Caught exception in Members::View::HTML-process HTML::Template : Attempt to 
 set nonexistent parameter 'base' - this parameter name doesn't match any 
 declarations in the template file : (die_on_bad_params = 1) at 
 C:/Perl/site/lib/Catalyst/View/HTML/Template.pm line 99
  
 This is what I have in my HTML View...
  
 package Members::View::HTML;
 use strict;
 use base 'Catalyst::View::HTML::Template';
 __PACKAGE__-config(
 TEMPLATE_EXTENSION = '.tp',
 render_die = 1,
 );
 1;
 So how do I set the path for templates when using HTML::Template, why is it 
 falling over with the auto generated code in the View? And why isn't the 
 browser showing changed content when refreshed?
  
 From: Craig Chant [cr...@homeloanpartnership.com]
 Sent: 30 October 2012 20:08
 To: The elegant MVC web framework
 Subject: RE: [Catalyst] I'm loosing the plot here? - Controller behaviour 
 that makes no sense
 
 I've done the tutorial Debian VM walkthrough.
  
 I stopped at DBIC / CRUD, and I keep referring back to the tutorial, but it's 
 very hard to follow when it is using examples for a templating system / ORM / 
 CRUD and OS i'm not using.
  
 I'm also convinced there is a caching issue, how can I refresh the browser on 
 a controller/action i've changed the response-body of and still get the old 
 output?
  
 Please advise if there is some form of caching in Catalyst so I can turn it 
 off.
  
 I'm still unable to get the template to work, regardless of what I call it!
  
 here is the output from the server..
  
 [debug] Debug messages enabled
 [debug] Statistics enabled
 [debug] Loaded plugins:
 ..
 | Catalyst::Plugin::ConfigLoader  0.30   |
 | Catalyst::Plugin::Session  0.35|
 | Catalyst::Plugin::Session::State::Cookie  0.17 |
 | Catalyst::Plugin::Session::Store::FastMmap 0.16   |
 | Catalyst::Plugin::StackTrace  0.11 |
 ''
 [debug] Loaded dispatcher Catalyst::Dispatcher
 [debug] Loaded engine Catalyst::Engine
 [debug] Found home C:\Websites\members
 [debug] Loaded Config C:\Websites\members\members.conf
 [debug] Session Store file: C:\Users\admin\AppData\Local\Temp\1\members\
 ession_data
 [debug] Loaded components:
 .-+--.
 | Class   | Type |
 +-+--+
 | Members::Controller::Login  | instance |
 | Members::Controller::Root   | instance |
 | Members::Model::DBI | instance |
 | Members::Model::Members | instance |
 | Members::Model::Sql | class|
 | Members::View::HTML | instance |
 '-+--'
 [debug] Loaded Private actions:
 .--+--+--.
 | Private  | Class| Method   |
 +--+--+--+
 | /default | Members::Controller::Root| default  |
 | /end | Members::Controller::Root| end  |
 | /index   | Members::Controller::Root| index|
 | /begin   | Members::Controller::Root| begin|
 | /login/index | Members::Controller::Login   | index|
 | /login/login | Members::Controller::Login   | login|
 '--+--+--'
 [debug] Loaded Path actions:
 .-+--.
 | Path| Private  |
 

Re: [Catalyst] Session::Store::DBIC and session table (postgres)

2012-11-14 Thread Francisco Obispo
Did you use the dbicdump script (or myapp_create.pl model) command to create 
the schema files?

I would suggest you look to see how the 'sessions' table was created and use 
that as the name for the relation. 

regards


On Nov 14, 2012, at 7:07 AM, Fernan Aguero fernan.agu...@gmail.com wrote:

 Of course, I can reproduce succesfully what DBIC is trying to do on the Pg 
 terminal. E.g. for the following error:
 
 [error] Scheduler: Error executing /cron/remove_sessions: 
 DBIx::Class::ResultSet::delete(): DBI Exception: DBD::Pg::st execute failed: 
 ERROR:  relation sessions does not exist [for Statement DELETE FROM 
 sessions WHERE ( id = ? ) with ParamValues: 
 1='session:c7d07ff1ec06ebf2c6fc37c3cb8f36b117053384'] 
 
 I can fix the query and run it (using the same userid/credentials of the 
 catalyst app) without issues:
 
 tcsnp3= DELETE FROM webapp.sessions WHERE ( id = 
 'session:c7d07ff1ec06ebf2c6fc37c3cb8f36b117053384' );
 DELETE 1
 
 

Francisco Obispo 
Director of Applications and Services - ISC
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] Session::Store::DBIC and session table (postgres)

2012-11-14 Thread Francisco Obispo
Use:

$c-model('GUS::WebappSession') as the name.

or in the config:


Plugin::Session
  dbic_class GUS::WebappSession
  id_field id
  storage_field session_data
  expires_field expires
  need_commit 0
  expires 3600
  verify_address 1
/Plugin::Session


francisco


On Nov 14, 2012, at 12:51 PM, Fernan Aguero fernan.agu...@gmail.com wrote:

 
 The new classes are slightly different:
 lib/GUS/Webapp/Sessions.pm (old)
 lib/GUS/Result/WebappSession.pm (new)

Francisco Obispo 
Director of Applications and Services - ISC
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] Generating a large XML document (KML file) from a database

2012-11-26 Thread Francisco Obispo
Use the -write() methos in catalyst and  XML::Witer

Sent from my iPhone

On Nov 26, 2012, at 8:58 AM, Robert Rothenberg rob...@gmail.com wrote:

 I need to output a large XML file (actually, a KML file of points) from a
 database.
 
 I can't find any documentation for Catalyst::View::XML::Generator, or even
 decent documentation for XML::Generator, on how to do this.
 
 It would appear to expect me to put the entire structure in the stash, which
 I don't want to do, as it could contain thousands of points.
 
 Ideally I would pass an iterator function and it would do the rest.
 
 
 
 
 
 
 ___
 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/

___
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] Generating a large XML document (KML file) from a database

2012-11-26 Thread Francisco Obispo
XML::Writer



Sent from my iPhone

On Nov 26, 2012, at 9:23 AM, Francisco Obispo fobi...@isc.org wrote:

 Use the -write() methos in catalyst and  XML::Witer
 
 Sent from my iPhone
 
 On Nov 26, 2012, at 8:58 AM, Robert Rothenberg rob...@gmail.com wrote:
 
 I need to output a large XML file (actually, a KML file of points) from a
 database.
 
 I can't find any documentation for Catalyst::View::XML::Generator, or even
 decent documentation for XML::Generator, on how to do this.
 
 It would appear to expect me to put the entire structure in the stash, which
 I don't want to do, as it could contain thousands of points.
 
 Ideally I would pass an iterator function and it would do the rest.
 
 
 
 
 
 
 ___
 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/
 
 ___
 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/

___
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] Generating a large XML document (KML file) from a database

2012-11-26 Thread Francisco Obispo
Ok, Now that I'm on my computer, I can write a decent response:

I had a similar problem with generating a fairly large CSV file.

you don't want to store this in a stash entry because it can get very large, 
and 
even it you were using a temp file to write the data to, the user
would have to wait until the file is fully written and then
transferred, which could translate to unresponsiveness.

I decided to use catalyst -write() method to output directly
to the socket, and generate the CSV on the fly.

On your example, you could use XML::Writer which allows you to 
generate XML on the fly via:

  $c-write( $writer-startTag('hello',(attribute='value')) );
  $c-write( $writer-characters('World!') );
  $c-write( $writer-endTag()) ;


Will generate to the output buffer:

  hello attribute='value'World!/hello

You will need to generate a header with the right content type before you
start sending out stuff to your output buffer:

 $c-response-content_type('text/comma-separated-values');

 $c-res-header( 'Content-Disposition',
 qq[attachment; filename=download.csv] );


This is how I generated mine for the CSV, you would have to fill the 
right content_type: application/xxx?

And the name of the file in the Content-Disposition section.

Notice that you will not provide a Content-Length header, so the
client will not know how much data you will be sending until its 
done.

And catalyst won't know that you actually sent anything so to avoid
Catalyst rendering the template, just set the body to something, in
my case I did:

$c-response-body(qq{\n});

I know there are some methods to tell Catalyst to end instead
of generating the template, but I couldn't get them to work properly.


Regards


Francisco Obispo 
Director of Applications and Services - ISC
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE

On Nov 26, 2012, at 8:58 AM, Robert Rothenberg rob...@gmail.com wrote:

 I need to output a large XML file (actually, a KML file of points) from a
 database.
 
 I can't find any documentation for Catalyst::View::XML::Generator, or even
 decent documentation for XML::Generator, on how to do this.
 
 It would appear to expect me to put the entire structure in the stash, which
 I don't want to do, as it could contain thousands of points.
 
 Ideally I would pass an iterator function and it would do the rest.
 
 
 
 
 
 
 ___
 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/


___
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] Generating a large XML document (KML file) from a database

2012-11-26 Thread Francisco Obispo
Great!

I'll see if I can do the same with the CSV module that I wrote.

regards,

Francisco Obispo 
Director of Applications and Services - ISC
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE

On Nov 26, 2012, at 11:05 AM, Robert Rothenberg rob...@gmail.com wrote:

 Thanks. I guessed that was something I needed to do.
 
 One note: when initializing a new XML::Writer object, you can pass $c-res
 as the OUTPUT, and XML::Writer will do the right thing, apparently, since it
 has a print method.
 
 Also, sending an empty string to body
 
  $c-res-body()
 
 is enough.
 
 
 
 On 26/11/12 17:54 Francisco Obispo wrote:
 


___
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] DB values that change very rarely

2013-01-11 Thread Francisco Obispo
You really don't want this in DBIx::Class, you want fine grain control of when 
to fetch from the database, etc. Anyone can build their layer on top of 
DBIx::Class to implement caching.

Using something like memcached would save you some database hits, you can 
either set the values to expire at a specified time / number of seconds, or you 
can set/delete keys as part of the procedures at insert/update/delete on the 
database.

If you you Postgresql, you can actually take advantage of PgPool, which will 
give you the option to enable a caching layer… 

Francisco



On Jan 11, 2013, at 4:01 AM, Alexander Hartmaier 
alexander.hartma...@t-systems.at wrote:

 On 2013-01-10 16:15, Jesse Sheidlower wrote:
 In one of my apps, I have a number of tables that contain values that
 change very rarely. Think of something like a category table in an
 e-commerce app--they're mostly static, but every now and then you need
 to change or add or delete a category. These occasional changes do,
 however, need to be made by a (privileged) user, rather than a
 developer, so I can't just put them in the config file and edit this and
 restart the app when necessary. Since I don't know when they might
 change, I don't know how I could cache them, because when a change is
 made it needs to take effect immediately.
 
 These tables are used on almost every request. The result is that most
 of my controllers end up looking something like this, or having
 something like this at the end of them:
 
 sub add : Local {
   my ( $self, $c ) = @_;
 
   $c-stash-{title} = 'Add a new lemma';
 
   $c-stash-{batches} = $c-model('WordsDB::Batch')-search();
   $c-stash-{statuses} = $c-model('WordsDB::Status')-search();
   $c-stash-{regions} = $c-model('WordsDB::Region')-search();
   $c-stash-{subjects} = $c-model('WordsDB::Subject')-search();
 
   $c-stash-{template} = 'add.tt';
 }
 
 This means that almost every page generation hits the database a whole bunch 
 of
 unnecessary times, and that all of my controllers are cluttered.
 
 This must be a fairly common problem. What's the best way to deal with
 it--both the desire to persist what is mostly static data, and to keep
 my controllers clean?
 
 Thanks.
 
 Jesse Sheidlower
 
 ___
 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/
 I'd LOVE to see that functionality in DBIx::Class::Schema so prefetches
 use the cached values to populate the related data instead of hitting
 the database.
 
 --
 Best regards, Alexander Hartmaier
 
 
 ***
 T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
 Handelsgericht Wien, FN 79340b
 ***
 Notice: This e-mail contains information that is confidential and may be 
 privileged.
 If you are not the intended recipient, please notify the sender and then
 delete this e-mail immediately.
 ***
 
 ___
 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/

Francisco Obispo 
Director of Applications and Services - ISC
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] May be asynchronous communication between Catalyst applications

2013-02-22 Thread Francisco Obispo
I would probably use a message queue.

Have you looked into RabbitMQ ?

App 1 would be the producer, and you would have a consumer, responsible for 
performing the operation on App 2.

 



On Feb 22, 2013, at 10:40 PM, linuxsupport lin.supp...@gmail.com wrote:

 Hi All,
 
 I need your help on the following scenario.
 
 I have 2 Catalyst apps, say App 1 and App 2
 
 Now, User access the App 1 and request something, App 1 then connect to App 2 
 for the information but getting that information takes sometime lets say 15 
 minutes.
 
 What I want to implement is that, App 1 checks the status of request which 
 was sent to App 2 every 2 minutes and once completed it gets the response.
 
 Checking the status every 2 minutes can be controlled from the browser using 
 Ajax, client side code can send status request to App 1, App 1 can forward 
 this request to App 2, but how App2 will maintain the state and keep the job 
 running even if App 1 gets disconnect from App 2.
 
 Is there something similar to Ajax for Catalyst to Catalyst communication?
 
 I can create a table on App 2 and store the request, and run a cron script to 
 process the request and update table with result, App 1 can then pull the 
 information from that table but looking for more elegant way to do it.
 
 Thanks
  
 ___
 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/

Francisco Obispo 
Director of Applications and Services - ISC
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] Catalyst::Controller::REST and Serializer/Deserializer

2013-02-24 Thread Francisco Obispo

This is what I usually do:

1) install Catalyst::View::JSON

2) Add the view to your app: ./script/myapp_create.pl view JSON JSON

3) in the .conf file add:

View::JSON
  allow_callback 0
  expose_stash data
/View::JSON

4) in the controller:

If the whole controller (.pm) will return JSON data, just add this to the end:


sub end : Private {
  my ( $self, $c ) = @_;
  if ( $c-stash-{data} ) {
$c-forward('View::JSON');
return 1;
  }

  return;
}


if you want to selectively send it in a method:


sub hello : Local {
  my ($self,$c) = @_;

  my $data={ hello = 'world!'};

  $c-stash-{data} = $data;
  $c-forward('View::JSON');

  return 1;

};


Hope this helps










On Feb 24, 2013, at 11:13 PM, Jean-Marc Choulet jm130...@gmail.com wrote:

 Hello,
 
 I'm new to Catalyst and I've certainly a stupid question... I use a 
 Catalyst::Controller::REST to implement a web service. My question is : How 
 can I force a application/json content-type response when I ask my ws with FF 
 or Chrome... ?
 
 Thanks
 
 Jean-Marc
 
 ___
 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/

Francisco Obispo 
Director of Applications and Services - ISC
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] Using the Catalyst Makefile to install

2013-03-07 Thread Francisco Obispo
The installer uses Module::Install

So basically:

1) lib/ is installed in: /usr/local/lib/perl5
2) script/* becomes /usr/local/bin/*
3) man pages are usually installed in /usr/local/share/man/man3/

etc.

perldoc Module::Install for more info ;-)


dh-make-perl if you want to make a debian/ubuntu package



On Mar 7, 2013, at 2:56 PM, Alejandro Imass alejandro.im...@gmail.com wrote:

 Hi,
 
 What is the canonical way to use the provided Makefile to deploy
 Catalyst apps. Up until now I've only used to mainatin the
 dependencies and use make and make test but I have never used make
 install.
 
 I read through the Makefile and it's obvious that it will install all
 modules where they belong, but where do the resto of the files go??
 Example, the /root directory, the config file, etc.
 
 Is there a document that talks about this?
 
 Thanks,
 
 --
 Alejandro Imass
 
 ___
 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/

Francisco Obispo 
Director of Applications and Services - ISC
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] Using the Catalyst Makefile to install

2013-03-07 Thread Francisco Obispo
They are installed by default under the lib/ directory, I'm not a big fan of 
that setup, so what we usually do (in debian), we setup a custom package that 
does the magic that we need, including the nginx setup, etc.

Module::Install lets you do some limited configuration, but if you're looking 
to customize it, you're better off with a custom distribution package.

Module::Install also gives you the ability to generate a PAR (Perl Archive), 
and a tar distribution (make tardist). 

On FreeBSD for example I usually install my catalyst apps as:

perl Makefile.PL INSTALL_BASE=/path/to/myapp

that way I have everything enclosed in one location (FreeBSD package manager is 
a nightmare)

:-)


On Mar 7, 2013, at 8:50 PM, Alejandro Imass alejandro.im...@gmail.com wrote:

 On Thu, Mar 7, 2013 at 6:03 PM, Francisco Obispo fobi...@isc.org wrote:
 The installer uses Module::Install
 
 So basically:
 
 1) lib/ is installed in: /usr/local/lib/perl5
 2) script/* becomes /usr/local/bin/*
 3) man pages are usually installed in /usr/local/share/man/man3/
 
 etc.
 
 perldoc Module::Install for more info ;-)
 
 
 
 So the source, static files and the config file, etc. need to be
 installed manually ??
 
 BTW: saludes!
 
 --
 Alejandro Imass
 
 ___
 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/

Francisco Obispo 
Director of Applications and Services - ISC
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] Using the Catalyst Makefile to install

2013-03-10 Thread Francisco Obispo
Yes,

By we I mean: Internet Systems Consortium (ISC), internal applications.

We use debian in some of our platforms, and we package our software into a 
private repo.

Apologies for the confusion ;-)

On Mar 10, 2013, at 3:00 PM, gregor herrmann gre...@debian.org wrote:

 I'm not aware of anything like this in Debian's catalyst package; so
 I guess Francisco meant running under Debian. Sorry :)
 
 
 Cheers,
 gregor (Debian Perl Group)

Francisco Obispo 
Director of Applications and Services - ISC
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] has_many but no left join?!

2013-06-18 Thread Francisco Obispo
That's going to generate a whole bunch of queries (1 per row), unless you 
include it in a prefetch attribute to the first call:

foreach my $index_status 
($c-model('MyApp::IndexStatus')-search(undef,{prefetch='old_statuses'})) {
# Generate the HTML here with columns from $index_status...
foreach my $old_status ($index_status-old_statuses-all) {
# Generate the HTML here for any $old_status records...
}
}

On Jun 18, 2013, at 10:44 AM, Robert Wohlfarth rbwohlfa...@gmail.com wrote:

 On Tue, Jun 18, 2013 at 11:54 AM, Stephen Shorrock 
 stephen.shorr...@gmail.com wrote:
 snip
 then (in Cat app)
 $c-model('MyApp::IndexStatus')-search_related('old_statuses');
 
 produces SQL something like:
 SELECT me.myindex, me.myoldindex, me.mystatus FROM index_statuses me  JOIN 
 index_statuses old_statuses ON old_statuses.myindex = me.myoldindex:
 
 even adding {join_type='LEFT'} to the arguments of has_many does not produce 
 a left join.
 
 It looks like the code asks for all MyApp::IndexStatus with matching 
 old_statuses records. That translates into an INNER JOIN.
 
 If you're looking for all MyApp::IndexStatus records along with any related 
 old_statuses records, try something like this:
 foreach my $index_status ($c-model('MyApp::IndexStatus')-all) {
 # Generate the HTML here with columns from $index_status...
 foreach my $old_status ($index_status-old_statuses-all) {
 # Generate the HTML here for any $old_status records...
 }
 }
 
 -- 
 Robert Wohlfarth
 ___
 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/

Francisco Obispo 
Director of Applications and Services - ISC
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] has_many but no left join?!

2013-06-18 Thread Francisco Obispo
Again,

I think you want to use 'prefetch'.



On Jun 18, 2013, at 11:09 AM, Robert Wohlfarth rbwohlfa...@gmail.com wrote:

 Ah, well then I answered the wrong question :)
 
 How about this code?
 $c-model('MyApp::IndexStatus')-search({'old_statuses.id' = 
 undef},{join='old_statuses'})
 
 

Francisco Obispo 
Director of Applications and Services - ISC
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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] has_many but no left join?!

2013-06-18 Thread Francisco Obispo
Prefetch is really smart, and in the newer versions of DBIx::Class is even 
capable of taking multiple relations without the risk of duplicating rows.

  
http://search.cpan.org/~frew/DBIx-Class-0.08205/lib/DBIx/Class/ResultSet.pm#prefetch

Basically as I understood the problem, you want to fetch a row, and the 
possible relation, as a LEFT JOIN would provide. But you always want the main 
relation to return a value even if the join is NULL.

Prefetch will do that without complicated use cases.

Francisco


On Jun 18, 2013, at 11:19 AM, Stephen Shorrock stephen.shorr...@gmail.com 
wrote:

 I think Robert has cracked it, but why prefetch?
 
 

Francisco Obispo 
Director of Applications and Services - ISC
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
PGP KeyID = B38DB1BE


___
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: Out of office 10/4-10/5 (was: Out of office 10/4-10/5 (was: Out of office 10/4-10/5 (was: Out of office 10/4-10/5 (was: Out of office 10/4-10/5 (was: Out of office 10/4-10/5 (was: Out of office 10

2013-08-09 Thread Francisco Obispo
Steve needs to learn how to configure his email vacation program

Sent from my iPhone

On Aug 9, 2013, at 6:51 PM, Steve st...@matsch.com wrote:

 Thank you for your email.  I will be out of the office Thursday and Friday, 
 returning Monday the 8th.  I will respond to your email at that time.  Please 
 call our office for any immediate concerns: 616-459-0782.
 
 -- 
 Steve Schafer
 Matsch Systems
 Phone: 616-477-9629
 Mobile: 616-304-9440
 Email: st...@matsch.com
 Web: http://www.matsch.com/
 
 ___
 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/
___
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/