jon at jrock.us
Fri Aug 1 07:57:21 BST 2008
* On Tue, Jul 29 2008, John Beppu wrote:
> Now that composition and embedding of web apps is becoming a reality, we have
> to start anticipating needs like this. For example, the documentation for an
> app that's built to be embedded could state that:
Expectations suck. Use Ernst, tag your attributes and classes with the
necessary metadescription, and introspect. The user should tell the
computer what to do, not the other way around.
> * It expects a user object to be in its session's "u" key.
The Session should be a class of course, and the class should have an
attribute with a metadescription that "does"
Squatting::Description::User, or whatever.
> * The app will expect to be able to call the ->name method on this user
> object. (Some apps may want more... others less... this is just a
> hypothetical example.)
The User class should have a class metadescription that describes what
methods return what data.
> * If that key is undef, the app will assume the current session is not in a
> "logged in" state.
Why not force the class to implement a role that provides a
"user_is_logged_in" method? Then there is no need to guess. Just call
the method and see. (Actually, it would be better to be able to
meta-describe methods... but I haven't implemented this yet.)
Someone else mentioned in another post how this sort of thing is
impossible with forms, but it's actually not. Ernst and Reaction have
solved this problem. We generate the DBIC files from the "row" class's
metadescription, and we generate the form handling code from the same
metadescription. Unfortunately all of my examples are locked up in
internal code right now (very experimental), and I think mst's code is
mostly in the same state :)
Anyway, here is an old Ernst demo:
The important part:
Anyway, it turns out that this is a simple problem, but just needs some
tweaking for maximum enjoyment and ease of use. (We've gotten rid of TT
in the "production" version, for example, because the fragments are too
hard for designers to work with. Instead, we are using
print just => another => perl => hacker => if $,=$"
More information about the Catalyst