[Rt-commit] [svn] r868 - in RTx-Atom: . html/Atom/0.3 html/Atom/0.3/Describe html/Atom/0.3/Get html/Atom/0.3/Put html/Atom/0.3/Set lib/RTx

autrijus at pallas.eruditorum.org autrijus at pallas.eruditorum.org
Tue May 11 15:46:12 EDT 2004


Author: autrijus
Date: Tue May 11 15:46:12 2004
New Revision: 868

Added:
   RTx-Atom/html/Atom/0.3/Set/
   RTx-Atom/html/Atom/0.3/Set/Property
   RTx-Atom/html/Atom/0.3/Set/index
Removed:
   RTx-Atom/html/Atom/0.3/Put/
Modified:
   RTx-Atom/   (props changed)
   RTx-Atom/html/Atom/0.3/Describe/index
   RTx-Atom/html/Atom/0.3/Get/Property
   RTx-Atom/html/Atom/0.3/Get/index
   RTx-Atom/html/Atom/0.3/dhandler
   RTx-Atom/lib/RTx/Atom.pm
Log:
 ----------------------------------------------------------------------
 r4779 at not:  autrijus | 2004-05-11T19:24:22.300603Z
 
 * It's Set, not Put
 ----------------------------------------------------------------------
 r4780 at not:  autrijus | 2004-05-11T19:46:02.561454Z
 
 * "Set" now works on Property.
 * Further refactor common resource inferencing into dhandler.
 ----------------------------------------------------------------------


Modified: RTx-Atom/html/Atom/0.3/Describe/index
==============================================================================
--- RTx-Atom/html/Atom/0.3/Describe/index	(original)
+++ RTx-Atom/html/Atom/0.3/Describe/index	Tue May 11 15:46:12 2004
@@ -5,19 +5,14 @@
 %# 400: Request failed.  Body is error message in text/plain.
 %# 404: There is no container matching the specified URI.
 <%INIT>
-my $obj = $CollectionClass->new($session{CurrentUser})->NewItem;
-my $id = $1 if $Path =~ /(\d+)$/;
-$obj->Load($id);
-
-my $accessible = $obj->_ClassAccessible;
+my $accessible = $Object->_ClassAccessible;
 
 my $map;
 while (my ($k, $v) = each %$accessible) {
     $map->{$k} = '' if $v->{write};
 }
 
-my $type = ($id ? 'Object' : 'Container');
-return $m->comp($type, %ARGS, Map => $map, Object => $obj);
+return $m->comp($Resource, %ARGS, Map => $map);
 </%INIT>
 <%ARGS>
 $Path
@@ -27,6 +22,8 @@
 $ShowEntry
 $X
 
+$Resource
+$Object
 $Type
 $CollectionClass
 $FeedURI

Modified: RTx-Atom/html/Atom/0.3/Get/Property
==============================================================================
--- RTx-Atom/html/Atom/0.3/Get/Property	(original)
+++ RTx-Atom/html/Atom/0.3/Get/Property	Tue May 11 15:46:12 2004
@@ -1,10 +1,11 @@
 %# [GET EditURI]
 %# Retrieve a representation of an property.
 <%INIT>
-$r->content_type('text/plain');
-my $code = $Object->can($Property)
+$Object->_ClassAccessible->{$Property}{read}
     or return $m->comp($ShowError, Status => 404);
-print $code->($Object);
+
+$r->content_type('text/plain');
+print $Object->$Property;
 </%INIT>
 <%ARGS>
 $Object

Modified: RTx-Atom/html/Atom/0.3/Get/index
==============================================================================
--- RTx-Atom/html/Atom/0.3/Get/index	(original)
+++ RTx-Atom/html/Atom/0.3/Get/index	Tue May 11 15:46:12 2004
@@ -4,19 +4,8 @@
 %# 400: Request failed.  Body is error message.
 %# 404: There is no object matching the specified URI.
 <%INIT>
-my $obj = $CollectionClass->new($session{CurrentUser})->NewItem;
-my ($id, $property) = ($1, $2) if $Path =~ /(\d+)(?:\.(\w+))?$/;
-$obj->Load($id) or return $m->comp($ShowError, Status => 404);
-
-my $type = ($property ? 'Property' : 'Object');
-return $m->comp($type, %ARGS, Object => $obj, Property => $property);
+return $m->comp($Resource, %ARGS);
 </%INIT>
 <%ARGS>
-$ShowLink
-$ShowEntry
-$ShowError
-$BaseURI
-$Path
-$CollectionClass
-$X
+$Resource
 </%ARGS>

Added: RTx-Atom/html/Atom/0.3/Set/Property
==============================================================================
--- (empty file)
+++ RTx-Atom/html/Atom/0.3/Set/Property	Tue May 11 15:46:12 2004
@@ -0,0 +1,25 @@
+%# [PUT EditURI]
+%# Modifies a property with the serialization in the request body.
+<%INIT>
+$Object->_ClassAccessible->{$Property}{read}
+    or return $m->comp($ShowError, Status => 404);
+$Object->_ClassAccessible->{$Property}{write}
+    or return $m->comp($ShowError, Status => 403);
+
+$r->content_type('text/plain');
+
+my $method = "Set$Property";
+my ($status, $msg) = ($Object->$method( $r->content ))[0, -1];
+if ($status) {
+    print $Object->$Property;
+}
+else {
+    $r->status(400);
+    print $msg;
+}
+</%INIT>
+<%ARGS>
+$Object
+$Property
+$ShowError
+</%ARGS>

Added: RTx-Atom/html/Atom/0.3/Set/index
==============================================================================
--- (empty file)
+++ RTx-Atom/html/Atom/0.3/Set/index	Tue May 11 15:46:12 2004
@@ -0,0 +1,11 @@
+%# [PUT EditURI]
+%# Modifies an object or property with the serialization in the request body.
+%# 200: Success.  Body is the object, serialized as an AtomEntry.
+%# 400: Request failed.  Body is error message in text/plain.
+%# 404: There is no object matching the specified URI.
+<%INIT>
+return $m->comp($Resource, %ARGS);
+</%INIT>
+<%ARGS>
+$Resource
+</%ARGS>

Modified: RTx-Atom/html/Atom/0.3/dhandler
==============================================================================
--- RTx-Atom/html/Atom/0.3/dhandler	(original)
+++ RTx-Atom/html/Atom/0.3/dhandler	Tue May 11 15:46:12 2004
@@ -177,7 +177,7 @@
     GET	    => 'Get',
     HEAD    => 'Get',
     POST    => 'Add',
-    PUT	    => 'Put',
+    PUT	    => 'Set',
     DELETE  => 'Remove',
     OPTIONS => 'Describe',
 );
@@ -259,9 +259,17 @@
     return $m->comp('Elements/Error', Status => 404);
 }
 
+my $obj = $class->new($session{CurrentUser})->NewItem;
+my ($id, $property) = ($1, $2) if $path =~ m{/(\d+)(?:\.(\w+))?$};
+$obj->Load($id) or return $m->comp('Elements/Error', Status => 404) if $id;
+my $resource = ($id ? $property ? 'Property' : 'Object' : 'Container');
+
 $m->comp(
     "$verb/index", %ARGS,
     Type => $type,
+    Resource => $resource,
+    Object => $obj,
+    Property => $property,
     CollectionClass => $class,
     FeedURI => "$BaseURI/$type",
     X => XML::Simple->new(RootName => 'body', NoIndent => 0),

Modified: RTx-Atom/lib/RTx/Atom.pm
==============================================================================
--- RTx-Atom/lib/RTx/Atom.pm	(original)
+++ RTx-Atom/lib/RTx/Atom.pm	Tue May 11 15:46:12 2004
@@ -67,7 +67,7 @@
         401 Authorization Required
         WWW-Authenticate: WSSE realm="localhost", profile="UsernameToken"
 
-Log in and probe the "Users" collection:
+Log in and probe the C<Users> collection:
 
     OPTIONS /Atom/0.3/Users
     X-WSSE: UsernameToken Username="guest", ...


More information about the Rt-commit mailing list