* 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: http://git.jrock.us/?p=Ernst.git;a=tree;f=prototype/catalyst/TestApp;hb=HEAD The important part: http://git.jrock.us/?p=Ernst.git;a=blob;f=prototype/catalyst/TestApp/lib/TestApp/Backend/Record.pm;hb=HEAD 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 Template::Refine.) Regards, Jonathan Rockway -- print just => another => perl => hacker => if $,=$" _______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/