Re: [Catalyst] MySQL server has gone away

2007-04-28 Thread Oleg Pronin


 That /is/ what we are talking about - unless MySQL cannot
 tell you that the database connection has evaporated while in
 transaction context.



$dbh can tell you. while in transaction $dbh-{AutoCommit} is off.
___
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] MySQL server has gone away

2007-04-28 Thread Peter Edwards
I've seen this problem under Red Hat Enterprise Linux 4 and Mysql 3.23 and
suspect it was down to incorrect configuration of full/half duplex on the
Network Interface Card against the router, possibly combined with a Linux
Ethernet driver bug. Some useful pointers here
http://dev.mysql.com/doc/refman/5.0/en/communication-errors.html
http://dev.mysql.com/doc/refman/5.0/en/gone-away.html

We put in code to wrap the DBI calls, detect the error and re-run the
transactions in that case. You can detect it with $sth-execute() fails and
$sth-errstr() =~ m/gone away/i

For lookups we use tie() through a locking wrapper to DB_File, generating
the DBM databases from master data in the database.

Regards, Peter
Dragonstaff Limited  http://www.dragonstaff.com 

 Oleg Pronin wrote:
  One can say that it is a very rare situation. I can tell you that in
  production environment (about 1.000.000 hits per day) it happens
 every
  day several times. Some users just see an error, some lost their
 data.
  This is just not always visible to you.
 The OP may find a requirement to incorporate a transaction model
 (explicit start txn/commit/rollback) to solve this problem in MySQL;
 which is what they'd have to do for Oracle or Postgres or Rdb. I'd
 hope
 that MySQL reports a transaction failure when the database connection
 evaporates. This would allow a retry on the failed transaction.
 However,
 it may be that the Catalyst Controller / View design/implementation is
 only what would ordinarily be flat file accesses that use SQL
 instead of
 keyed-access flat files. If that's the case, wrapping a transaction
 around each of these SQL prepare/execute pairs will be a substantial
 performance hit.



___
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] perl -d myapp_server.pl : how ?

2007-04-28 Thread Kieren Diment

http://dev.catalyst.perl.org/wiki/DebugSample

On 27/04/07, Dami Laurent (PJ) [EMAIL PROTECTED] wrote:


 Hello,

The question was already asked in the list, but I can't remember of any
satisfying answer.

Did anybody succeed in running the standalone server in debug mode ?

Seems that the server main loop, waiting for HTTP events, is not
compatible with the debugger loop waiting for keyboard events.

I'm able to set breakpoints after Catalyst has loaded all modules and just
before entering MyApp-run($port, $host ...) .. but the breakpoints never
actually break.

Thanks in advance, L. Dami

PS I'm running perl v5.8.8 built for MSWin32-x86-multi-thread, Binary
build 819 [267479] provided by ActiveState


___
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/


___
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] CC::FormBuilder woes

2007-04-28 Thread Juan Camacho

On 4/28/07, Richard Jones [EMAIL PROTECTED] wrote:

Juan Camacho wrote:



 Maybe there is an unexpected stash issue. Try to create a minimalist
 example (with form, template and controller code) and post here.
OK, will do. But would it be easier if I posted the output of
Dumper.dump(form)? Also just realised I'm using CCF 0.02 - could that
affect it (can't update it at the moment). Changes file doesn't suggest
it would.
--


No, 0.03 shouldn't make much a difference, but at least on your
development server, I would suggest using it locally. In fact, the
quickest option is to just modify the test files under t/lib and
t/root to come up with some scenario that breaks the 'perl -Mblib
t/01-basic.t' test.

___
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/


[Catalyst] Debug/Warning messages for duplicate files under M/V/C directorios

2007-04-28 Thread Eden Cardim

Greetings everyone,

I stumbled onto an annoying problem this week, a co-worker of mine
somehow managed to duplicate the lib tree into lib/MyApp/Controller
which, of course caused the app to crash before I got the initial
debug messages, since the log only flushes after the entire app loads,
so it took me quite a while to figure it out. While I was whining
about the problem in #catalyst, mst suggested there should be helpful
debug messages to deal with this kind of issue. Simply flushing the
log as each component loads doesn't help a lot since the duplicate
file can be loaded before the real one, in that case, the 'redefine'
warnings aren't very helpful. Ideally, the debug messages should
report which two components tried to load the same thing. I've done
something like this by walking the symtable every time a component
loads, but that sounds like overkill. Any thoughts on how to get this
done?

--
Eden Cardim
Instituto Baiano de Biotecnologia
Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas
Laboratório de Bioinformática

___
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] MySQL server has gone away

2007-04-28 Thread Oleg Pronin

$sth-errstr() =~ m/gone away/i

this is the first method that i used. (per database string checking)
and this is i'm going away from.


2007/4/28, Peter Edwards [EMAIL PROTECTED]:


I've seen this problem under Red Hat Enterprise Linux 4 and Mysql 3.23 and
suspect it was down to incorrect configuration of full/half duplex on the
Network Interface Card against the router, possibly combined with a Linux
Ethernet driver bug. Some useful pointers here
http://dev.mysql.com/doc/refman/5.0/en/communication-errors.html
http://dev.mysql.com/doc/refman/5.0/en/gone-away.html

We put in code to wrap the DBI calls, detect the error and re-run the
transactions in that case. You can detect it with $sth-execute() fails
and
$sth-errstr() =~ m/gone away/i

For lookups we use tie() through a locking wrapper to DB_File, generating
the DBM databases from master data in the database.

Regards, Peter
Dragonstaff Limited  http://www.dragonstaff.com

 Oleg Pronin wrote:
  One can say that it is a very rare situation. I can tell you that
in
  production environment (about 1.000.000 hits per day) it happens
 every
  day several times. Some users just see an error, some lost their
 data.
  This is just not always visible to you.
 The OP may find a requirement to incorporate a transaction model
 (explicit start txn/commit/rollback) to solve this problem in MySQL;
 which is what they'd have to do for Oracle or Postgres or Rdb. I'd
 hope
 that MySQL reports a transaction failure when the database
connection
 evaporates. This would allow a retry on the failed transaction.
 However,
 it may be that the Catalyst Controller / View design/implementation
is
 only what would ordinarily be flat file accesses that use SQL
 instead of
 keyed-access flat files. If that's the case, wrapping a transaction
 around each of these SQL prepare/execute pairs will be a substantial
 performance hit.



___
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/

___
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] refactoring an existing HTML::Mason installation to use Catalyst

2007-04-28 Thread Garrett Goebel

Marc,

I just did the opposite for an old Mason site at work the other day.  
I embedded mason pages in catalyst. I.e., I used  
Catalyst::View::Mason and created a controller that forwarded all the  
mason pages to it.


Because Catalyst::View::Mason uses Mason without Apache you won't  
have access to $r. For my purposes this wasn't a big deal. As a quick  
hack in my controller I put $c-stash-{backend} = 'catalyst'. Then  
in the autohandler I dropped:


%args
$backend
/$args
my $r = $c-request  if $backend eq 'catalyst';

$r and $c-request were similar enough that this worked for me. Your  
milage may vary.


cheers,

Garrett

On Apr 28, 2007, at 5:15 AM, Marc Espie wrote:


Couldn't find any simple guide to that, so I was wondering if someone
had done it already.

I have a somewhat big HTML::Mason `classic' web-site, with web pages
that include all kinds of Mason components.

I'd like to migrate all of that to Catalyst, but it's not going to  
happen

overnight, and the application must keep running.

So I was wondering if there was any guide to this kind of `inside-out'
refactoring.

Specifically, I see how I can get the Mason app coexisting with  
Catalyst
stuff, I also have a plan to migrate the DBI glue to DBIx::Class,  
but I

would like to keep using the Mason infrastructure for now, and by able
to invoke catalyst parts as Mason components, e.g., a web page served
by mason:

some static content...
some mason stuff.
 invoke/some/external_compoent /
   ^
   |
what should I put to be able to have part of my catalyst app there ?

I understand it will require having two views (full catalyst app, and
html fragments for HTML::Mason), but I don't see how to run the  
controller

from Mason...

___
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/




___
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/


[Catalyst] A gentle introduction to Chained - Catalyst::Controller::PathArgs

2007-04-28 Thread Zbigniew Lukasiak

For those too lazy to learn Chained in one step I've prepared
Catalyst::Controller::PathArgs  (on the way to CPAN) - it's some
syntactic sugar over Chained, useful for the most common cases.

My blog entry on it:
http://perlalchemy.blogspot.com/2007/04/catalystcontrollerpathargs.html

See the POD copied below for details.
--
Zbigniew Lukasiak
http://brudnopis.blogspot.com/

==

NAME
  Catalyst::Controller::PathArgs - syntactic sugar for
Catalyst::DispatchType::Chained.

SYNOPSIS
package MyApp::Controller::Root;
use base 'Catalyst::Controller::PathArgs';
__PACKAGE__-config-{namespace} = '';

sub pathargsroot : PathArgs(1) {}

use Catalyst::Controller::PathArgs;
package TestApp::Controller::Pathargsroot;

use base 'Catalyst::Controller::PathArgs';

sub pathargsend : PathArgs(1) EndPoint { }

DESCRIPTION
  This Catalyst Controller base adds two new action attributes:
PathArgs (taking one numerical argument)
  and EndPoint.  This is entirely syntactic sugar over the
Catalyst::DispatchType::Chained full machinery
  for paths like '/book/$book_id/edition/$edition_id/view' - with
PathArgs you can chain the 'book', 'edi-
  tion' and 'view' methods and declare how many parameters they
take.  EndPoint is needed to declare an
  ation as the end of the chain (in theory this should be
computable - but for now I don't see any easy
  way to do that).

  This package uses Class::C3 this means that you cannot use NEXT
in classes based on it - but C3 looks
  like a good replacement for NEXT.

  To declare that the book subroutine is the root chained action
with one argument you need to declare it
  in the Root controller with:

sub book : PathArgs(1) {

  If we had a non chained path with /book/edition - the edition
sub would be declared in the 'Book' controller
  - and this is the same case here - you just add PathArgs(1) to
indicate that it is indeed
  chained and that it takes one parameter. So in the Book
controller you add:

sub edition : PathArgs(1) {

  For the last action in the chain you need to add EndPoint.  So
in the Book::Edition controller you would
  need:

sub view : PathArgs(0) EndPoint {

  You can also mix PathArgs with PathPart (new in Catalyst
5.7007).  For example if you wanted to have an
  action responding for the address /book/$book_id/edition you
would need a subroutine called 'edition'
  in the Book controller, but there is already one routine called
'edition' in that controller.  What you
  can do in that case is make a sub with a different name and
declare that from the outside it's name
  should be really 'edition':

sub edition_mascarade: PathPart('edition') PathArgs(0) EndPoint {

  yeah - you need to add EndPoint there as well.

  An example is included in the example directory of this distribution.

  Internally PathArgs and EndPoint are converted to 'Chained(.)'
and appriopriate CaptureArgs or Args
  attributes.  For more sophisticated chaining you might need to
use Catalyst::DispatchType::Chained
  directly.

  create_action

  This is the overriden method from Catalyst::Controller used
here to compute the new attributes.

LIMITATIONS
  Using this module forces you to have a directory structure of
the modules similar to the external paths
  that you want to serve.  For example to serve the external path
of '/book/$book_id/edition/$edi-
  tion_id/view' you need to have a module 'Book/Edition.pm'. If
you want to build your modules directory
  structure completely independently from the path served you
need the full power of Catalyst::Dis-
  patchType::Chained.  To convert a script using PathArgs to the
original Chained just change every
  PathArgs($number) to 'Chained('.')  CaptureArgs($number)' or
'Chained('.') Args($number)' if it is an
  'EndPoint'.

BUGS
SUPPORT
AUTHOR
  Zbigniew Lukasiak
  CPAN ID: ZBY
  http://perlalchemy.blogspot.com/

COPYRIGHT
  This program is free software; you can redistribute it and/or
modify it under the same terms as Perl
  itself.

  The full text of the license can be found in the LICENSE file
included with this module.

SEE ALSO
  Catalyst::DispatchType::Chained

___
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/


[Catalyst] Question about Catalyst::Controller::FormBuilder

2007-04-28 Thread Balaji Srinivasan

Hi There
I am using Catalyst::Controller::FormBuilder to create my forms. Its working
great for me except for this one issue:
I would like to specify a field that has a regexp that has a comma in it.
For example:


sub doStuff : Path('/doStuff) Form('/doStuff') {

.
}

My doStuff.fb file has the following field

fields:
   username:
   label: Username
   size: 40
   validate: /^[^,]{6,40}$/

ie I want the username field to contain 6-40 characters without any single
or double quotes.
Unfortunately the validation code for this on the javascript side turns
into:

   var username = form.elements['username'].value;
   if (username == null || (username != '/^[^']{6'  username != '40}+$/')) {
   alertstr += 'Username should be between 6 and 40 characters
and should not contain single-quotes (\') or double-quotes ()\n';
   invalid++;
   }


ie. The value is split at the , sign.
This looks like it would be a fairly common problem. Any workaround for
this?
Thanks
Balaji
___
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/