Commits

Olemis Lang committed c047115 Merge

Merge: Protocol URLs and content types docs now work with trunk.

  • Participants
  • Parent commits dc0e889, fa758cc

Comments (0)

Files changed (1)

t5437/t5437-protocol_api-r7194.diff

 +
 +class JsonRpcProtocol(Component):
 +    r"""
-+    ==== JSON-RPC example ====
++    === JSON-RPC example ===
 +    
 +    {{{
 +    user: ~ > cat body.json
 +    # IRPCProtocol methods
 +
 +    def rpc_info(self):
-+        return ('JSON-RPC', True, self.__doc__)
++        return ('JSON-RPC', True, self.__doc__, list(self.rpc_match()))
 +
 +    def rpc_match(self):
 +        yield ('jsonrpc', 'application/json')
 diff --git a/trunk/tracrpc/templates/xmlrpclist.html b/trunk/tracrpc/templates/xmlrpclist.html
 --- a/trunk/tracrpc/templates/xmlrpclist.html
 +++ b/trunk/tracrpc/templates/xmlrpclist.html
-@@ -15,11 +15,25 @@
-       <h1>Remote Procedure Call (RPC) Interface</h1>
-       <dl>
-         <dt>API Status:</dt>
+@@ -10,103 +10,74 @@
+     <title>XML-RPC</title>
+   </head>
+   <body>
+-
+-    <div id="content" class="wiki">
+-      <h1>Remote Procedure Call (RPC) Interface</h1>
+-      <dl>
+-        <dt>API Status:</dt>
 -          <dd>XML-RPC is <strong>available</strong></dd>
 -          <dd>JSON-RPC is <strong>
 -            ${xmlrpc.json and 'available' or 'not available'}</strong></dd>
-+          <dd py:for="protocol in xmlrpc.protocols">
-+            ${protocol[0]} is <strong>
-+              ${protocol[1] and 'available' or 'not available'}</strong>
-+          </dd>
-       </dl>
- 
-+      <h2>Calling Methods</h2>
-+      <p>Libraries for remote procedure calls and parsing exists
-+        for most major languages and platforms - use a tested, standard library
-+        for consistent results.</p>
-+      <p>The following are examples for illustration only, and shows raw
-+        access to RPC using <tt>curl</tt> (with Content-Type and Body for POST request):</p>
-+      <div class="help">
-+        <div py:for="protocol in xmlrpc.protocols">
-+            ${wiki_to_html(context, protocol[2].replace(
-+                            '${req.abs_href.rpc()}', req.abs_href.rpc()))}
+-      </dl>
+-
+-      <h2>RPC exported functions</h2>
+-
+-      <div id="searchable">
+-        <dl py:for="key in sorted(xmlrpc.functions)" py:with="namespace = xmlrpc.functions[key]">
+-          <dt>
+-            <h3 id="${'xmlrpc.' + to_unicode(namespace.namespace)}">
+-              ${namespace.namespace} - ${namespace.description}
+-            </h3>
+-          </dt>
+-          <dd>
+-            <table class="listing tickets">
+-              <thead>
+-                <tr>
+-                  <th style="width:40%">Function</th>
+-                  <th style="width:45%">Description</th>
+-                  <th style="width:15%">Permission required</th>
+-                </tr>
+-              </thead>
+-              <tbody py:for="idx, function in enumerate(namespace.methods)">
+-                <tr class="${'color3-' + (idx % 2 == 0 and 'even' or 'odd')}">
+-                  <td style="padding-left:4em;text-indent:-4em">${function[0]}</td>
+-                  <td>${function[1]}</td>
+-                  <td>${function[2] or "By resource"}</td>
+-                </tr>
+-              </tbody>
+-            </table>
+-          </dd>
++    <div id="main">
++      <div id="content" class="wiki">
++        <h1>Remote Procedure Call (RPC) Interface</h1>
++        <dl>
++          <dt>API Status:</dt>
++            <dd py:for="protocol in xmlrpc.protocols">
++              <h4>${protocol[0]}</h4>
++              <p>${protocol[0]} is <strong>
++                ${protocol[1] and 'available' or 'not available'}</strong>
++              </p>
++              <ul>
++                <li py:for="h, ct in protocol[3]">
++                  Use <tt>${req.abs_href(h)}</tt> and specify 
++                  <tt>Content-Type=$ct</tt> to perform anonymous calls. 
++                  Use <tt>${req.abs_href.login(h)}</tt> with basic
++                  authentication for user context.
++                </li>
++              </ul>
++            </dd>
+         </dl>
++  
++        <h2>Calling Methods</h2>
++        <p>Libraries for remote procedure calls and parsing exists
++          for most major languages and platforms - use a tested, standard library
++          for consistent results.</p>
++        <p>The following are examples for illustration only, and shows raw
++          access to RPC using <tt>curl</tt> (with Content-Type and Body for POST request):</p>
++        <div class="help">
++          <div py:for="protocol in xmlrpc.protocols">
++              ${wiki_to_html(context, protocol[2].replace(
++                              '${req.abs_href.rpc()}', req.abs_href.rpc()))}
++          </div>
 +        </div>
-+      </div>
-+
-       <h2>RPC exported functions</h2>
- 
-       <div id="searchable">
-@@ -50,60 +64,6 @@
-         </dl>
++  
++        <h2>RPC exported functions</h2>
++  
++        <div id="searchable">
++          <dl py:for="key in sorted(xmlrpc.functions)" py:with="namespace = xmlrpc.functions[key]">
++            <dt>
++              <h3 id="${'xmlrpc.' + to_unicode(namespace.namespace)}">
++                ${namespace.namespace} - ${namespace.description}
++              </h3>
++            </dt>
++            <dd>
++              <table class="listing tickets">
++                <thead>
++                  <tr>
++                    <th style="width:40%">Function</th>
++                    <th style="width:45%">Description</th>
++                    <th style="width:15%">Permission required</th>
++                  </tr>
++                </thead>
++                <tbody py:for="idx, function in enumerate(namespace.methods)">
++                  <tr class="${'color3-' + (idx % 2 == 0 and 'even' or 'odd')}">
++                    <td style="padding-left:4em;text-indent:-4em">${function[0]}</td>
++                    <td>${function[1]}</td>
++                    <td>${function[2] or "By resource"}</td>
++                  </tr>
++                </tbody>
++              </table>
++            </dd>
++          </dl>
++        </div>
++        
++        <script type="text/javascript">
++          addHeadingLinks(document.getElementById("searchable"));
++        </script>
        </div>
-       
+-      
 -      <h2>Calling Methods</h2>
 -      <p>XML and JSON libraries for remote procedure calls and parsing exists
 -        for all major languages and platforms - use a tested, standard library
 -        </ul>
 -      </div>
 -      
-       <script type="text/javascript">
-         addHeadingLinks(document.getElementById("searchable"));
-       </script>
+-      <script type="text/javascript">
+-        addHeadingLinks(document.getElementById("searchable"));
+-      </script>
+     </div>
+   </body>
+ </html>
 diff --git a/trunk/tracrpc/tests/__init__.py b/trunk/tracrpc/tests/__init__.py
 --- a/trunk/tracrpc/tests/__init__.py
 +++ b/trunk/tracrpc/tests/__init__.py
 +
 +class XmlRpcProtocol(Component):
 +    r"""
-+    ==== XML-RPC example ====
++    === XML-RPC example ===
 +    {{{
 +    user: ~ > cat body.xml
 +    <?xml version="1.0"?>
 +    # IRPCProtocol methods
 +
 +    def rpc_info(self):
-+        return ('XML-RPC', True, self.__doc__)
++        return ('XML-RPC', True, self.__doc__, list(self.rpc_match()))
 +
 +    def rpc_match(self):
 +        yield ('xmlrpc', 'application/xml')