Sweet. If I can get away from the tedious front-end stuff, I will try to build a TD patch.<br><br><div><span class="gmail_quote">On 7/16/07, <b class="gmail_sendername">Jesse Vincent</b> <<a href="mailto:jesse@bestpractical.com">
jesse@bestpractical.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>On Jul 13, 2007, at 11:25 PM, Andrew Sterling Hanenkamp wrote:
<br><br>> I was thinking of porting CAS+ from Mason to Template::Declare, but<br>> I'd have to use something like XML::Writer to handle the XML pages.<br>> That's not so bad really, but it's not quite as nice as the typical
<br>> Template::Declare templates. So, I was trying to think of a way to get<br>> something better going. I tried to emulate the Jifty::DBI::Schema and<br>> Jifty::Action::Param declarations.<br>><br>> Here's a sample of what I was thinking:
<br>><br><br>Yes! I'd love to see a T::D subclass to do this.<br><br><br>> use Template::Declare::XML;<br>> use Jifty::View::Declare schema {<br>> namespace cas => '<a href="http://www.yale.edu/tp/cas">
http://www.yale.edu/tp/cas</a>';<br>> default_prefix is 'cas';<br>><br>> tag serviceResponse =><br>> is not_empty;<br>><br>> tag authenticationSuccess =><br>> is not_empty;
<br>><br>> tag user =><br>> is data;<br>><br>> tag proxyGrantingTicket =><br>> is data;<br>><br>> tag authenticationFailure =><br>> attributes {<br>> attribute code =>
<br>> is required;<br>> },<br>> is not_empty;<br>> };<br>><br>> template 'serviceValidate' => sub {<br>> my $result = get 'result';<br>><br>> xml_decl { version =>
1.0, encoding => 'UTF-8' };<br>><br>> serviceResponse {<br>> if ($result->success) {<br>> authenticationSuccess {<br>> user { $result->content('username'); };
<br>><br>> if ($result->content('proxy_granting_ticket')) {<br>> proxyGrantingTicket {<br>> $result->content('proxy_granting_ticket');
<br>> };<br>> }<br>> };<br>> }<br>><br>> else {<br>> authenticationFailure {<br>> attr { code => $result->content('code') };
<br>><br>> $result->error;<br>> };<br>> }<br>> };<br>> };<br>><br>> Not shown are some additional properties like:<br>><br>> tag 'serviceResponse' =>
<br>> prefix is 'cas',<br>> local_name is 'serviceResponse',<br>> is not_empty;<br>><br>> With the default_prefix I show, the prefix property would be assumed.<br>> The local_name is inferred from the tag name, but can be overridden
<br>> for some cases, like if:<br>><br>> tag 'service_response' => local_name 'service-response';<br>><br>> An addition heuristic would be handling prefixes in the tag name like:<br>><br>
> tag 'cas_serviceResponse' =><br>> is not_empty;<br>><br>> If there's a namespace prefix "cas" then it can infer this to be<br>> shorthand for:<br>><br>> tag 'cas_serviceResponse' =>
<br>> prefix 'cas',<br>> local_name 'serviceResponse',<br>> is not_empty;<br>><br>> The "not_empty" and "data" provide simple validation checks to warn<br>> you when a tag is expected to have content, but didn't have any or
<br>> when a tag contained tags and only text nodes were expected. An<br>> addition "empty" could also be used to indicate that a tag is expected<br>> to be empty. These wouldn't need to be implemented in the first
<br>> revision.<br>><br>> I'm not certain that the "attributes" property is really necessary<br>> either, but it could again provide an extra validation check to let<br>> the engine know that things are sane.
<br>><br>> Questions? Comments?<br>> _______________________________________________<br>> jifty-devel mailing list<br>> <a href="mailto:jifty-devel@lists.jifty.org">jifty-devel@lists.jifty.org</a><br>> <a href="http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel">
http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel</a><br>><br><br><br>_______________________________________________<br>jifty-devel mailing list<br><a href="mailto:jifty-devel@lists.jifty.org">jifty-devel@lists.jifty.org
</a><br><a href="http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel">http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel</a><br><br><br></blockquote></div><br>