Package occi :: Package protocol :: Module rendering
[hide private]
[frames] | no frames]

Source Code for Module occi.protocol.rendering

  1  # coding=utf-8 
  2  # 
  3  # Copyright (C) 2010-2012 Platform Computing 
  4  # 
  5  # This library is free software; you can redistribute it and/or 
  6  # modify it under the terms of the GNU Lesser General Public 
  7  # License as published by the Free Software Foundation; either 
  8  # version 2.1 of the License, or (at your option) any later version. 
  9  # 
 10  # This library is distributed in the hope that it will be useful, 
 11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
 13  # Lesser General Public License for more details. 
 14  # 
 15  # You should have received a copy of the GNU Lesser General Public 
 16  # License along with this library; if not, write to the Free Software 
 17  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA 
 18  # 
 19  ''' 
 20  A empty rendering class. 
 21   
 22  Created on Feb 2, 2012 
 23   
 24  @author: tmetsch 
 25  ''' 
 26   
 27   
28 -class Rendering(object):
29 ''' 30 All renderings should derive from this class. 31 ''' 32
33 - def __init__(self, registry):
34 ''' 35 Constructor. 36 37 registry -- The registry used for this process. 38 ''' 39 self.registry = registry
40
41 - def to_entity(self, headers, body, def_kind, extras):
42 ''' 43 Given the HTTP headers and the body this method will convert the HTTP 44 data into an entity representation. Must return Resource or Link 45 instances. 46 47 headers -- The HTTP headers. 48 body -- The HTTP body. 49 def_kind -- If provided this kind is taken (Needed for update). 50 extras -- Passed on extra object. 51 ''' 52 raise NotImplementedError()
53
54 - def from_entity(self, entity):
55 ''' 56 Given an entity it will return a HTTP body an header. 57 58 If it's a link make sure source, target attributes are set. If it's a 59 Resource make sure Links are presented properly. 60 61 entity -- The entity which is to rendered. 62 ''' 63 raise NotImplementedError()
64
65 - def to_entities(self, headers, body, extras):
66 ''' 67 Given the HTTP headers and the body this method will convert the HTTP 68 data into a set of entity representations. Must return a set of 69 Resource or Link instances. 70 71 headers -- The HTTP headers. 72 body -- The HTTP body. 73 extras -- Passed on extra object. 74 ''' 75 raise NotImplementedError()
76
77 - def from_entities(self, entities, key):
78 ''' 79 Given an set of entities it will return a HTTP body an header. 80 81 entities -- The entities which will be rendered. 82 key -- Needed for uri-list (see RFC) and html rendering. 83 ''' 84 raise NotImplementedError()
85
86 - def from_categories(self, categories):
87 ''' 88 Given an set of categories it will return a HTTP body an header. 89 90 categories -- The list of categories which is to be rendered. 91 ''' 92 raise NotImplementedError()
93
94 - def to_action(self, headers, body, extras):
95 ''' 96 Given the HTTP headers and the body this method will convert the HTTP 97 data into an Action. 98 99 headers -- The HTTP headers. 100 body -- The HTTP body. 101 extras -- Passed on extra object. 102 ''' 103 raise NotImplementedError()
104
105 - def to_mixins(self, headers, body, extras):
106 ''' 107 Given the HTTP headers and the body this method will convert the HTTP 108 data into a Mixins. Must return a list with Mixin instances. 109 110 headers -- The HTTP headers. 111 body -- The HTTP body. 112 extras -- Passed on extra object. 113 ''' 114 raise NotImplementedError()
115
116 - def get_filters(self, headers, body, extras):
117 ''' 118 Given the HTTP headers and the body this method will convert the HTTP 119 data into a list of categories and attributes. 120 121 headers -- The HTTP headers. 122 body -- The HTTP body. 123 extras -- Passed on extra object. 124 ''' 125 raise NotImplementedError()
126