List Info

Thread: RDBO/RHTMLO integration with Catalyst - work in progress




RDBO/RHTMLO integration with Catalyst - work in progress
country flaguser name
France
2007-07-21 07:56:09
	Hello lists,

	Since I haven't seen any work like this before (if I'm
wrong please 
give me pointers!) I started to write a Catalyst Controller
called 
"Catalyst::Controller::RHTMLO" to integrate RHTMLO
(and a few bits of 
RDBO) to Catalyst the same way
"Catalyst::Controller::FormBuilder" do. 
In fact my work is originally based on it.

	For the moment the only thing one can do with it is to
define a form in 
YAML (or any config file recognized by
"Config::Loader") and have it 
displayed in the template (TT2 for the moment, but others
are planned).

	The module also defines, like the FormBuilder one, a 'Form'
method 
attribute. The plan is to have forms automagically validated
and, if no 
errors, give the user (developper) the ability to save them
as objects 
in the db. Else, the error messages are set for user
convenience.

	Here is an example of a YAML file for the action
"/user/create", 
located in .../root/forms/user/create.yaml:
--------------------------------------------------------
name:   UserCreateForm # optional, automatically computed
method: post
rdbo:   User # class of the rdbo object, used to load/save
objects and 
also for field init (see below, types are sometimes missing,
but it works)
fields_order:
         - login
         - disp_name
         - mail
         - disp_mail
         - home_page
         - pass
         - pass2
         - submit
fields:
         login:
                 label:    Login
                 validate: /^.{4,40}$/, /^w*$/
                 message:  Between 4 and 40 characters, Only

alphanumeric characters
                 required: 1
         disp_name:
                 label:    Real name (public)
                 validate: /^.{0,50}$/, /^[w.-()]*$/
                 message:  Max 50 characters, Forbidden
character(s)
         mail:
                 label:    Real Email
                 type:     email
                 message:  Invalid Email
                 required: 1
         disp_mail:
                 label:    Displayed Email (public)
                 validate: /^.{0,80}$/
                 message:  Max 80 characters
         home_page:
                 label:    URL
                 validate: /^.{0,100}$/
                 message:  Invalid URL
         pass:
                 label:    Password
                 type:     password
                 validate: /^.{4,40}$/
                 required: 1
                 message:  Between 4 and 40 characters
         pass2:
                 label:    Password confirmation
                 type:     password
                 validate: /^.{4,40}$/
                 message:  Between 4 and 40 characters
                 required: 1
         submit:
                 type:     submit
--------------------------------------------------------

	I haven't packaged it yet and I think it is too early
(despite the 
"release early, release often" moto) so I can't
upload it to CPAN but I 
have some question to ask to you all:

	- Is the name I gave a good name? I don't think so. I think
it should 
mention the fact that it also concerns RDBO.
	- Are you interested in a module like this? I'm pretty sure
somebody is 
 I'm
the first 
	- What are your requests / suggestions about a module like
this? Feel 
free to ask questions if my explanation wasn't enough.
	- Should I keep the validation system like this, or should
I create 
validation classes (better IMHO)? For the moment the error
messages are 
localized in the template with a macro.

	Thank you for your attention.

	Regards,
-- 
    ^/
  -/ O ----------------------------------------
| |/ |       Alexandre (Midnite) Jousset      |
  -|___|----------------------------------------

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

RDBO/RHTMLO integration with Catalyst - work in progress
country flaguser name
United States
2007-07-21 08:02:24
check out Catalyst::Controller::Rose on cpan.

It has a different philosophy than what you've described.
But if you find 
features missing that you think would make it more useful,
please send me 
patches/tests/docs etc. You might consider writing a new 
Catalyst::Controller::Rose::SomeThing to implement what
you're describing with YAML.

Alexandre Jousset wrote on 7/21/07 7:56 AM:
> 	Hello lists,
> 
> 	Since I haven't seen any work like this before (if I'm
wrong please 
> give me pointers!) I started to write a Catalyst
Controller called 
> "Catalyst::Controller::RHTMLO" to integrate
RHTMLO (and a few bits of 
> RDBO) to Catalyst the same way
"Catalyst::Controller::FormBuilder" do. 
> In fact my work is originally based on it.
> 
> 	For the moment the only thing one can do with it is to
define a form in 
> YAML (or any config file recognized by
"Config::Loader") and have it 
> displayed in the template (TT2 for the moment, but
others are planned).
> 
> 	The module also defines, like the FormBuilder one, a
'Form' method 
> attribute. The plan is to have forms automagically
validated and, if no 
> errors, give the user (developper) the ability to save
them as objects 
> in the db. Else, the error messages are set for user
convenience.
> 
> 	Here is an example of a YAML file for the action
"/user/create", 
> located in .../root/forms/user/create.yaml:
>
--------------------------------------------------------
> name:   UserCreateForm # optional, automatically
computed
> method: post
> rdbo:   User # class of the rdbo object, used to
load/save objects and 
> also for field init (see below, types are sometimes
missing, but it works)
> fields_order:
>          - login
>          - disp_name
>          - mail
>          - disp_mail
>          - home_page
>          - pass
>          - pass2
>          - submit
> fields:
>          login:
>                  label:    Login
>                  validate: /^.{4,40}$/, /^w*$/
>                  message:  Between 4 and 40 characters,
Only 
> alphanumeric characters
>                  required: 1
>          disp_name:
>                  label:    Real name (public)
>                  validate: /^.{0,50}$/,
/^[w.-()]*$/
>                  message:  Max 50 characters, Forbidden
character(s)
>          mail:
>                  label:    Real Email
>                  type:     email
>                  message:  Invalid Email
>                  required: 1
>          disp_mail:
>                  label:    Displayed Email (public)
>                  validate: /^.{0,80}$/
>                  message:  Max 80 characters
>          home_page:
>                  label:    URL
>                  validate: /^.{0,100}$/
>                  message:  Invalid URL
>          pass:
>                  label:    Password
>                  type:     password
>                  validate: /^.{4,40}$/
>                  required: 1
>                  message:  Between 4 and 40 characters
>          pass2:
>                  label:    Password confirmation
>                  type:     password
>                  validate: /^.{4,40}$/
>                  message:  Between 4 and 40 characters
>                  required: 1
>          submit:
>                  type:     submit
>
--------------------------------------------------------
> 
> 	I haven't packaged it yet and I think it is too early
(despite the 
> "release early, release often" moto) so I
can't upload it to CPAN but I 
> have some question to ask to you all:
> 
> 	- Is the name I gave a good name? I don't think so. I
think it should 
> mention the fact that it also concerns RDBO.
> 	- Are you interested in a module like this? I'm pretty
sure somebody is 
>  I'm the
first 
> 	- What are your requests / suggestions about a module
like this? Feel 
> free to ask questions if my explanation wasn't enough.
> 	- Should I keep the validation system like this, or
should I create 
> validation classes (better IMHO)? For the moment the
error messages are 
> localized in the template with a macro.
> 
> 	Thank you for your attention.
> 
> 	Regards,

-- 
Peter Karman  .  http://peknet.com/  . 
peterpeknet.com

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

RDBO/RHTMLO integration with Catalyst - work in progress
country flaguser name
France
2007-07-21 13:12:44
Peter Karman a écrit :
> check out Catalyst::Controller::Rose on cpan.
> 
> It has a different philosophy than what you've
described. But if you find 
> features missing that you think would make it more
useful, please send me 
> patches/tests/docs etc. You might consider writing a
new 
> Catalyst::Controller::Rose::SomeThing to implement what
you're describing with YAML.

	I've had seen your modules but I did not check them enough
to 
understand what they do exactly. Now I did...

	I'm still studying them to be sure what is the right thing
to do... But 
any advice is welcome...
-- 
    ^/
  -/ O ----------------------------------------
| |/ |       Alexandre (Midnite) Jousset      |
  -|___|----------------------------------------


_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: RDBO/RHTMLO integration with Catalyst - work in progress
country flaguser name
United States
2007-07-21 13:44:23

Alexandre Jousset wrote on 7/21/07 1:12 PM:
> Peter Karman a écrit :
>> check out Catalyst::Controller::Rose on cpan.
>>
>> It has a different philosophy than what you've
described. But if you 
>> find features missing that you think would make it
more useful, please 
>> send me patches/tests/docs etc. You might consider
writing a new 
>> Catalyst::Controller::Rose::SomeThing to implement
what you're 
>> describing with YAML.
> 
>     I've had seen your modules but I did not check them
enough to 
> understand what they do exactly. Now I did...
> 
>     I'm still studying them to be sure what is the
right thing to do... 
> But any advice is welcome...

C::C::Rose takes the "thin controller/fat model"
approach. Look at the example 
app in the t/examples dir to see one implementation.

I prefer to follow the RHTMLO convention of a Perl class for
each form, rather 
than YAML magic, etc. So C::C::Rose basically is a thin glue
between a 
Rose::HTML::Form subclass and a Rose:B::Objec
t subclass (via 
Catalyst::Model::RDBO, which is also thin glue).

My approach has been to write just enough code to get RHTMLO
and RDBO working in 
a Catalyst context, in a generic CRUD fashion. The idea is
that my RHTMLO and 
RDBO subclasses can exist happily on their own, or pulled
into Catalyst with the 
thin glue of the C::C::Rose and C::M::RDBO base classes.

-- 
Peter Karman  .  http://peknet.com/  . 
peterpeknet.com

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: RDBO/RHTMLO integration with Catalyst - work in progress
country flaguser name
France
2007-07-21 14:36:49
Peter Karman a écrit :
>>     I'm still studying them to be sure what is the
right thing to 
>> do... But any advice is welcome...
> 
> C::C::Rose takes the "thin controller/fat
model" approach. Look at the 
> example app in the t/examples dir to see one
implementation.

	Done.

> I prefer to follow the RHTMLO convention of a Perl
class for each form, 
> rather than YAML magic, etc. So C::C::Rose basically is
a thin glue 

	I understand your point.

	My goal is to provide a "form framework" that can
speed up form 
creation and modification. In this aspect a YAML file is far
quickly 
updatable than a Perl class. In a sense it is like the class
loader in 
RDBO but only in its dynamic version (of course, I generate
the forms at 
start, not each time the action is called, like
C::C::FormBuilder does). 
But I want best of both worlds, i.e. the nice Rose framework
with the 
very easy C::C::FormBuilder approach, and in the case of the
Rose 
framework I want RHTMLO and RDBO glued together.

> between a Rose::HTML::Form subclass and a Rose:B::Objec
t subclass (via 
> Catalyst::Model::RDBO, which is also thin glue).
> 
> My approach has been to write just enough code to get
RHTMLO and RDBO 
> working in a Catalyst context, in a generic CRUD
fashion. The idea is 
> that my RHTMLO and RDBO subclasses can exist happily on
their own, or 
> pulled into Catalyst with the thin glue of the
C::C::Rose and C::M::RDBO 
> base classes.

	Thank you for your explanation.

	I think I could name my module C::C::Rose::FormManager, or
something 
like that...?  I plan
to use your C::C::Rose and C::M::RDBO base classes.
-- 
    ^/
  -/ O ----------------------------------------
| |/ |       Alexandre (Midnite) Jousset      |
  -|___|----------------------------------------

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: RDBO/RHTMLO integration with Catalyst - work in progress
country flaguser name
United Kingdom
2007-07-22 12:48:07
On Sat, Jul 21, 2007 at 08:02:24AM -0500, Peter Karman
wrote:
> check out Catalyst::Controller::Rose on cpan.
> 
> It has a different philosophy than what you've
described. But if you find 
> features missing that you think would make it more
useful, please send me 
> patches/tests/docs etc. You might consider writing a
new 
> Catalyst::Controller::Rose::SomeThing to implement what
you're describing 
> with YAML.

Do you have any plans to split the dependencies a bit on
this?

I've always been quite fond of RHTMLO and have been on a
couple projects now
where we considered Controller::Rose and had to pass on it
because it
assumed you wanted RDBO as well.

Catalyst stuff should really be as non-opinionated as
possible - people might
want to use RDBO with a different form library too, and it'd
be nice for the
glue to elegantly support that case as well.

-- 
      Matt S Trout       Need help with your Catalyst or
DBIx::Class project?
   Technical Director    Want a managed development or
deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at)
shadowcatsystems.co.uk for a quote
http://chainsawblues.vo
x.com/             http://www.shadowc
atsystems.co.uk/ 

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: RDBO/RHTMLO integration with Catalyst - work in progress
country flaguser name
United States
2007-07-22 14:53:32

Matt S Trout wrote on 7/22/07 12:48 PM:
> On Sat, Jul 21, 2007 at 08:02:24AM -0500, Peter Karman
wrote:
>> check out Catalyst::Controller::Rose on cpan.
>>
>> It has a different philosophy than what you've
described. But if you find 
>> features missing that you think would make it more
useful, please send me 
>> patches/tests/docs etc. You might consider writing
a new 
>> Catalyst::Controller::Rose::SomeThing to implement
what you're describing 
>> with YAML.
> 
> Do you have any plans to split the dependencies a bit
on this?
> 

I hadn't any plans, but since you've raised the issue, I'd
be happy to discuss it.

> I've always been quite fond of RHTMLO and have been on
a couple projects now
> where we considered Controller::Rose and had to pass on
it because it
> assumed you wanted RDBO as well.

C::C::Rose assumes that you are going to override methods in
your subclasses, so 
it should be able to work with just about any model, I would
think.

All that is required is that the model class returned by
model_name() implement 
the same methods as C::M::RDBO. C::M::RDBO is intentionally
agnostic w.r.t. 
method names. I.e., it doesn't use the same method names as
RDBO or RDBO::Manager.

So a model needs to implement:

  * create()   - make an object (i.e. MyObject->new())
  * fetch()    - load an object's data
  * search()   - return an arrayref of objects
  * count()    - return a count of matches
  * iterator() - return an iterator instead of arrayref of
objects

fetch_all() and all() are just aliased to search() right
now.

C::C::Rose::CRUD just needs fetch() and create() to work,
and for the returned 
object to implement a save() and delete() method. Even
save() is optional -- 
just override save_obj() and make the object do whatever you
want.

C::C::Rose::Search is a little trickier since rose_query()
and setup() assume 
RDBO::QueryBuilder is the target SQL generator. But again,
those can be 
overridden to adapt to whatever your model's search() method
can accept.

So if (for example) you wanted to use DBIC with C::C::Rose,
you'd need a model 
that implements the methods above. But grok C::M::RDBO --
with the execption of 
fetch(), there's really not much going on in there. I
wouldn't think it would be 
hard to write a DBIC-compatible model than implements the
C::M::RDBO API.

How do you imagine C::C::R::CRUD and ::Search could play
friendlier with other 
models?


> 
> Catalyst stuff should really be as non-opinionated as
possible - people might
> want to use RDBO with a different form library too, and
it'd be nice for the
> glue to elegantly support that case as well.
> 

Hm. Catalyst stuff should be non-opinionated, but I don't
see how one Controller 
can be all things to all users. C::C::Rose assumes RHTMLO
but can be flexible 
with the Model. And you can use C::M::RDBO with any kind of
controllers you want.

But if folks wanted to use a different form library with
C::M::RDBO, and their 
form library doesn't have an API remotely close to RHTMLO's,
then they should 
probably be using a different package. We don't ask 
Catalyst::Controller::FormBuilder to support RHTMLO do we?
;)



-- 
Peter Karman  .  http://peknet.com/  . 
peterpeknet.com

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

[1-7]

about | contact  Other archives ( Real Estate discussion Medical topics )