> OpenInteract will probably do what you want, but one of its design
> philosophies is to have the templates to relatively simple work and
> handlers do the real data manipulation. So from the example in your
> original message:
>
>   [% data=fetch({sql=>"SELECT MessageId, Subject FROM Messages"}) %]
>
> You might do something like
>
> package MySite::Handler::Messages;
>
> sub listing {
>     my ( $class, $p ) = @_;
>     my $R = OpenInteract::Request->instance;
>     my $message_iterator = eval { $R->message->fetch_group };
>     my ( $error );
>     if ( $@ ) {
>         $error = "Cannot retrieve messages: $SPOPS::Error::system_msg";
>     }
>     return $R->template( {}, { iter => $message_iterator,
>                                error_msg => $error },
>                          { name => 'mypkg::message_list' } );
> }
>
> And in your template:
>
> ------------------------------
>
> <h1>Summary of messages</h1>
>
> [% IF NOT iter.has_next -%]
>
> <p>Sorry, no messages to display.</p>
>
> [% ELSE -%]
>
> <table border="0">
> [% WHILE ( message = iter.get_next ) -%]
>    <tr>
>      <td>[% message.subject %]</td>
>      <td>[% message.from %]</td>
>      [% view_url = OI.make_url( base => '/Message/show',
>                                 message_id = message.id ) -%]
>      <td><a href="[% view_url %]">View message</a></td>
>    </tr>
> [% END -%]
> </table>
>
> [% END -%]
>
> ------------------------------
>
> So in your handler you have the option of ordering the messages as you
> wish, screening certain ones out, etc. And the template can make
> simple display decisions but doesn't do much with the data besides
> display it.

In the my answer to Joshua, I wrote that it was bad example of our usage of
TT.
Templates does not contain tags, besides IF and FOREACH usually.
All database access and any data processing on Perl module side.

> One last thing: I'm not sure how large your application is, but for
> small applications OpenInteract is most likely overkill. The only way
> I'd write something simple (e.g., a guestbook) in OI is if I already
> had an OI system installed and wanted to extend it.

We have about 20-30 sites with content management. All these content editors
has similar
HTML and code blocks.
(www.webzavod.ru/projects/contentum/ - example for future customers)
Our goal
1. Place all these CSS, images files and reusable HTML blocks (= includes or
xml tags) in one directory, which will be Aliased for every site.
2. There is Apache module Apache::Contentum with reusable subs, which also
we call xml tags.
3. For every site we can, if needed, create Apache module - descendant of
Apache::Contentum with specific for this site features.

As you can see it is not 'guestbook' task, and we will extend this system in
future and very important to choose right solution now. All these steps done
in many variants, but I don't like the results :( We want to share our work,
and create open project, but code is not pure, as yours... Learn, learn and
learn as told great Lenin :)

We wrote configs in Data::Dumper format, compiles them, inserts them into
Apache Perl module for every site.
We consider to place these data to one file with representation data now.
Clear TT solutions - too much [% PROCESS %], and it is not so reusable as
XML
I think, we dont know XML so good yet and how to implement well-defined
database driven features in XML, although we made 2 AxKit site
(http://nalog.samara.ru for example), we decided that database driven sites
simpler implement as Perl Module + TT.

About my problem with SPOPS...
I have - Win mysql 3.23.41
and DBI 1.14 (there is not newer version for Active Perl), DBD::MySQL 1.22
If I don't solve this problem by myslf I'll descibe it to
http://www.openinteract.org/support
Thanks...

-------------------------------
Sergey "BeerBong" Polyakov
Chief of WebZavod
http://www.webzavod.ru

Reply via email to