[jifty-devel] Struggling with Jifty

Sadia Lone l at mavsol.com
Sun May 16 01:36:54 EDT 2010

> > Well, I'm not an expert in Jifty, but from my experience, you cand edit
> > or delete in a similar way you create the post, using autoclasses (is it
> > the right name?). For example, to edit a record (to modify it):
> >
> >   template '/edit_post' => page { title => 'Edit Post Entry' } content
> >   {
> >        my $postid = get 'postid';
> >
> >        my $post = MyWeblog::Model::Post->new;
> >        $post->load($postid);

Hi Jes, thanks a lot for your kind help. With your help I am starting
to make sense of number of difficult things.

Yes, I was missing this code needed to get parameters from URL,
loading existing record and then updating it. I am still struggling
with delete page but hopefully get it done. If not will ask you again.

> In my experience it's better to move slightly more things into dispatcher:
> on '/edit_post/*' => run {
>    # * - also captures so you can do the following and don't need before rule:
>    my $id = $1;
>    # load right in dispatcher
>    my $post = Jifty->app_class('Model::Post');
>    $post->load( $id );
>    # "404: not found" if not found
>    abort(404) unless $post->id;
>    # store object instead of id
>    set post => $post;
>     show '/edit_post' ;
> };

Hi Ruslan, I tried to use the $post object in my lib/MyWeblog/View.pm
as follows:

template editpost => page { title => 'Edit Entry' } content {

      my $post = get 'post';
      my $action = new_action(class => 'UpdatePost', record => $post);

      form {
          render_action $action;
          form_submit(label => 'Update');

But I think I am doing something wrong because of the following error.
(JiftyDemo is my app name)

INFO - GET request for /errors/500
FATAL - View error: Attempt to reload JiftyDemo/View.pm aborted.
Compilation failed in require at
/usr/local/share/perl/5.10.1/Jifty/Util.pm line 277.

> I hope once you implement this and learn new tricks, you send us
> patches for documentation to make things clearer for other newbies :)

Yes sure Ruslan, I badly needed such a document and I think a lot of
beginners too. I am going to do a write up as soon as I am able to do
following things:

1. Adding, editing, deleting rows in a model. (Almost done).
2. Using templates to selectively display table columns.
3. User registration, management with the plug-in.
4. Menu bar mgmt.
5. Basic validation using models.

Most applications at my work place don't need functionality more than
this. I am surprised (and happy) to learn that I need to write very
few lines of code to do these things using Jifty. This is indeed going
to increase my productivity many fold.

So I think Jifty is not only for the developers of advanced applications.

Thx for all the help.


More information about the jifty-devel mailing list