From rehak at tekkirk.org Sat Dec 10 14:36:10 2016 From: rehak at tekkirk.org (Martin =?utf-8?B?xZhlaMOhaw==?=) Date: Sat, 10 Dec 2016 15:36:10 +0100 Subject: [Catalyst] No database defaults with FormHandler and DBIC In-Reply-To: References: <20161031075723.GF6900@marvin.tekkirk.org> <031fcdce-0601-c7d1-cc9e-e2f6a3b5b20a@hidden-primary.net> <19cdde2b-f60c-ace4-efdb-41cb98951bc2@hidden-primary.net> <20161031160016.GH6900@marvin.tekkirk.org> Message-ID: <20161210143610.4vh5zwyu4a6untgk@marvin.tekkirk.org> Hi Gerda, sorry for late reply. Didn't have time to look into this. Now I have: my $init_row = $c->model('DB::Lesson')->new_result({}); $validated = $self->formDetail->process(item => $init_row); And I still don't see the database defaults in the rendered form. Any clue where to look now? Thank you -- Martin On 2016.11.01 12:22:15 -0400, Gerda Shank wrote: > A database row is used for defaults only if it is provided in the ?item? > attribute. If you provide only the item_id and item_class they are used to > update the row but not for defaults. > > Gerda > > > On Mon, Oct 31, 2016 at 12:00 PM, Martin Rehak wrote: > > > Hi, > > > > thanks much for comments. > > > > I know there are number of ways how/where to set/define defaults from app > > code > > and there is large text written about it in Catalyst documentation. > > > > What I would expect to work at least is that database default is going to > > be > > propagated into the form from the schema definition. I don't need to have > > the > > second place with explicit default definition when there is and implicit > > definition coming from db. > > > > In other words: > > $ script/reha_create.pl model DB DBIC::Schema reha::Schema create=static > > 'dbi:Pg:dbname=;host=' reha > > > > generates > > > > =head2 capacity > > > > data_type: 'integer' > > default_value: 1 > > is_nullable: 1 > > > > and there is the default definition successfully fetched from db. How to > > get it > > used without any override (and duplication) in the app code? > > > > Thank you very much in advance. > > > > Regards > > -- > > Martin > > > > On 2016.10.31 09:23:26 +0000, LNATION . wrote: > > > Probs incorrect approach but it'll work.... > > > > > > before render => sub { > > > unless ($_[0]->field('capacity')->value) { # mayb editing > > > $_[0]->field('capacity')->value(1); > > > } > > > } > > > > > > On Mon, Oct 31, 2016 at 8:28 AM, Marc0 > > wrote: > > > > > > > Am 31.10.2016 um 09:15 schrieb Marc0: > > > > > Am 31.10.2016 um 08:57 schrieb Martin Rehak: > > > > >> has_field 'capacity' => (type => 'PosInteger', > > > > >> #default => '1', > > > > >> label => 'Kapacita'); > > > > > > > > > > maybe add a "lazy => 1" to your commented "default => '1'"? > > > > > > > > > > has_field q(capacity) => ( > > > > > type => q(PosInteger), > > > > > lazy => 1, > > > > > default => q(1), > > > > > label => q(Kapacita), > > > > > ); > > > > > > > > maybe "capacity" is explicitely set to undef, you could try an "around" > > > > method modifier to check for a defined value: > > > > > > > > has_field q(capacity) => ( > > > > is => q(ro), # just guessing > > > > type => q(PosInteger), > > > > lazy => 1, > > > > default => q(1), > > > > label => q(Kapacita), > > > > writer => q(_set_default_capacity), > > > > ); > > > > > > > > # untested, but according to Moose::Manual::MethodModifiers > > > > around q(has_field) => sub { > > > > my $orig = shift; > > > > my $self = shift; > > > > > > > > # check for definedness and set to default value if > > > > # not defined (NULL) > > > > $self->_set_default_capacity(1) > > > > unless defined $self->$orig(); > > > > > > > > return $self->$orig(); > > > > }; > > > > > > > > Regards > > > > -- > > > > Marc0 > > > > > > > > _______________________________________________ > > > > List: Catalyst at lists.scsys.co.uk > > > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > > > Searchable archive: http://www.mail-archive.com/ > > > > catalyst at lists.scsys.co.uk/ > > > > Dev site: http://dev.catalyst.perl.org/ > > > > > > > > > _______________________________________________ > > > List: Catalyst at lists.scsys.co.uk > > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > > Searchable archive: http://www.mail-archive.com/ > > catalyst at lists.scsys.co.uk/ > > > Dev site: http://dev.catalyst.perl.org/ > > > > > > _______________________________________________ > > List: Catalyst at lists.scsys.co.uk > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > Searchable archive: http://www.mail-archive.com/ > > catalyst at lists.scsys.co.uk/ > > Dev site: http://dev.catalyst.perl.org/ > > > _______________________________________________ > List: Catalyst at lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/catalyst at lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ From rehak at tekkirk.org Sat Dec 10 14:44:59 2016 From: rehak at tekkirk.org (Martin =?utf-8?B?xZhlaMOhaw==?=) Date: Sat, 10 Dec 2016 15:44:59 +0100 Subject: [Catalyst] No database defaults with FormHandler and DBIC In-Reply-To: <20161210143610.4vh5zwyu4a6untgk@marvin.tekkirk.org> References: <20161031075723.GF6900@marvin.tekkirk.org> <031fcdce-0601-c7d1-cc9e-e2f6a3b5b20a@hidden-primary.net> <19cdde2b-f60c-ace4-efdb-41cb98951bc2@hidden-primary.net> <20161031160016.GH6900@marvin.tekkirk.org> <20161210143610.4vh5zwyu4a6untgk@marvin.tekkirk.org> Message-ID: <20161210144459.4xboi4t7kqchvkvz@marvin.tekkirk.org> Also form definition looks like this: has 'formDetail' => (isa => 'reha::Form::LessonDetail', is => 'rw', lazy => 1, default => sub {reha::Form::LessonDetail->new }); Is that right in case I would like to have database defaults used after process()? Regards -- M. On 2016.12.10 15:36:10 +0100, Martin ?eh?k wrote: > Hi Gerda, > > sorry for late reply. Didn't have time to look into this. > > Now I have: > > my $init_row = $c->model('DB::Lesson')->new_result({}); > $validated = $self->formDetail->process(item => $init_row); > > And I still don't see the database defaults in the rendered form. Any clue > where to look now? > > Thank you > -- > Martin > > On 2016.11.01 12:22:15 -0400, Gerda Shank wrote: > > A database row is used for defaults only if it is provided in the ?item? > > attribute. If you provide only the item_id and item_class they are used to > > update the row but not for defaults. > > > > Gerda > > > > > > On Mon, Oct 31, 2016 at 12:00 PM, Martin Rehak wrote: > > > > > Hi, > > > > > > thanks much for comments. > > > > > > I know there are number of ways how/where to set/define defaults from app > > > code > > > and there is large text written about it in Catalyst documentation. > > > > > > What I would expect to work at least is that database default is going to > > > be > > > propagated into the form from the schema definition. I don't need to have > > > the > > > second place with explicit default definition when there is and implicit > > > definition coming from db. > > > > > > In other words: > > > $ script/reha_create.pl model DB DBIC::Schema reha::Schema create=static > > > 'dbi:Pg:dbname=;host=' reha > > > > > > generates > > > > > > =head2 capacity > > > > > > data_type: 'integer' > > > default_value: 1 > > > is_nullable: 1 > > > > > > and there is the default definition successfully fetched from db. How to > > > get it > > > used without any override (and duplication) in the app code? > > > > > > Thank you very much in advance. > > > > > > Regards > > > -- > > > Martin > > > > > > On 2016.10.31 09:23:26 +0000, LNATION . wrote: > > > > Probs incorrect approach but it'll work.... > > > > > > > > before render => sub { > > > > unless ($_[0]->field('capacity')->value) { # mayb editing > > > > $_[0]->field('capacity')->value(1); > > > > } > > > > } > > > > > > > > On Mon, Oct 31, 2016 at 8:28 AM, Marc0 > > > wrote: > > > > > > > > > Am 31.10.2016 um 09:15 schrieb Marc0: > > > > > > Am 31.10.2016 um 08:57 schrieb Martin Rehak: > > > > > >> has_field 'capacity' => (type => 'PosInteger', > > > > > >> #default => '1', > > > > > >> label => 'Kapacita'); > > > > > > > > > > > > maybe add a "lazy => 1" to your commented "default => '1'"? > > > > > > > > > > > > has_field q(capacity) => ( > > > > > > type => q(PosInteger), > > > > > > lazy => 1, > > > > > > default => q(1), > > > > > > label => q(Kapacita), > > > > > > ); > > > > > > > > > > maybe "capacity" is explicitely set to undef, you could try an "around" > > > > > method modifier to check for a defined value: > > > > > > > > > > has_field q(capacity) => ( > > > > > is => q(ro), # just guessing > > > > > type => q(PosInteger), > > > > > lazy => 1, > > > > > default => q(1), > > > > > label => q(Kapacita), > > > > > writer => q(_set_default_capacity), > > > > > ); > > > > > > > > > > # untested, but according to Moose::Manual::MethodModifiers > > > > > around q(has_field) => sub { > > > > > my $orig = shift; > > > > > my $self = shift; > > > > > > > > > > # check for definedness and set to default value if > > > > > # not defined (NULL) > > > > > $self->_set_default_capacity(1) > > > > > unless defined $self->$orig(); > > > > > > > > > > return $self->$orig(); > > > > > }; > > > > > > > > > > Regards > > > > > -- > > > > > Marc0 > > > > > > > > > > _______________________________________________ > > > > > List: Catalyst at lists.scsys.co.uk > > > > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > > > > Searchable archive: http://www.mail-archive.com/ > > > > > catalyst at lists.scsys.co.uk/ > > > > > Dev site: http://dev.catalyst.perl.org/ > > > > > > > > > > > > _______________________________________________ > > > > List: Catalyst at lists.scsys.co.uk > > > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > > > Searchable archive: http://www.mail-archive.com/ > > > catalyst at lists.scsys.co.uk/ > > > > Dev site: http://dev.catalyst.perl.org/ > > > > > > > > > _______________________________________________ > > > List: Catalyst at lists.scsys.co.uk > > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > > Searchable archive: http://www.mail-archive.com/ > > > catalyst at lists.scsys.co.uk/ > > > Dev site: http://dev.catalyst.perl.org/ > > > > > > _______________________________________________ > > List: Catalyst at lists.scsys.co.uk > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > Searchable archive: http://www.mail-archive.com/catalyst at lists.scsys.co.uk/ > > Dev site: http://dev.catalyst.perl.org/ > From thisusedtobeanemail at gmail.com Sat Dec 10 15:41:39 2016 From: thisusedtobeanemail at gmail.com (LNATION .) Date: Sat, 10 Dec 2016 16:41:39 +0100 Subject: [Catalyst] No database defaults with FormHandler and DBIC In-Reply-To: References: <20161031075723.GF6900@marvin.tekkirk.org> <031fcdce-0601-c7d1-cc9e-e2f6a3b5b20a@hidden-primary.net> <19cdde2b-f60c-ace4-efdb-41cb98951bc2@hidden-primary.net> Message-ID: maybe something like ...... my $columns = $result->result_source->columns_info; my %default_form_spec; for my $name (keys %{$columns}){ if (my $default = $columns->{$name}->{default_value}) { $default_form_spec{ $name } = $default; } } -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisusedtobeanemail at gmail.com Sat Dec 10 15:50:46 2016 From: thisusedtobeanemail at gmail.com (LNATION .) Date: Sat, 10 Dec 2016 16:50:46 +0100 Subject: [Catalyst] No database defaults with FormHandler and DBIC In-Reply-To: References: <20161031075723.GF6900@marvin.tekkirk.org> <031fcdce-0601-c7d1-cc9e-e2f6a3b5b20a@hidden-primary.net> <19cdde2b-f60c-ace4-efdb-41cb98951bc2@hidden-primary.net> Message-ID: and then make a role role has default_column_spec => ( ...) before render => sub { while (my ($field, $default) = each %{ $_[0]->default_column_spec}{ unless ($_[0]->field($filed)->value) { # mayb editing $_[0]->field('$field)->value($default); } } } On Sat, Dec 10, 2016 at 4:41 PM, LNATION . wrote: > maybe something like ...... > > my $columns = $result->result_source->columns_info; > my %default_form_spec; > for my $name (keys %{$columns}){ > if (my $default = $columns->{$name}->{default_value}) { > $default_form_spec{ $name } = $default; > } > } > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisusedtobeanemail at gmail.com Sat Dec 10 15:51:52 2016 From: thisusedtobeanemail at gmail.com (LNATION .) Date: Sat, 10 Dec 2016 16:51:52 +0100 Subject: [Catalyst] No database defaults with FormHandler and DBIC In-Reply-To: References: <20161031075723.GF6900@marvin.tekkirk.org> <031fcdce-0601-c7d1-cc9e-e2f6a3b5b20a@hidden-primary.net> <19cdde2b-f60c-ace4-efdb-41cb98951bc2@hidden-primary.net> Message-ID: My email coding has some syntax errors, apologies. On Sat, Dec 10, 2016 at 4:50 PM, LNATION . wrote: > and then make a role role > > has default_column_spec => ( ...) > > before render => sub { > while (my ($field, $default) = each %{ $_[0]->default_column_spec}{ > unless ($_[0]->field($filed)->value) { # mayb editing > $_[0]->field('$field)->value($default); > } > } > } > > > On Sat, Dec 10, 2016 at 4:41 PM, LNATION . > wrote: > >> maybe something like ...... >> >> my $columns = $result->result_source->columns_info; >> my %default_form_spec; >> for my $name (keys %{$columns}){ >> if (my $default = $columns->{$name}->{default_value}) { >> $default_form_spec{ $name } = $default; >> } >> } >> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rehak at tekkirk.org Sat Dec 10 16:17:46 2016 From: rehak at tekkirk.org (Martin =?utf-8?B?xZhlaMOhaw==?=) Date: Sat, 10 Dec 2016 17:17:46 +0100 Subject: [Catalyst] No database defaults with FormHandler and DBIC In-Reply-To: References: <20161031075723.GF6900@marvin.tekkirk.org> <031fcdce-0601-c7d1-cc9e-e2f6a3b5b20a@hidden-primary.net> <19cdde2b-f60c-ace4-efdb-41cb98951bc2@hidden-primary.net> Message-ID: <20161210161746.qeca3vrm66dqr2uc@marvin.tekkirk.org> Hi, I understand that there is a complicated solution. I am looking for the simplest way. Doc says: For forms where you pass in an 'item' (usually a database row object), the values in that object will be used preferentially; if an accessor exists in the 'item' object, then the defaults won't be used. (If an accessor doesn't exist, the defaults *will* be used.) $form->process( item => $row, params => {} ); For the above call the 'default' on the field will not be used, which is usually what you want. What is the easiest way how to get defaults going from the database schema into a form, please? Is process() function able to propagate defaults from $row into $form? How to achieve that? Regards -- Martin On 2016.12.10 16:51:52 +0100, LNATION . wrote: > My email coding has some syntax errors, apologies. > > On Sat, Dec 10, 2016 at 4:50 PM, LNATION . > wrote: > > > and then make a role role > > > > has default_column_spec => ( ...) > > > > before render => sub { > > while (my ($field, $default) = each %{ $_[0]->default_column_spec}{ > > unless ($_[0]->field($filed)->value) { # mayb editing > > $_[0]->field('$field)->value($default); > > } > > } > > } > > > > > > On Sat, Dec 10, 2016 at 4:41 PM, LNATION . > > wrote: > > > >> maybe something like ...... > >> > >> my $columns = $result->result_source->columns_info; > >> my %default_form_spec; > >> for my $name (keys %{$columns}){ > >> if (my $default = $columns->{$name}->{default_value}) { > >> $default_form_spec{ $name } = $default; > >> } > >> } > >> > >> > >> > > > _______________________________________________ > List: Catalyst at lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/catalyst at lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ From thisusedtobeanemail at gmail.com Sat Dec 10 16:48:25 2016 From: thisusedtobeanemail at gmail.com (LNATION .) Date: Sat, 10 Dec 2016 17:48:25 +0100 Subject: [Catalyst] No database defaults with FormHandler and DBIC In-Reply-To: <20161210161746.qeca3vrm66dqr2uc@marvin.tekkirk.org> References: <20161031075723.GF6900@marvin.tekkirk.org> <031fcdce-0601-c7d1-cc9e-e2f6a3b5b20a@hidden-primary.net> <19cdde2b-f60c-ace4-efdb-41cb98951bc2@hidden-primary.net> <20161210161746.qeca3vrm66dqr2uc@marvin.tekkirk.org> Message-ID: The problem I think is when you call >new_result the default value from your database does get **populated that happens when on insert.... On Sat, Dec 10, 2016 at 5:17 PM, Martin ?eh?k wrote: > Hi, > > I understand that there is a complicated solution. I am looking for > the simplest way. > > Doc says: > > > For forms where you pass in an 'item' (usually a database row object), > the values in that object will be used preferentially; if an accessor > exists in the 'item' object, then the defaults won't be used. (If an > accessor doesn't exist, the defaults *will* be used.) > > $form->process( item => $row, params => {} ); > > For the above call the 'default' on the field will not be used, which is > usually what you want. > > > What is the easiest way how to get defaults going from the database > schema into a form, please? Is process() function able to propagate > defaults from $row into $form? How to achieve that? > > Regards > -- > Martin > > On 2016.12.10 16:51:52 +0100, LNATION . wrote: > > My email coding has some syntax errors, apologies. > > > > On Sat, Dec 10, 2016 at 4:50 PM, LNATION . < > thisusedtobeanemail at gmail.com> > > wrote: > > > > > and then make a role role > > > > > > has default_column_spec => ( ...) > > > > > > before render => sub { > > > while (my ($field, $default) = each %{ > $_[0]->default_column_spec}{ > > > unless ($_[0]->field($filed)->value) { # mayb editing > > > $_[0]->field('$field)->value($default); > > > } > > > } > > > } > > > > > > > > > On Sat, Dec 10, 2016 at 4:41 PM, LNATION . < > thisusedtobeanemail at gmail.com> > > > wrote: > > > > > >> maybe something like ...... > > >> > > >> my $columns = $result->result_source->columns_info; > > >> my %default_form_spec; > > >> for my $name (keys %{$columns}){ > > >> if (my $default = $columns->{$name}->{default_value}) { > > >> $default_form_spec{ $name } = $default; > > >> } > > >> } > > >> > > >> > > >> > > > > > > _______________________________________________ > > List: Catalyst at lists.scsys.co.uk > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > Searchable archive: http://www.mail-archive.com/ > catalyst at lists.scsys.co.uk/ > > Dev site: http://dev.catalyst.perl.org/ > > > _______________________________________________ > List: Catalyst at lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/ > catalyst at lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: From thisusedtobeanemail at gmail.com Sat Dec 10 17:00:05 2016 From: thisusedtobeanemail at gmail.com (LNATION .) Date: Sat, 10 Dec 2016 18:00:05 +0100 Subject: [Catalyst] No database defaults with FormHandler and DBIC In-Reply-To: References: <20161031075723.GF6900@marvin.tekkirk.org> <031fcdce-0601-c7d1-cc9e-e2f6a3b5b20a@hidden-primary.net> <19cdde2b-f60c-ace4-efdb-41cb98951bc2@hidden-primary.net> <20161210161746.qeca3vrm66dqr2uc@marvin.tekkirk.org> Message-ID: Sorry Long day :) corrected sentence... The problem is because when you call ->new_result the default_value does not get set, which is reasonable behavior the moment you are dealing with time. I am unsure whether there is another create method which uses database or even the schema column spec. Regards Robert On Sat, Dec 10, 2016 at 5:48 PM, LNATION . wrote: > The problem I think is when you call >new_result the default value from > your database does get **populated that happens when on insert.... > > On Sat, Dec 10, 2016 at 5:17 PM, Martin ?eh?k wrote: > >> Hi, >> >> I understand that there is a complicated solution. I am looking for >> the simplest way. >> >> Doc says: >> >> >> For forms where you pass in an 'item' (usually a database row object), >> the values in that object will be used preferentially; if an accessor >> exists in the 'item' object, then the defaults won't be used. (If an >> accessor doesn't exist, the defaults *will* be used.) >> >> $form->process( item => $row, params => {} ); >> >> For the above call the 'default' on the field will not be used, which is >> usually what you want. >> >> >> What is the easiest way how to get defaults going from the database >> schema into a form, please? Is process() function able to propagate >> defaults from $row into $form? How to achieve that? >> >> Regards >> -- >> Martin >> >> On 2016.12.10 16:51:52 +0100, LNATION . wrote: >> > My email coding has some syntax errors, apologies. >> > >> > On Sat, Dec 10, 2016 at 4:50 PM, LNATION . < >> thisusedtobeanemail at gmail.com> >> > wrote: >> > >> > > and then make a role role >> > > >> > > has default_column_spec => ( ...) >> > > >> > > before render => sub { >> > > while (my ($field, $default) = each %{ >> $_[0]->default_column_spec}{ >> > > unless ($_[0]->field($filed)->value) { # mayb editing >> > > $_[0]->field('$field)->value($default); >> > > } >> > > } >> > > } >> > > >> > > >> > > On Sat, Dec 10, 2016 at 4:41 PM, LNATION . < >> thisusedtobeanemail at gmail.com> >> > > wrote: >> > > >> > >> maybe something like ...... >> > >> >> > >> my $columns = $result->result_source->columns_info; >> > >> my %default_form_spec; >> > >> for my $name (keys %{$columns}){ >> > >> if (my $default = $columns->{$name}->{default_value}) { >> > >> $default_form_spec{ $name } = $default; >> > >> } >> > >> } >> > >> >> > >> >> > >> >> > > >> >> > _______________________________________________ >> > List: Catalyst at lists.scsys.co.uk >> > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst >> > Searchable archive: http://www.mail-archive.com/ca >> talyst at lists.scsys.co.uk/ >> > Dev site: http://dev.catalyst.perl.org/ >> >> >> _______________________________________________ >> List: Catalyst at lists.scsys.co.uk >> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst >> Searchable archive: http://www.mail-archive.com/ca >> talyst at lists.scsys.co.uk/ >> Dev site: http://dev.catalyst.perl.org/ >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ken at kenbeal.com Sat Dec 10 20:45:27 2016 From: ken at kenbeal.com (Ken Beal) Date: Sat, 10 Dec 2016 15:45:27 -0500 Subject: [Catalyst] Using Komodo to edit/debug Catalyst Message-ID: Hi, Years ago I used the ActiveState IDE Komodo to work with Catalyst. I'd like to do this again, but am no longer at that employer so can't check the settings. I asked at the ActiveState Komodo forums but haven't gotten a good answer (last was "compare the env vars" which I did but didn't see any real differences, other than x86/x64, as Komodo appears to be an x86 app). http://community.komodoide.com/t/how-to-edit-catalyst-source-files-with-proper-syntax-checking/3204/7 I figure asking here might provide a better answer since people here are "debugging Catalyst apps" so should be able to provide pointers to how to do so. (Versus Komodo being used to debug a whole bunch of other stuff, i.e., I might have better luck with the domain knowledge here.) Thanks, Ken -- "Look at what's happened to me; I can't believe it myself!" -------------- next part -------------- An HTML attachment was scrubbed... URL: From diment at gmail.com Sun Dec 11 03:17:41 2016 From: diment at gmail.com (Kieren Diment) Date: Sun, 11 Dec 2016 14:17:41 +1100 Subject: [Catalyst] Using Komodo to edit/debug Catalyst In-Reply-To: References: Message-ID: I just use perl -d from the console. perl -d script/myapp.pl (or more modernly perl -d `which plackup` myapp.psgi) and set breakpoints in the code with $DB::single=1 as required. See also LWP::Protocol::PSGI for serverless psgi deployment mainly for use in test scripts. On Sun, Dec 11, 2016 at 7:45 AM, Ken Beal wrote: > Hi, > > Years ago I used the ActiveState IDE Komodo to work with Catalyst. I'd > like to do this again, but am no longer at that employer so can't check the > settings. > > I asked at the ActiveState Komodo forums but haven't gotten a good answer > (last was "compare the env vars" which I did but didn't see any real > differences, other than x86/x64, as Komodo appears to be an x86 app). > http://community.komodoide.com/t/how-to-edit-catalyst- > source-files-with-proper-syntax-checking/3204/7 > > I figure asking here might provide a better answer since people here are > "debugging Catalyst apps" so should be able to provide pointers to how to > do so. (Versus Komodo being used to debug a whole bunch of other stuff, > i.e., I might have better luck with the domain knowledge here.) > > Thanks, > Ken > -- > "Look at what's happened to me; > I can't believe it myself!" > > _______________________________________________ > List: Catalyst at lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/ > catalyst at lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From igavus at gmail.com Sun Dec 11 07:32:11 2016 From: igavus at gmail.com (Toomas P) Date: Sun, 11 Dec 2016 09:32:11 +0200 Subject: [Catalyst] Using Komodo to edit/debug Catalyst In-Reply-To: References: Message-ID: While I don't do my debugging inside the IDE, I'm happy with what IntelliJ IDEA's Perl plugin does. Before that, I was using Komodo same as you. 2016-12-11 5:17 GMT+02:00 Kieren Diment : > I just use perl -d from the console. > > perl -d script/myapp.pl (or more modernly perl -d `which plackup` > myapp.psgi) and set breakpoints in the code with $DB::single=1 as > required. See also LWP::Protocol::PSGI for serverless psgi deployment > mainly for use in test scripts. > > On Sun, Dec 11, 2016 at 7:45 AM, Ken Beal wrote: > >> Hi, >> >> Years ago I used the ActiveState IDE Komodo to work with Catalyst. I'd >> like to do this again, but am no longer at that employer so can't check the >> settings. >> >> I asked at the ActiveState Komodo forums but haven't gotten a good answer >> (last was "compare the env vars" which I did but didn't see any real >> differences, other than x86/x64, as Komodo appears to be an x86 app). >> http://community.komodoide.com/t/how-to-edit-catalyst-sourc >> e-files-with-proper-syntax-checking/3204/7 >> >> I figure asking here might provide a better answer since people here are >> "debugging Catalyst apps" so should be able to provide pointers to how to >> do so. (Versus Komodo being used to debug a whole bunch of other stuff, >> i.e., I might have better luck with the domain knowledge here.) >> >> Thanks, >> Ken >> -- >> "Look at what's happened to me; >> I can't believe it myself!" >> >> _______________________________________________ >> List: Catalyst at lists.scsys.co.uk >> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst >> Searchable archive: http://www.mail-archive.com/ca >> talyst at lists.scsys.co.uk/ >> Dev site: http://dev.catalyst.perl.org/ >> >> > > _______________________________________________ > List: Catalyst at lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/ > catalyst at lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ > > -- Nothing is ever easy -------------- next part -------------- An HTML attachment was scrubbed... URL: From rehak at tekkirk.org Sun Dec 11 18:37:37 2016 From: rehak at tekkirk.org (Martin =?utf-8?B?xZhlaMOhaw==?=) Date: Sun, 11 Dec 2016 19:37:37 +0100 Subject: [Catalyst] No database defaults with FormHandler and DBIC In-Reply-To: References: <031fcdce-0601-c7d1-cc9e-e2f6a3b5b20a@hidden-primary.net> <19cdde2b-f60c-ace4-efdb-41cb98951bc2@hidden-primary.net> <20161210161746.qeca3vrm66dqr2uc@marvin.tekkirk.org> Message-ID: <20161211183737.ok5s2o4lovym3yvp@marvin.tekkirk.org> Hi, thank you for kickstarting me. I still don't understand there is no such method provided by DBIx already I have resolved the issue with this diff: diff -r d65de14e366f lib/reha/Controller/Lesson.pm --- a/lib/reha/Controller/Lesson.pm Sat Dec 10 17:22:07 2016 +0100 +++ b/lib/reha/Controller/Lesson.pm Sun Dec 11 19:35:28 2016 +0100 @@ -54,17 +54,9 @@ my ($self, $c, $lesson_id) = @_; my ($validated); - my $init_row = $c->model('DB::Lesson')->new_result({}); + my $row = $c->model('DB::Lesson')->find_or_default({id => $lesson_id}); $validated = $self->formDetail->process( - item => $init_row, + item => $row, params => $c->req->parameters); if ($validated) { diff -r d65de14e366f lib/reha/Schema.pm --- a/lib/reha/Schema.pm Sat Dec 10 17:22:07 2016 +0100 +++ b/lib/reha/Schema.pm Sun Dec 11 19:35:28 2016 +0100 @@ -8,7 +8,9 @@ use MooseX::MarkAsMethods autoclean => 1; extends 'DBIx::Class::Schema'; -__PACKAGE__->load_namespaces; +__PACKAGE__->load_namespaces( + default_resultset_class => '+reha::Schema::ResultSet::Base', + resultset_namespace => 'Base'); # Created by DBIx::Class::Schema::Loader v0.07043 @ 2016-02-05 16:52:32 diff -r d65de14e366f lib/reha/Schema/ResultSet/Base.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/reha/Schema/ResultSet/Base.pm Sun Dec 11 19:35:28 2016 +0100 @@ -0,0 +1,28 @@ +package reha::Schema::ResultSet::Base; + +use strict; +use warnings; + +use base 'DBIx::Class::ResultSet'; + +sub find_or_default { + my $self = shift; + my $attrs = (@_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {}); + my $hash = ref $_[0] eq 'HASH' ? shift : {@_}; + my $row; + + # return data if found + if (keys %$hash and $row = $self->find($hash, $attrs) ) { + return $row; + } + + # return new result with defaults prefilled + $row = $self->new_result($hash); + foreach my $col ($row->result_source->columns) { + my $default = $row->result_source->column_info($col)->{default_value}; + $row->$col($default) if($default && !defined $row->$col()); + } + return $row; +} + +1; Thank you very much all for patience with my issue. Regards -- Martin On 2016.12.10 18:00:05 +0100, LNATION . wrote: > Sorry Long day :) corrected sentence... > > The problem is because when you call ->new_result the default_value does > not get set, which is reasonable behavior the moment you are dealing with > time. I am unsure whether there is another create method which uses > database or even the schema column spec. > > Regards > > Robert > > On Sat, Dec 10, 2016 at 5:48 PM, LNATION . > wrote: > > > The problem I think is when you call >new_result the default value from > > your database does get **populated that happens when on insert.... > > > > On Sat, Dec 10, 2016 at 5:17 PM, Martin ?eh?k wrote: > > > >> Hi, > >> > >> I understand that there is a complicated solution. I am looking for > >> the simplest way. > >> > >> Doc says: > >> > >> > >> For forms where you pass in an 'item' (usually a database row object), > >> the values in that object will be used preferentially; if an accessor > >> exists in the 'item' object, then the defaults won't be used. (If an > >> accessor doesn't exist, the defaults *will* be used.) > >> > >> $form->process( item => $row, params => {} ); > >> > >> For the above call the 'default' on the field will not be used, which is > >> usually what you want. > >> > >> > >> What is the easiest way how to get defaults going from the database > >> schema into a form, please? Is process() function able to propagate > >> defaults from $row into $form? How to achieve that? > >> > >> Regards > >> -- > >> Martin > >> > >> On 2016.12.10 16:51:52 +0100, LNATION . wrote: > >> > My email coding has some syntax errors, apologies. > >> > > >> > On Sat, Dec 10, 2016 at 4:50 PM, LNATION . < > >> thisusedtobeanemail at gmail.com> > >> > wrote: > >> > > >> > > and then make a role role > >> > > > >> > > has default_column_spec => ( ...) > >> > > > >> > > before render => sub { > >> > > while (my ($field, $default) = each %{ > >> $_[0]->default_column_spec}{ > >> > > unless ($_[0]->field($filed)->value) { # mayb editing > >> > > $_[0]->field('$field)->value($default); > >> > > } > >> > > } > >> > > } > >> > > > >> > > > >> > > On Sat, Dec 10, 2016 at 4:41 PM, LNATION . < > >> thisusedtobeanemail at gmail.com> > >> > > wrote: > >> > > > >> > >> maybe something like ...... > >> > >> > >> > >> my $columns = $result->result_source->columns_info; > >> > >> my %default_form_spec; > >> > >> for my $name (keys %{$columns}){ > >> > >> if (my $default = $columns->{$name}->{default_value}) { > >> > >> $default_form_spec{ $name } = $default; > >> > >> } > >> > >> } > >> > >> > >> > >> > >> > >> > >> > > > >> > >> > _______________________________________________ > >> > List: Catalyst at lists.scsys.co.uk > >> > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > >> > Searchable archive: http://www.mail-archive.com/ca > >> talyst at lists.scsys.co.uk/ > >> > Dev site: http://dev.catalyst.perl.org/ > >> > >> > >> _______________________________________________ > >> List: Catalyst at lists.scsys.co.uk > >> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > >> Searchable archive: http://www.mail-archive.com/ca > >> talyst at lists.scsys.co.uk/ > >> Dev site: http://dev.catalyst.perl.org/ > >> > > > > > _______________________________________________ > List: Catalyst at lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/catalyst at lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ From thisusedtobeanemail at gmail.com Mon Dec 12 07:05:34 2016 From: thisusedtobeanemail at gmail.com (LNATION .) Date: Mon, 12 Dec 2016 08:05:34 +0100 Subject: [Catalyst] No database defaults with FormHandler and DBIC In-Reply-To: <20161211183737.ok5s2o4lovym3yvp@marvin.tekkirk.org> References: <031fcdce-0601-c7d1-cc9e-e2f6a3b5b20a@hidden-primary.net> <19cdde2b-f60c-ace4-efdb-41cb98951bc2@hidden-primary.net> <20161210161746.qeca3vrm66dqr2uc@marvin.tekkirk.org> <20161211183737.ok5s2o4lovym3yvp@marvin.tekkirk.org> Message-ID: Good morning Martin I wrote this Saturday night, it uses Moose as both HTML::FormHandler and Catalyst do... as long as result_source->columns_info gives you what I think, it should work... beware I only wrote on quick test :) https://github.com/ThisUsedToBeAnEmail/HTML-FormHandler-Role-Default/blob/master/lib/HTML/FormHandler/Role/Default.pm If you're adamant on having this logic in your schema I would looking into just writing a new_with_defaults method where you just loop through the Results column info build a hash and then return new_result(%defaults). Regards, Robert. On Sun, Dec 11, 2016 at 7:37 PM, Martin ?eh?k wrote: > Hi, > > thank you for kickstarting me. I still don't understand there is no such > method > provided by DBIx already I have resolved the issue with this diff: > > diff -r d65de14e366f lib/reha/Controller/Lesson.pm > --- a/lib/reha/Controller/Lesson.pm Sat Dec 10 17:22:07 2016 +0100 > +++ b/lib/reha/Controller/Lesson.pm Sun Dec 11 19:35:28 2016 +0100 > @@ -54,17 +54,9 @@ > my ($self, $c, $lesson_id) = @_; > my ($validated); > > - my $init_row = $c->model('DB::Lesson')->new_result({}); > + my $row = $c->model('DB::Lesson')->find_or_default({id => > $lesson_id}); > $validated = $self->formDetail->process( > - item => $init_row, > + item => $row, > params => $c->req->parameters); > > if ($validated) { > diff -r d65de14e366f lib/reha/Schema.pm > --- a/lib/reha/Schema.pm Sat Dec 10 17:22:07 2016 +0100 > +++ b/lib/reha/Schema.pm Sun Dec 11 19:35:28 2016 +0100 > @@ -8,7 +8,9 @@ > use MooseX::MarkAsMethods autoclean => 1; > extends 'DBIx::Class::Schema'; > > -__PACKAGE__->load_namespaces; > +__PACKAGE__->load_namespaces( > + default_resultset_class => '+reha::Schema::ResultSet::Base', > + resultset_namespace => 'Base'); > > > # Created by DBIx::Class::Schema::Loader v0.07043 @ 2016-02-05 16:52:32 > diff -r d65de14e366f lib/reha/Schema/ResultSet/Base.pm > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/lib/reha/Schema/ResultSet/Base.pm Sun Dec 11 19:35:28 2016 +0100 > @@ -0,0 +1,28 @@ > +package reha::Schema::ResultSet::Base; > + > +use strict; > +use warnings; > + > +use base 'DBIx::Class::ResultSet'; > + > +sub find_or_default { > + my $self = shift; > + my $attrs = (@_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {}); > + my $hash = ref $_[0] eq 'HASH' ? shift : {@_}; > + my $row; > + > + # return data if found > + if (keys %$hash and $row = $self->find($hash, $attrs) ) { > + return $row; > + } > + > + # return new result with defaults prefilled > + $row = $self->new_result($hash); > + foreach my $col ($row->result_source->columns) { > + my $default = $row->result_source->column_ > info($col)->{default_value}; > + $row->$col($default) if($default && !defined $row->$col()); > + } > + return $row; > +} > + > +1; > > Thank you very much all for patience with my issue. > > Regards > -- > Martin > > On 2016.12.10 18:00:05 +0100, LNATION . wrote: > > Sorry Long day :) corrected sentence... > > > > The problem is because when you call ->new_result the default_value does > > not get set, which is reasonable behavior the moment you are dealing with > > time. I am unsure whether there is another create method which uses > > database or even the schema column spec. > > > > Regards > > > > Robert > > > > On Sat, Dec 10, 2016 at 5:48 PM, LNATION . < > thisusedtobeanemail at gmail.com> > > wrote: > > > > > The problem I think is when you call >new_result the default value from > > > your database does get **populated that happens when on insert.... > > > > > > On Sat, Dec 10, 2016 at 5:17 PM, Martin ?eh?k > wrote: > > > > > >> Hi, > > >> > > >> I understand that there is a complicated solution. I am looking for > > >> the simplest way. > > >> > > >> Doc says: > > >> > > >> > > >> For forms where you pass in an 'item' (usually a database row object), > > >> the values in that object will be used preferentially; if an accessor > > >> exists in the 'item' object, then the defaults won't be used. (If an > > >> accessor doesn't exist, the defaults *will* be used.) > > >> > > >> $form->process( item => $row, params => {} ); > > >> > > >> For the above call the 'default' on the field will not be used, which > is > > >> usually what you want. > > >> > > >> > > >> What is the easiest way how to get defaults going from the database > > >> schema into a form, please? Is process() function able to propagate > > >> defaults from $row into $form? How to achieve that? > > >> > > >> Regards > > >> -- > > >> Martin > > >> > > >> On 2016.12.10 16:51:52 +0100, LNATION . wrote: > > >> > My email coding has some syntax errors, apologies. > > >> > > > >> > On Sat, Dec 10, 2016 at 4:50 PM, LNATION . < > > >> thisusedtobeanemail at gmail.com> > > >> > wrote: > > >> > > > >> > > and then make a role role > > >> > > > > >> > > has default_column_spec => ( ...) > > >> > > > > >> > > before render => sub { > > >> > > while (my ($field, $default) = each %{ > > >> $_[0]->default_column_spec}{ > > >> > > unless ($_[0]->field($filed)->value) { # mayb editing > > >> > > $_[0]->field('$field)->value($default); > > >> > > } > > >> > > } > > >> > > } > > >> > > > > >> > > > > >> > > On Sat, Dec 10, 2016 at 4:41 PM, LNATION . < > > >> thisusedtobeanemail at gmail.com> > > >> > > wrote: > > >> > > > > >> > >> maybe something like ...... > > >> > >> > > >> > >> my $columns = $result->result_source->columns_info; > > >> > >> my %default_form_spec; > > >> > >> for my $name (keys %{$columns}){ > > >> > >> if (my $default = $columns->{$name}->{default_value}) { > > >> > >> $default_form_spec{ $name } = $default; > > >> > >> } > > >> > >> } > > >> > >> > > >> > >> > > >> > >> > > >> > > > > >> > > >> > _______________________________________________ > > >> > List: Catalyst at lists.scsys.co.uk > > >> > Listinfo: http://lists.scsys.co.uk/cgi- > bin/mailman/listinfo/catalyst > > >> > Searchable archive: http://www.mail-archive.com/ca > > >> talyst at lists.scsys.co.uk/ > > >> > Dev site: http://dev.catalyst.perl.org/ > > >> > > >> > > >> _______________________________________________ > > >> List: Catalyst at lists.scsys.co.uk > > >> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > >> Searchable archive: http://www.mail-archive.com/ca > > >> talyst at lists.scsys.co.uk/ > > >> Dev site: http://dev.catalyst.perl.org/ > > >> > > > > > > > > > _______________________________________________ > > List: Catalyst at lists.scsys.co.uk > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > Searchable archive: http://www.mail-archive.com/ > catalyst at lists.scsys.co.uk/ > > Dev site: http://dev.catalyst.perl.org/ > > > _______________________________________________ > List: Catalyst at lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/ > catalyst at lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: