[Rt-commit] [svn] r896 - in RTx-Atom: . html/Atom/0.3 html/Atom/0.3/Add html/Atom/0.3/Elements html/Atom/0.3/Get html/Atom/0.3/Remove lib/RTx

autrijus at pallas.eruditorum.org autrijus at pallas.eruditorum.org
Fri May 14 13:59:27 EDT 2004


Author: autrijus
Date: Fri May 14 13:59:27 2004
New Revision: 896

Modified:
   RTx-Atom/   (props changed)
   RTx-Atom/html/Atom/0.3/Add/index
   RTx-Atom/html/Atom/0.3/Elements/Error
   RTx-Atom/html/Atom/0.3/Get/Property
   RTx-Atom/html/Atom/0.3/Remove/index
   RTx-Atom/html/Atom/0.3/dhandler
   RTx-Atom/lib/RTx/Atom.pod
Log:
 ----------------------------------------------------------------------
 r4884 at not:  autrijus | 2004-05-14T17:59:27.443413Z
 
 * Put success message back; change 204 back to 200.
 * The final remaining verb, "Remove", is now implemented.
 ----------------------------------------------------------------------


Modified: RTx-Atom/html/Atom/0.3/Add/index
==============================================================================
--- RTx-Atom/html/Atom/0.3/Add/index	(original)
+++ RTx-Atom/html/Atom/0.3/Add/index	Fri May 14 13:59:27 2004
@@ -16,22 +16,23 @@
 $args{Requestor} ||= $session{CurrentUser}->Id
     if $CollectionClass->isa('RT::Tickets');
 
+my $status = 400;
+
 my @rv;
 if ($Path =~ /.*\b(\w+)s/ and $Object and my $code = $Object->can("Add$1")) {
     @rv = $code->($Object, %args);
-    return $m->comp($ShowError, Status => 204) if $rv[0];
+    $status = 200 if $rv[0];
 }
 else {
     @rv = $obj->Create( %args );
-}
-
-if (my $id = $obj->Id) {
-    $r->header_out(Location => "$BaseURI/$Path/$id");
-    return $m->comp($ShowError, Status => 303);
+    if (my $id = $obj->Id) {
+	$r->header_out(Location => "$BaseURI/$Path/$id");
+	$status = 303;
+    }
 }
 
 $r->content_type('text/plain');
-$r->status(400);
+$r->status($status);
 
 print $rv[-1];
 </%INIT>

Modified: RTx-Atom/html/Atom/0.3/Elements/Error
==============================================================================
--- RTx-Atom/html/Atom/0.3/Elements/Error	(original)
+++ RTx-Atom/html/Atom/0.3/Elements/Error	Fri May 14 13:59:27 2004
@@ -2,6 +2,10 @@
 $r->content_type('text/html');
 $r->header_out($ARGS{$_}) for sort keys %ARGS;
 $r->status($Status);
+if ($Status == 404) {
+    require Carp;
+    print Carp::longmess($Status);
+}
 $m->abort($Status) unless $ENV{FCGI_ROLE};
 </%INIT>
 <%ARGS>

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	Fri May 14 13:59:27 2004
@@ -21,9 +21,6 @@
     return $m->comp($ShowError, Status => 303);
 }
 
-$m->comp($ShowError, Status => 404)
-    unless $Object and $Object->can($Property);
-
 $r->content_type('text/plain');
 print $Object->$Property;
 </%INIT>

Modified: RTx-Atom/html/Atom/0.3/Remove/index
==============================================================================
--- RTx-Atom/html/Atom/0.3/Remove/index	(original)
+++ RTx-Atom/html/Atom/0.3/Remove/index	Fri May 14 13:59:27 2004
@@ -1,6 +1,19 @@
 %# [DELETE EditURI]
 %# Delete an object.
-%# 204: Successfully deleted.
-%# 400: Request failed.  Body is error message.
+%# 200: Successfully deleted.  Body is the success message.
+%# 400: Request failed.  Body is the error message.
 %# 404: There is no object matching the specified URI.
-% return $m->comp($ShowError, Status => 400);
+<%INIT>
+$Resource eq 'Object' or return $m->comp($ShowError, Status => 400);
+my ($ok, $msg) = $Object->Delete;
+
+$r->content_type('text/plain');
+$r->status(400) unless $ok;
+print $msg;
+
+</%INIT>
+<%ARGS>
+$ShowError
+$Object
+$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	Fri May 14 13:59:27 2004
@@ -134,7 +134,7 @@
     require Cache::FileCache;
     $nonce_cache = Cache::FileCache->new({
 	namespace => 'RT-Nonces',
-	default_expires_in => 1728000,
+	default_expires_in => 86400,
 	auto_purge_interval => 3600,
     });
     $auth_nonce = substr($auth_nonce, 0, 32);
@@ -327,13 +327,10 @@
 
 my $resource = ($obj ? $property ? 'Property' : 'Object' : 'Container');
 
-# Can't allow cache to happen at all
-eval {
-    $prev_obj = $obj if $obj;
-    $obj ||= $list->NewItem;
-    $obj->_expire( $obj->_gen_primary_cache_key());
-    $list->UnLimit unless $list->_isLimited;
-};
+eval { $prev_obj = $obj if $obj };
+eval { $obj ||= $list->NewItem };
+eval { $obj->_expire( $obj->_gen_primary_cache_key()) };
+eval { $list->UnLimit unless $list->_isLimited };
 
 if ($resource eq 'Container') {
     # FeedURI on collection

Modified: RTx-Atom/lib/RTx/Atom.pod
==============================================================================
--- RTx-Atom/lib/RTx/Atom.pod	(original)
+++ RTx-Atom/lib/RTx/Atom.pod	Fri May 14 13:59:27 2004
@@ -315,7 +315,7 @@
 
 Remove the specified object.
 
-    204: Successfully deleted.
+    200: Successfully deleted.  Body is the success message.
     400: Request failed.  Body is the error message.
     404: There is no object matching the specified URI.
 
@@ -344,9 +344,10 @@
 
 Create a new object from the AtomEntry in the request's body.
 
-    204: Created, but the new object has no EditURI.
+    200: Created, but the new object has no EditURI.  Body is the
+         success message.
     303: Created.  The 'Location' header is set to the new object's
-         EditURI (for subsequent Get/Update).
+         EditURI (for subsequent Get/Update).  Body is the success message.
     400: Request failed.  Body is the error message.
     404: There is no container matching the specified URI.
 


More information about the Rt-commit mailing list