Re: Rose::HTMLx::Form::Related::RDBO

40 views
Skip to first unread message

ghav...@materialisations.com

unread,
Jul 14, 2011, 8:55:27 PM7/14/11
to Rose::HTML::Objects
I'm working with an application (database) where just about everything
is an enumeration. Consequently, what makes the most sense for me is
generating forms where just about everything is a PopUpMenu. And it
is not possible for a computer program to validate any of this data.
The thing I am writing helps engineers validate the data (FYI).

But, I decided to try Rose::HTMLx::Form::Related::RDBO just to see
what would happen (look at the ->html output). There is man page for
RHFRR, it shows how to set up a perl module file (package) to use it.
There is a man page for RHFR which shows a similar thing. There is no
man page for RHF, saying how to actually use this. (Substitute
perldoc for man if you want.) Looking at google, I can't find any
examples of how people actually use this.

Can anyone point to an example, or write one?

Thanks.
Gord

John Siracusa

unread,
Jul 14, 2011, 9:12:22 PM7/14/11
to rose-htm...@googlegroups.com

You're looking for an example of Rose::HTML::Form in use? How about
the synopsis here?

http://search.cpan.org/dist/Rose-HTML-Objects/lib/Rose/HTML/Form.pm

-John

Peter Karman

unread,
Jul 14, 2011, 9:18:56 PM7/14/11
to Rose::HTML::Objects


On Jul 14, 7:55 pm, "ghave...@materialisations.com"
<ghave...@materialisations.com> wrote:
> I'm working with an application (database) where just about everything
> is an enumeration.  Consequently, what makes the most sense for me is
> generating forms where just about everything is a PopUpMenu.  And it
> is not possible for a computer program to validate any of this data.
> The thing I am writing helps engineers validate the data (FYI).

Might you want http://search.cpan.org/dist/Rose-HTMLx-Form-Field-PopUpMenuNumeric/
?


>
> But, I decided to try Rose::HTMLx::Form::Related::RDBO just to see
> what would happen (look at the ->html output).  There is man page for
> RHFRR, it shows how to set up a perl module file (package) to use it.
> There is a man page for RHFR which shows a similar thing.  There is no
> man page for RHF, saying how to actually use this.  (Substitute
> perldoc for man if you want.)  Looking at google, I can't find any
> examples of how people actually use this.
>
> Can anyone point to an example, or write one?
>

The docs for RHxFR are woefully lacking in examples and the author
should be severely reprimanded for such shoddy work.

For each Form class, I do something like this:

------------------------------------
package My::Form;
use strict;
use Carp;
use base qw( Rose::HTMLx::Form::Related::RDBO );

sub init_metadata {
my $self = shift;
return $self->metadata_class->new(
form => $self,
object_class => 'My::RDBOClass',
);
}

1;
-----------------------


which assumes one Form class == one RDBO class.

Then you use the My::Form class just like you use Rose::HTML::Form.

RHxFR is used extensively by CatalystX::CRUD::YUI.

Let me know if that doesn't get you in the right direction. You can
also check out the http://groups.google.com/group/catalystxcrud list.

pek

Gordon Haverland

unread,
Jul 15, 2011, 2:46:38 PM7/15/11
to rose-htm...@googlegroups.com
On July 14, 2011, John Siracusa wrote:
> On Thu, Jul 14, 2011 at 8:55 PM, ghav...@materialisations.com
> <ghav...@materialisations.com> wrote:
> > I'm working with an application (database) where just about
> > everything is an enumeration.

Thanks for replying John and Peter.

Starting from the RHFRR man page (perldoc)
package MyRDBO::Class::Form;
use strict;
use base qw( Rose::HTMLx::Form::Related::RDBO );

sub init_object_class { 'MyRDBO::Class' }

1;
I get an error that I must define init_metadata(), or pass a
metadata object in the new(). I presume it is looking for
metadata on MyRDBO::Class, and I also presume that the
init_object_class method defined above is meant to provide the
information required, which means I must have something screwed up
to be seeing the message. Thinking the tests might have an
answer, I notice that the DBIC example has init_app_class()
instead of init_object_class(). Neither (or both together) works.
Having:
use MyRDBO::Class;
defined above (after the use base statement), doesn't help
anything.

Going back to my test program, I generate a metadata object and
pass it as an argument in the new():

use Rose::DB::Object::Metadata;
my $meta = Rose::DB::Object::Metadata->new( class =>
'MyRDBO::Class' );
my $formx = MyRDBO::Class::Form::TableName->new( $meta );

And this gets a different error. But, I've been single stepping
perldb in emacs for 6 hours already today and I figured that I
would send another note, while I take a break.

I've been changing package names above to match the POD, the dump
below has the original names.

Cannot set element for EngMaterielSpec::FormX::BranchTable at
/home/ghaverla/src/perl/rheaume/Mojolicious/Lite/bh.pl line 24
at /usr/local/share/perl/5.12.3/Rose/HTML/Form/Field.pm line 684

Rose::HTML::Form::Field::element('EngMaterielSpec::FormX::BranchTable=HASH(0xa180e00)',
'Rose::DB::Object::Metadata=HASH(0xb830064)') called at
/usr/share/perl5/Rose/Object.pm line 25

Rose::Object::init('EngMaterielSpec::FormX::BranchTable=HASH(0xa180e00)',
'element', 'Rose::DB::Object::Metadata=HASH(0xb830064)') called at
/usr/local/share/perl/5.12.3/Rose/HTML/Object.pm line 280
Rose::HTML::Object::init('element',
'Rose::DB::Object::Metadata=HASH(0xb830064)') called at
/usr/local/share/perl/5.12.3/Rose/HTML/Form.pm line 186

Rose::HTML::Form::init('EngMaterielSpec::FormX::BranchTable=HASH(0xa180e00)',
'Rose::DB::Object::Metadata=HASH(0xb830064)') called at
/usr/local/share/perl/5.12.3/Rose/HTMLx/Form/Related.pm line 68

Rose::HTMLx::Form::Related::init('EngMaterielSpec::FormX::BranchTable=HASH(0xa180e00)',
'Rose::DB::Object::Metadata=HASH(0xb830064)') called at
/usr/local/share/perl/5.12.3/Rose/HTML/Form.pm line 125
Rose::HTML::Form::new('EngMaterielSpec::FormX::BranchTable',
'Rose::DB::Object::Metadata=HASH(0xb830064)') called at
/home/ghaverla/src/perl/rheaume/Mojolicious/Lite/bh.pl line 24


Gord

Gordon Haverland

unread,
Jul 16, 2011, 7:28:15 PM7/16/11
to rose-htm...@googlegroups.com
On July 14, 2011, John Siracusa wrote:
> On Thu, Jul 14, 2011 at 8:55 PM, ghav...@materialisations.com

[ snip ]

I don't know. I can get my own routines which generate popupmenus
of stuff to work, but doing something simple like having this
module (HTFRR) generate a form for a table that consists of 2
columns, one is a primary key and the other is a UNIQUE column
just keeps coming up with errors. Single stepping through things
and looking at variables, it is not apparent what the problem is.
But, there are vanishingly few comments in the code, so I have no
idea if having empty lists in certain places is unusual or not.

If the generic .pm in the perldoc works for some people, but
generates errors for me, all I can think of is there is something
in my configuration which is "wrong". And I've pretty much
exhausted what I can change in doing this. Heck, I was using
FormX as a directory early on, and I thought maybe something was
sensitive to that capital X at the end, so I changed the modules,
packages and directories to use Form. No difference, the same
error messages.

The other thing that comes to mind, is that there is vanshingly
little data in what I have in my database (most of the data is an
enumeration of some kind). Most tables have primary keys, and
most tables with more than 2 columns are filled with foreign keys.
And there are 3 pivot tables present for Many-to-Many
relationships. Is interrelated giving up?

At this point, I am going to give up on Related::RDBO. I really
didn't think it was going to help my situation because of how
dense the foreign keys are: but between the documentation, the
test examples in the CPAN module and the source, I have no idea
where the problem is.

Gord

Peter Karman

unread,
Jul 16, 2011, 9:42:57 PM7/16/11
to Rose::HTML::Objects


On Jul 16, 6:28 pm, Gordon Haverland <ghave...@materialisations.com>
wrote:
> On July 14, 2011, John Siracusa wrote:
>
> > On Thu, Jul 14, 2011 at 8:55 PM, ghave...@materialisations.com
>
> [ snip ]
>
> I don't know.  I can get my own routines which generate popupmenus
> of stuff to work, but doing something simple like having this
> module (HTFRR) generate a form for a table that consists of 2
> columns, one is a primary key and the other is a UNIQUE column
> just keeps coming up with errors.  Single stepping through things
> and looking at variables, it is not apparent what the problem is.  
> But, there are vanishingly few comments in the code, so I have no
> idea if having empty lists in certain places is unusual or not.

Thanks for your diligence and good feedback on using RHxFR. It has not
been, to my knowledge, used much outside the module
(CatalystX::CRUD::YUI) from which it was originally spun off, so the
docs are pitiful, I know. RHxFR is mostly useful when you are aiming
for a very tight coupling between your model (e.g. RDBO) and your view
(presentation layer) because it makes the presentation layer more
aware of its internal relationships.

I've added actual RDBO tests to svn that illustrate how to use the
RDBO-based Forms.

https://svn.msi.umn.edu/sw/perl/Rose-HTMLx-Form-Related/trunk/t/01-rdbo.t

Hope those help a bit.

Having said all that, it's not really clear to me what, exactly,
you're trying to accomplish. From your other email it sounded like you
were trying to create a web front-end to an existing database with no
CSS or JS dependencies. If you're using both RDBO and RHTMLO, then I
suggest trying Rose::DBx::Garden, which will interrogate an existing
db and create both the RDBO and RHTMLO classes for you. If you wanted
to then use the interrelated magic of RHxFR, you could simply change
the ISA definition in the base Form class and all the generated Form
classes should then just Do the Right Thing.
Reply all
Reply to author
Forward
0 new messages