[pve-devel] r5035 - pve-common/trunk

svn-commits at proxmox.com svn-commits at proxmox.com
Fri Aug 20 10:19:18 CEST 2010


Author: dietmar
Date: 2010-08-20 08:19:18 +0000 (Fri, 20 Aug 2010)
New Revision: 5035

Modified:
   pve-common/trunk/ChangeLog
   pve-common/trunk/JSONSchema.pm
   pve-common/trunk/RESTHandler.pm
Log:
	* JSONSchema.pm (validate): new 'fragmentDelimiter' option.

	* RESTHandler.pm (find_handler): remove 'require' - we load
	statically instead



Modified: pve-common/trunk/ChangeLog
===================================================================
--- pve-common/trunk/ChangeLog	2010-08-20 06:06:07 UTC (rev 5034)
+++ pve-common/trunk/ChangeLog	2010-08-20 08:19:18 UTC (rev 5035)
@@ -1,3 +1,10 @@
+2010-08-20  Proxmox Support Team  <support at proxmox.com>
+
+	* JSONSchema.pm (validate): new 'fragmentDelimiter' option.
+
+	* RESTHandler.pm (find_handler): remove 'require' - we load
+	statically instead
+
 2010-08-17  Proxmox Support Team  <support at proxmox.com>
 
 	* JSONSchema.pm (get_options): we use option type 's' for boolean

Modified: pve-common/trunk/JSONSchema.pm
===================================================================
--- pve-common/trunk/JSONSchema.pm	2010-08-20 06:06:07 UTC (rev 5034)
+++ pve-common/trunk/JSONSchema.pm	2010-08-20 08:19:18 UTC (rev 5035)
@@ -562,6 +562,11 @@
 	    type =>  'string',
 	    description => "path for URL matching (uri template)",
 	},
+        fragmentDelimiter => {
+            type => 'string',
+	    description => "A ways to override the default fragment delimiter '/'. This onyl works on a whole sub-class. You can set this to the empty string to match the whole rest of the URI.",            
+	    optional => 1,
+        },
 	parameters => {
 	    type => 'object',
 	    description => "JSON Schema for parameters.",
@@ -586,6 +591,7 @@
 		properties => {
                     subclass => {},
                     path => {},
+                    fragmentDelimiter => { optional => 1 }
                 }             
             },
 	}, 

Modified: pve-common/trunk/RESTHandler.pm
===================================================================
--- pve-common/trunk/RESTHandler.pm	2010-08-20 06:06:07 UTC (rev 5034)
+++ pve-common/trunk/RESTHandler.pm	2010-08-20 08:19:18 UTC (rev 5035)
@@ -160,20 +160,24 @@
     return undef if !$info;
 
     if (my $subh = $info->{subclass}) {
-	eval "require $subh;";
 
-	if ($@) {
-	    syslog ('err', "missing subclass '$subh': $@");
-	    return undef;
-	}
-
 	my $matchlen = scalar(@{$info->{match_re}});
 
 	for (my $i = 0; $i < $matchlen; $i++) {
-	    my $fragment = shift @$stack;
-	    # fixme: store $fragments somewhere ?
+	    shift @$stack; # pop from stack
 	}
 
+	my $fd = $info->{fragmentDelimiter};
+
+	if (defined($fd)) {
+
+	    # we only support the empty string '' (match whole URI)
+	    die "unsupported fragmentDelimiter '$fd'" 
+		if $fd ne '';
+
+	    $stack = [ join ('/', @$stack) ];
+	}
+
 	return $subh->find_handler($method, $stack, $uri_param);
     }
 




More information about the pve-devel mailing list