Re: [Catalyst] get the path to the home

2007-09-28 Thread Mark Zealey
The __FILE__ compile-time constant may be of some use.. You should be able to 
get the directory of the current module by doing something like:

package MyApp::I18N::foo;
use strict;

sub get_my_dir {
  my ($dir) = __FILE__ =~ m!^ (.*) / [^/]+ !x;
  return $dir;
}

Of course, if you wanted to do that from a subclass or so you'd probably have 
to get the package of the object by ref($self) || $self, turn that into a 
file name and then look it up in %INC to find the location of the object.

Mark

On Friday 28 September 2007 3:46 pm, Octavian Rasnita wrote:
 From: Chisel Wright [EMAIL PROTECTED]

 On Fri, Sep 28, 2007 at 03:30:23PM +0300, Octavian Rasnita wrote:
  Hi,
 
  I have a I18N module in my Catalyst application and I want to get the
  path to the home directory of the application. Is it possible to get it
  without hard codding it in that module?
 
  The module is:
 
  package MyApp::I18N::ro;
 
  Assuming you can access to $c, I think this is what you want:
 
$c-path_to(’’)
 
  It's described in 'perldoc Catalyst' and mentioned in 'perldoc
  Catalyst::Plugin::ConfigLoader'
 
  --
  Chisel Wright

 Thank you but I know that. However, I have just the following module which
 is not a controller or a model or a view:

 # Copy/paste from Catalyst::Plugin::I18N:

#MyApp/I18N/de.pm
package MyApp::I18N::de;
use base 'MyApp::I18N';
our %Lexicon = ( 'Hello Catalyst' = 'Hallo Katalysator' );
1;

 So I don't have access to $c. Does this mean that I will need to hard code
 the path to the home directory?

 Here is what I want to do: I want to create a site in more languages, and
 it is simple to use a .po file for translating short strings, however I
 also need to display a few pages with pretty large descriptions, and I
 think I can avoid using a database for this.

 Instead of using .po files I want to use perl modules like ro.pm, de.pm and
 so on, and in those files I want to define the translations as:

 our %lexicon = (
 'term' = 'translation',
 'another term' = get_file('another_term',
 );

 sub get_file {
 my $file = shift;
 # read that file and return its content
 }

 I will keep those files in directories named with the language names like
 de, ro, en, fr, and they will be placed in MyApp/lib/MyApp/I18N directory
 (where the .pm or .po files should be also placed.

 And I want to know if there is a way of getting that folder name without
 hard codding it.

 Thanks.

 Octavian



 ___
 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] Catalyst Hosting

2007-08-09 Thread Mark Zealey
I work for pipex hosting, who own 123-reg.

123-reg have cheap dedi servers (from £40/mo) running ubuntu 
(http://www.123-reg.co.uk/dedicated-server-hosting/). You can get root access 
(actually a chroot, but you get full control of the box and the ip) and we 
even put catalyst on there as standard (using the deb packages). Bandwidth is 
un-metered, with a 10mbps conn to 1gbps backbone in leeds.

Mark

___
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] conditional loading of Controllers and Models

2007-07-16 Thread Mark Zealey
I use:

package MyApp;
use Catalyst qw/ ... /;

my @extra_plugins;

if( $ENV{CATALYST_DEBUG} ) {
push @extra_plugins = qw/ Static::Simple StackTrace /;
}

# Start the application
__PACKAGE__-setup( @extra_plugins );



Mark

On Monday 16 July 2007 1:48 pm, Daniel McBrearty wrote:
 is there a way to have some C's and M's load into catalyst
 conditionally? for example, if some config variable is set?

 cheers

 D

 ___
 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] Proper way to perform cleanups on server shutdown?

2007-07-11 Thread Mark Zealey
Perhaps I'm missing something, but what's the problem with doing something 
like:

package MyApp;

$SIG{INT} = sub {
  graceful_shutdown();
  exit(1);
}

END { graceful_shutdown() }

sub graceful_shutdown {
  # Code here...
}

Note that a $SIG{INT} will not exit if you override it, which is why you need 
the exit. This means that you could make it restart on a SIG{INT} (or perhaps 
better, $SIG{HUP})

Mark

___
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] what do you do when your app hangs without explanation?

2007-07-08 Thread Mark Zealey
In the debugger you can just hit ctl-c when it's looping and it'll stop your 
program and tell you where you are, stack frames etc..

M

On Sunday 08 July 2007 6:30 pm, Daniel McBrearty wrote:
 in the middle of working on another part of the app altogether,
 suddenly when I start up, just trying to login causes a hang. The
 process takes 95% CPU, there is no debug output (not even to show the
 request is received).

 break out the debugger? I have no idea even where to put the
 breakpoint, it looks like my code is not even reached.

 simple things I can check for?

___
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] Automatic structure creation from form data

2007-07-03 Thread Mark Zealey
check out Catalyst::Controller::FormBuilder - it'll autogenerate your forms 
for you, handle validation etc etc.

M

On Tuesday 03 July 2007 7:19 pm, Andrew Hayward wrote:
 I'm relatively new to this Catalyst malarkey, so you'll have to bear
 with me for a minute.

 I was wondering if it possible to construct an HTML form such that the
 back end automatically creates a hash (or an array) based on the naming
 scheme.

 For example...

 form
input name=items[0][name] value=...
input name=items[0][description] value=...
input name=items[1][name] value=...
input name=items[1][description] value=...
...
 /form

 ...giving...

 $c-request-parameters-{items}-[0]-{name}
 ...etc (which itself is probably incorrect!)


 If I'm barking up the wrong tree, or just plain barking, then please
 excuse me. I know it can be done in other server-side languages (yes,
 I'm more used to PHP), and I figured it might be something that other
 people have tried in the past.


 Thanks,

 - Andrew

 ___
 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] Re: Redispatching actions

2007-05-22 Thread Mark Zealey

   You said absolutely nothing to address the “wrong URL”
   problem Matt mentioned, btw.
 
  What wrong URL? My example showed that
  http://example.com/data/update is virtually equal to
  http://example.com/data/view if not posted from a form.

 Of course they are virtually equal – after all they are equally
 terrible. If you lay out your URI space in that manner, it’s no
 wonder that you can’t understand why redirects are good.

Why do you say this? what do you propose for a better URI layout?


Mark

___
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] Redispatching actions

2007-05-20 Thread Mark Zealey
Hi there,

I was wondering if there was some way within the Catalyst api to redispatch 
calls. The problem I'm having is:

package MyApp::C::Blah;

sub add : Local :Form(...) {
  if($form-submitted) {
# Add to database
$c-res-redirect($c-uri_for('view'))
  }
  # Generate form and display
}
sub edit : Local { ... same as add but fill out form initially }
sub delete: Local {
  # Delete item
$c-res-redirect($c-uri_for('view'))
}
sub view : Local {
  # display page
}
sub index : Private {
$c-res-redirect($c-uri_for('view'))
}


This is an awful lot of duplicated code, forever looking up the uri for view 
and then redirecting there when i want to send the user to it. I could do 
$c-forward('view'), which would reduce the overhead, and stop me having to 
send so many 302 responses etc, but because I'm using TT, $c-action-name is 
automatically used as the template file to process, which is what I want. I 
could do $c-stash-{template} = '/blah/view.tt' in view(), but that's 
annoying as TT already does that for me automatically. There must be some way 
to simply say I want to redispatch to the view() action in such a way as 
$c-action-name is set to view, etc. I guess Catalyst::Plugin::SubRequest 
would do that, but again that's quite a lot of overhead and I don't really 
want all the request data to be localized... Anyone got any ideas or should I 
write a $c-redispatch plugin?

Thanks,

Mark

___
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] Mapping urls inside catalyst

2007-05-19 Thread Mark Zealey
Hi,

I'm trying to work out the 'best way' of solving the following problem. 
Basically, I want to have several entries into my application. One is of the 
form /foo/id where id is an integer primary key. Another 
is /bar/other_key where other_key is some string key, and another is via a 
virtual host. I want them all to go into my MyApp::C::Foo:: namespace, but I 
have multiple classes under there eg MyApp::C::Foo::Fred. I thus want the 
following to be equivalent:

mysite.com/foo/5/fred/list
mysite.com/bar/myname/fred/list
othersite.com/fred/list

(each of those should set some $c-stash variable to be the entry in the 
database corrosponding to these bits of information).

I was thinking I colud do this using Chained actions; but I don't know much 
about them and the rest of the app is not using them - it's using :Local for 
the most part.

Thoughts, suggestions, ideas, criticisms welcome!

Mark

___
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] Mapping urls inside catalyst

2007-05-19 Thread Mark Zealey
wow; thanks for your detailed response - I hadn't even considered doing 
something like that. I'm not sure that it's exactly what I'm looking for 
though; I am basically trying to write my app in the 'fred' layer ie I want a 
lot of modules as MyApp::Controller::Foo::Fred, 
MyApp::Controller::Foo::Wilma, etc (say, 10 modules)which just need to get 
the database entry in one of three ways. I think in that case you're saying 
that I would need to use all 10 of these as base classes in each of C::Foo, 
C::Bar and C::ViaHost ?

The original solution I was thinking of was something like a simple 
select-type statement based on the beginning of the path, and then a 
re-dispatch (ie in MyApp::C::Root::auto, I'd have if(s!^/foo/(\d+)(?=/)!!) { 
load by id } elsif(s!^/bar/([^/]+)!! { load by name } else { look up vhost}) 
but I couldn't really work out how to do this stripping and then shove the 
url back into catalyst...

Mark

On Saturday 19 May 2007 9:18 pm, Robert 'phaylon' Sedlacek wrote:
 Mark Zealey wrote:
  Hi,
 
  I'm trying to work out the 'best way' of solving the following problem.
  Basically, I want to have several entries into my application. One is of
  the form /foo/id where id is an integer primary key. Another
  is /bar/other_key where other_key is some string key, and another is
  via a virtual host. I want them all to go into my MyApp::C::Foo::
  namespace, but I have multiple classes under there eg
  MyApp::C::Foo::Fred. I thus want the following to be equivalent:
 
  mysite.com/foo/5/fred/list
  mysite.com/bar/myname/fred/list
  othersite.com/fred/list

 Is fred an argument or is he a part of the application? :)

  I was thinking I colud do this using Chained actions; but I don't know
  much about them and the rest of the app is not using them - it's using
  :Local for the most part.

 Assuming that fred is an argument, I would implement:
   - a controller base class, that chains to a base action in the
 subclass:

   package MyApp::ControllerBase::Fred;
   use strict;
   use base 'Catalyst::Controller';

   # this gets the fred, ties to the 'load' action in the subclass
   sub load_fred: Chained('load') PathPart('') CaptureArgs(1) {
 my ($self, $c, $fred) = @_;
 $c-stash(fred = $fred);
   }

   sub list_fred: Chained('load_fred') PathPart('list') {
 ...
   }

   1;

   - different controllers for every type of invocation. these are the
 actions I would implement:

 in MyApp::Controller::Foo (load gets the id):
   sub base: Chained PathPart('foo') CaptureArgs(0) { ... }
   sub load: Chained('base') PathPart('') CaptureArgs(1) { ... }

 in MyApp::Controller::Bar (load gets the name):
   sub base: Chained PathPart('bar') CaptureArgs(0) { ... }
   sub load: Chained('base') PathPart('') CaptureArgs(1) { ... }

 in MyApp::Controller::ViaHost (load uses host to find the item):
   sub base: Chained PathPart('') CaptureArgs(0) { ... }
   sub load: Chained('base') PathPart('') CaptureArgs(0) { ... }

 In any case, you could omit the base actions and load directly. I just
 like the convention of naming the chained base action in a controller
 'base.' All need to have their base class set to the one above.

 This is all untested of course. But you should get the chains

   /foo/*/*/list - Foo::base, Foo::load, Fred::load_fred, Fred::list_fred
   /bar/*/*/list - Bar::base, Bar::load, Fred::load_fred, Fred::list_fred
   /*/*/list - ViaHost::base, ViaHost::load, Fred::load_fred,
   Fred::list_fred

 If 'fred' is an action, but not an argument, just change the 'load_fred'
 action to a simple chained action that tales no args. Make it a base if
 it's just a namespace element. Maybe you should also consider putting
 the chain that goes via the domain under another namespace, if fred is
 indeed an argument, to avoid collisions.


 .phaylon

 ___
 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] Bug with POSTs using cat 5.7007, and parse_on_demand = 1

2007-05-18 Thread Mark Zealey
Hi,

I have found a bug with catalyst, when Catalyst::Engine::HTTP is used with 
parse_on_demand set to true, and POST content. when I post, the 
connection 'hangs'. if i hit esc in the browser, I get the following cat 
output:

Can't call FIRSTKEY method on handle DBI::db=HASH(0x9858670) after 
take_imp_data() at /usr/lib/perl5/site_perl/5.8.8/Data/Dump.pm line 251.
Can't call FIRSTKEY method on handle DBI::db=HASH(0x984a6ec) after 
take_imp_data() at /usr/lib/perl5/site_perl/5.8.8/Data/Dump.pm line 251.
[info] *** Request 1 (0.200/s) [17010] [Fri May 18 21:59:01 2007] ***
[debug] POST request for wedding/invite/add from 127.0.0.1
[debug] Path is wedding/invite/add
[debug] Found sessionid 6b7b217cfca6320d5f6579dbe7b4087ce8102acb in cookie
[debug] Restored session 6b7b217cfca6320d5f6579dbe7b4087ce8102acb
[debug] Body Parameters are:
.-+--.
| Parameter   | Value|
+-+--+
| _submit | Add new invite   |
| _submitted_invite   | 1|
| address |  |
| email   |  |
| invited | 0|
| known_by| 639359   |
| name| blah |
| type| service  |
'-+--'
[error] Caught exception in Wedding::Controller::Root-end Wrong 
Content-Length value: 107 at /usr/lib/perl5/site_perl/5.8.8/Catalyst.pm line 
1611
[debug] Found sessionid 6b7b217cfca6320d5f6579dbe7b4087ce8102acb in cookie
[debug] Restored session 6b7b217cfca6320d5f6579dbe7b4087ce8102acb
[debug] Redirecting to http://localhost:3000/wedding/invite/view;
[info] Request took 5.621478s (0.178/s)
.+---.
| Action | Time  |
++---+
| /auto  | 0.263820s |
| /wedding/auto  | 0.000924s |
| /wedding/invite/add| 0.171354s |
| /end   | 4.483848s |
'+---'

The FIRSTKEY stuff is some tied hash access to DBI (keys or something), and 
I'm not sure why it is saying 'Wrong content-length value' - this is perhaps 
the key to the error? When I run the server under perl -d, and hit ^C when 
it's hanging, it shows it being this:

Catalyst::Engine::HTTP::read_chunk(/usr/lib/perl5/site_perl/5.8.8/Catalyst/Engine/HTTP.pm:131):
131:my $rc = *STDIN-sysread(@_);

I guess cat is mis-parsing the amount of data that it expects from the POST 
command? When i turn parse_on_demand off, it all works fine...

Mark

___
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] Bug with POSTs using cat 5.7007, and parse_on_demand = 1

2007-05-18 Thread Mark Zealey
After spending the past two hours looking through code etc, I finally 
discovered this was a bug of my own making. Basically, I've written a custom 
little FormBuilder controller module that loads .pm files with formbuilder 
specs. As part of that, it specified that it wanted { params = $c-req }, 
which wouldn't normally be a problem except that then in the base class, I do 
a Hash::Merge with some other values that I want. This by default does a 
Clone on the hashes, hence cloning $c-req. This meant that $c-req-{_body} 
was read in the cloned version when -param was called, but it was then 
called again in the non-cloned version which caused it to want to read the 
data again. Pfew!

Mark

On Friday 18 May 2007 10:24 pm, Andy Grundman wrote:
 One more thing, can you set the environment variable
 CATALYST_HTTP_DEBUG=1 and then run through your bad POST?  This
 should give some helpful info.

 ___
 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] todo list for FormBuilders (was the l10n thread)

2007-02-20 Thread Mark Zealey
Something else i wanted to do was to be able to define 'blocks' which would go 
on my form; for example:

form:
  INCLUDE 'name.fb'
  INCLUDE 'address.fb'

To get a default name block and then an address block appended to my form. 
Using HTML::Widget you could do -merge which is something i'm yet to find an 
equivelent too in formbuilder. Because of the way the fields are defined; i'm 
not sure it's possible to create a block widget like that and in any case i 
want to 'flatten' it into the form basically via an include as shown above. I 
don't really know how switching to YAML would work with that though...

Mark

On Tuesday 20 February 2007 4:04 pm, Jonathan Rockway wrote:
 Christopher H. Laco wrote:
  FormBuilder is nice when it comes to localizing the messages via
  messages.$lang. It totally sucks when it comes to localizing the form
  labels themselves. It looks like I either have to manually loop through
  teh fields and localize the labels, or use a different .frm config for
  each language...which means duplicating major parts of the config.

 This doesn't really answer your question, but raises another good point.
  FormBuilder's definition files are great.  The fact that they're
 magically parsed by the secret internals FormBuilder isn't.  In your
 case, you really want something like this:

 Form:
   foo:
 name: _[1]
   bar:
 name: _[2]
 ...

 and then you want to apply a filter that properly maps _[1] to the
 localized string as expected.

 The way this should work is that form definition files should be
 retrieved from a Model.  The default model would parse the YAML and then
 pass the result to FormBuilder.  This would give you the opportunity to
 reuse an existing model (maybe you want your forms to come from a
 database), and give you the opportunity to subclass the model to do
 l10n, use XML instead of YAML, etc.  The idea is to use a Catalyst model
 instead of a FormBuilder model.  This would solve your problem, and
 many others that people haven't had yet :)

 Interestingly (now that I think about it) FormBuilder is really its own
 MVC framework (its own filesystem model for reading config, its own
 templating system as a view).  I guess what we need to do is get rid of
 FormBuilder's model and view and use Catalyst's instead.  (Something I
 dislike about FormBuilder is invoking TT twice per request; [% PROCESS
 my_form.tt form=FormBuilder %] is much clener.)

 Then you could read XML-formatted forms from memcached and render them
 with ClearSilver -- without FormBuilder ever knowing or caring.  (The
 flexibility of Catalyst we all love...)

 Anyway, /me goes to look at how easy this is to do... but in the mean
 time... comments?  Am I missing something?

___
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] Using C::C::FormBuilder With DBIC

2007-02-18 Thread Mark Zealey
wrt radioboxes on forms/dbic; I have been doing a true/false/null using the 
following:

invited:
label: Invited?
options: 1=Yes, 0=No
required: 0

As this is not required, if nothing is sent back the value will be undef = 
null; otherwise 1/0 will be returned based on yes/no response. To remove 
null, simply set required to 1.

re the easy solutions presented earlier in the thread for sticking a form into 
a db and back again; I don't ususally make the code that simple because it 
could open up injection attacks and doesn't work too well with more complex 
forms or fields. I usually explicitly list which fields i want to use so then 
a typo in the form or a forgotten/newly added field in the form will not 
allow remote users to mess with bits of the database you don't want them to 
mess with. I guess you could probably use db column permissions to do that 
db-side though.

Mark

On Sunday 18 February 2007 1:01 pm, Carl Franks wrote:
 On 18/02/07, RA Jones [EMAIL PROTECTED] wrote:
  [EMAIL PROTECTED] wrote:
   Hi Everyone,
  
   I have been experimenting with Catalyst::Controller::FormBuilder.  I'm
   trying to provide an edit form for objects read from and written to the
   DB via DBIx::Class.  Have FormBuilder automatically load the data from
   DBIC into the form seems pretty easy with something like:
  
   my $widget = $c-model('MyAppDB::Widget')-find($id);
   my $form = $self-formbuilder;
   $form-values($widget-get_columns);
  
  
   However, an elegant way of writing the data back out is not jumping out
   at me.  I know I could manually copy each field out of the $form object
   to my $widget object, but it seems like there should be simple way to
   do it all in one line like I got with the
   $form-values($widget-get_columns); above.
  
   Any suggestions?  What are other folks doing for C::C::FormBuilder and
   DBIC?
 
  I'm pretty new to this, but this is what I did:
 
  sub edit : Local Form {
 
 # get data into form pretty much as above, then:
 
  if ( $form-submitted  $form-validate ) {
 $c-stash-{user} = $user;
 $c-forward('do_edit');
  }
 
  sub do_edit : Private {
 my ($self, $c) = @_;
 my $form = $self-formbuilder;
 my $fields = $form-field;
 $c-stash-{user}-update($fields);
 $c-flash-{status_msg} = 'User updated';
 $c-response-redirect( $c-req-base . 'users/view/' .
   $c-stash-{user}-id );
  }
 
  Not sure if it's the 'best' way, but it works. Will be interesting to
  see what other suggestions you get.

 It might be worth looking at the code for DBIx::Class::HTMLWidget for some
 ideas
 http://search.cpan.org/src/ANDREMAR/DBIx-Class-HTMLWidget-0.09/lib/DBIx/Cla
ss/HTMLWidget.pm

 When you're populating the form from the database, would your
 $form-values($widget-get_columns);
 correctly set select menus?

 Also, (for all browsers that I'm aware of) no value is sent back to
 the server for unchecked radioboxes - so it'd be worth checking
 whether the $fb-field solution handles this properly.
 (I don't know, as I've only read the formbuilder docs, I've never used it).

 Cheers,
 Carl

 ___
 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] Re: looping

2007-02-14 Thread Mark Zealey
You could of course do somethnig like:

push @lname = $c-model('myDB::Author')-get_column('last_name')-all;

tmtowtdi

Mark

On Wednesday 14 February 2007 5:21 pm, A. Pagaltzis wrote:
 Hi Ian,

 * Ian Docherty [EMAIL PROTECTED] [2007-02-14 16:40]:
  A. Pagaltzis wrote:
 * Will Smith [EMAIL PROTECTED] [2007-02-12 21:25]:
 my $column = $c-model(myDB::Author)-get_column('last_name');
 while(my $name = $column-next){
 $lname[$i] = $name;
 $i = $i + 1;
 }
 
 Ugh. Use `push`; this isn’t C.
 
  Or 'map'

 That won’t work here, since there’s no list to process, just an
 iterator. (I always thought List::Util should supply `unfold`…)

 Regards,

___
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] viewing catalyst memory usage

2007-02-12 Thread Mark Zealey
Hi there,

Is there any (vaguely simple?) way to see where all the memory is being used 
in a catalyst application? This kinda follows on from the previous thread on 
mod_perl memory usage, but I'd like to use something like Devel::Monitor or 
Devel::ObjectTracker to monitor all objects created by catalyst and try to 
optimize those that are using the most memory - even quite a simple cat app 
with DBIx::Class, Authentication, Sessions and TT takes about 30-40mb and 
this can't be good.

Thanks,

Mark

___
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] Using $c-view('TT')-render for emails

2007-02-06 Thread Mark Zealey
I'd just create a separate TT view instance eg i call my website 
view 'C::V::Website' and my email view 'C::V::Email' and then just parse it 
through that - means you can have different dirs /root/website 
and /root/email with different variables - the email and website views are 
generally very different so best have them as different objects, even if the 
same base class.

Mark

On Tuesday 06 February 2007 10:53 pm, Jim Spath wrote:
 In the docs for Catalyst::View::TT and Catalyst::Plugin::Email, it
 suggests using $c-view('TT')-render() for the rendering of email
 templates.

 My issue is that I created my Catalyst view with TTSite as described in
 the CatalystBasics tutorial, and when I call the render method on the
 email template, all of the site templates (header, footer, etc) are
 pulled in, when all I really want is the email template by itself.

 What is the right solution?  Should I create a new view just for email
 templates?  Should I modify my existing view in some way to allow it to
 output both normal site templates and one-off templates?  Should I not
 use render() for email templates?

 Thanks!
 - Jim


 ___
 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] formbuilder method in C::C::FormBuilder not located

2007-02-01 Thread Mark Zealey
I'm guessing you didn't change the line which says:

use base 'Catalyst::Controller';

to:

use base 'Catalyst::Controller::FormBuilder';

Mark

On Thursday 01 February 2007 8:39 pm, rahed wrote:
 Hi,

 starting with Catalyst, I went through CatalystBasics tutorial. From the
 archive I concluded it's better to use FormBuilder for my forms. So I
 tried to add some forms based on CGI::FormBuilder. Into Books.pm I
 added example synopsis from Catalyst::Controller::FormBuilder and also
 created edit.fb in root/forms/books. Default settings were left untouched.

 When I call edit action as http://localhost:3000/books/edit I get

 Caught exception in MyApp::Controller::Books-edit Can't locate object
 method formbuilder via package MyApp::Controller::Books.

 I also tried to add my method in C::C::FormBuilder which was located and
 rendered ok.

 I may miss something but don't know what. Could someone help?

___
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] Accessing $c from Model

2006-12-27 Thread Mark Zealey
Hi there,

I'm basically wanting to write a simple log function which logs hits on my 
website as entries in a database (automatically adding $c-user-{id} and 
$c-req-referrer etc), but to do so I want to use a model (I think). Any 
ideas how I can just say $c-model('Log')-info(foo) and automatically get 
$c passed in? I think I could have sth like:

package MyApp::Model::Log;
use base 'Catalyst::Model';

my $last_c;

sub ACCEPT_CONTEXT {
my ($self, $c) = @_;
$last_c = $c;
}

sub info {
my ($self, $msg) = @_
my $c = $last_c;
...
}

but this seems pretty messy...

Mark

___
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] Various login problems

2006-12-27 Thread Mark Zealey
that's cos the database connection has gone away (it happens after about 20 
min) and the DBD driver for you database doesnt have autoreconnect set. This 
is a DBD:: specific thing - the way for mysql databases is to set 
mysql_auto_reconnect to true in the DBI connection options (which iirc you 
can pass through DBIx::Class somehow.

Mark

On Wednesday 27 December 2006 3:35 pm, Jesse Sheidlower wrote:
 For the past few months, with two of my Cat apps, I've been
 having unpredictable problems where a logged-in user would get
 redirected back to the login page, and could not re-login
 again. After some amount of time, the user would be able to
 log in.

 This was sporadic and I never managed to be online when it
 was happening, so I had no idea how to even start to evaluate
 it. However, the other day it happened when I was on the
 server, and I saw that the error log was getting this:

 DBD::mysql::st execute failed: MySQL server has gone away at
 /usr/local/lib/perl5/site_perl/5.8.7/Catalyst/Plugin/Session/Store/DBI.pm
 line 30.

 DBD::mysql::st fetchrow_array failed: fetch() without execute() at
 /usr/local/lib/perl5/site_perl/5.8.7/Catalyst/Plugin/Session/Store/DBI.pm
 line 31.

 Now, the server had certainly not gone away in this time; when
 this was happening I was able to log in to the MySQL server,
 and other apps running on the server were able to hit the
 database.

 Restarting Apache fixes the problem immediately. I'm using
 the standard Cat session and auth stuff, all set up pretty
 much as the docs suggest. (I'm happy to post these if it
 would help.)

 Any suggestions what might be causing this, or where I should
 start to try to figure it out? Keep in mind that I cannot seem
 to force this to happen, so when it's OK, as it is now, I can't
 get it started.

 Thanks.

 Jesse Sheidlower


 ___
 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] Accessing $c from Model

2006-12-27 Thread Mark Zealey
On Wednesday 27 December 2006 1:01 pm, Ash Berlin wrote:
 Very very *VERY* bad idea.

 __PACKAGE__-mk_accessors(context);

 sub ACCEPT_CONTEXT {
my ($self, $c, @args) = @_;

my $new = bless({ %$self }, ref $self);
$new-context($c);
return $new;
 }

Isn't that really really slow though? Constructing a new object for each call?

___
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] How do I pull out HTML::Widget result values?

2006-12-26 Thread Mark Zealey
I usually just do sth like:

if($result-have_errors) { display form; return }

# otherwise:
my $p = $c-req-params;
# We know that the params are valid now...

Mark

On Tuesday 26 December 2006 6:01 pm, Dennis Daupert wrote:
 This is throwing me down the stairs. I'm trying to pull out individual form
 element values to do things with. I have a working form with settings like:

 ==
 my $w = $c-widget('write_msg_form')-method('post');
 $w-element('Textfield', 'sndr_email'
 )-label('Email')-size(50)-value(''); snip
 my $result = $w-process($c-req);
 snip
 $c-stash-{widget_result} = $w-result;
 ==

 In my tt template this works fine:

 [% widget_result.container %]

 But nothing I've tried has successfully retrieved stuff like the value of
 the sndr_email field. (Trying to follow doc for HTML::Widget::Result, but
 I'm having a disconnect going from the generically presented lists of
 methods to actual correctly formatted perl.) How to do this?

 /dennis

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