codecamp

CherryPy Atom Publishing Protocol (APP)

APP已经从Atom社区出现,作为HTTP之上的应用程序级协议,允许发布和编辑Web资源。 APP服务器和客户端之间的消息单元基于Atom XML文档格式。

Atom发布协议使用HTTP及其机制和Atom XML文档格式作为消息单元,定义APP服务和用户代理之间的一组操作。

APP首先定义服务文档,该服务文档向用户代理提供APP服务所服务的不同集合的URI。

例子 (Example)

让我们举个例子来说明APP的工作原理 -

<?xml version = "1.0" encoding = "UTF-8"?>
<service xmlns = "http://purl.org/atom/app#" xmlns:atom = "http://www.w3.org/2005/Atom">
   <workspace>
      <collection href = "http://host/service/atompub/album/">
         <atom:title> Albums</atom:title>
         <categories fixed = "yes">
            <atom:category term = "friends" />
         </categories>
      </collection>
      <collection href = "http://host/service/atompub/film/">
         <atom:title>Films</atom:title>
         <accept>image/png,image/jpeg</accept>
      </collection>
   </workspace>
</service>

APP指定如何使用HTTP方法对集合成员或集合本身执行基本CRUD操作,如下表所述 -

手术HTTP方法状态代码内容
RetrieveGET200表示资源的Atom条目
CreatePOST201通过Location和Content-Location标头创建的新资源的URI
UpdatePUT200表示资源的Atom条目
DeleteDELETE200None


CherryPy HTTP方法
CherryPy 孩子 - 模板引擎
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

CherryPy 一个工作应用程序

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }