On 11/10/06, Adam Jones <[EMAIL PROTECTED]> wrote:
>
>
> Karl Guertin wrote:
> > On 11/9/06, Tim Lesher <[EMAIL PROTECTED]> wrote:
> > > Any chance that this "end result" will include something like Rails' 
> > > "Acts"?
> >
> > Got an explanation for this? My google-fu is lacking.
>
> I'm guessing it is a reference to the various "acts_as_*" plugins that
> make it relatively easy to add row metadata (tags, voting, commenting,
> etc) to your model.

It's a bit more than metadata.  If you go back to the original
definition of the "active record" pattern (not the ActiveRecord
implemention in rails), it's all about encapsulating both data and
logic.

In practical terms, an "Act" adds metadata, domain logic, and
rendering logic (and customization hooks) to an object in a single
line of code, in a way that's easy to extend and easy to predict
(reducing interoperability issues).

For example, taking the "taggable" example, making an object
definition "taggable" would add not only the data columns and relation
tables to store tags, but it also would add methods like tag() and
untag() to the object itself.  Votable might add (using SQLObject
notation) methods like vote(self, voter, vote_amount),
_get_avg_vote(self), _get_num_votes(self), _get_voters(self), etc.



> In looking at it, TG could go one step further with a
> widgets-and-decorator combo. The idea would be that any acts_as_*
> plugin comes with some widgets and a decorator that allow the following
> to make the change from non-voteable to voteable:
>
> Original:
> @expose(template)
> def entries(self):
>    return dict(entries=model.entries.select(), entry_widget=mywidget)
>
> @acts_as_voteable(mywidget, voteable.vote_widget)
> @expose(template)
> def entries(self):
>     ...
>

I'm not sure what purpose the decorator serves in your example. I
think the voteable object be enough to bring the appropriate widgets
along.

I haven't dug too deeply into the Ruby magic that implements Act, but
I believe that their approach is aggregation-based rather than
inheritance-based.  It seems that one way to get this behavior would
be making TurboEntity support MI, but that has the usual set of
issues.

-- 
Tim Lesher <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to