Package amplee :: Package atompub :: Package member
[hide private]
[frames] | no frames]

Source Code for Package amplee.atompub.member

 1  # -*- coding: utf-8 -*- 
 2   
 3  __doc__ = """ 
 4  APP establishes uses the term of members to describe 
 5  resources within an APP service context. 
 6   
 7  APP says: 
 8  ''' 
 9  A resource whose IRI is listed in a Collection by a link 
10  element with a relation of "edit" or "edit-media".  
11  ''' 
12   
13  The base member is the what amplee calls the EntryMember 
14  which is the resource whose IRI is contained in the 
15  link defined by rel="edit". 
16   
17  The EntryMember should be rarerly used directly has it is 
18  only meaningful if your resource is an Atom entry document. 
19   
20  On the other hand the MediaMember describes the resource 
21  whose IRI is contained in the link defined by rel="edit-media". 
22   
23  The Mediamember will certainly be the most common class to 
24  inherit for your own member implementations. 
25  """ 
26   
27 -class EntryMember(object):
28 - def __init__(self, collection, id=None, atom=None):
29 """ 30 31 Keyword Arguments: 32 collection -- AtomPubCollection instance holding this member 33 id -- identifier for this member 34 atom -- bridge.Element instance 35 """ 36 self.collection = collection 37 self.entry = atom 38 self.member_id = id 39 self.media_id = None 40 self.media_type = u'application/atom+xml'
41
42 - def _getentry(self):
43 return self.entry
44
45 - def _setentry(self, entry):
46 raise AttributeError, "Cannot overwrite the underlying Atom entry"
47
48 - def _delentry(self):
49 raise AttributeError, "Cannot delete the underlying Atom entry"
50 51 atom = property(_getentry, _setentry, _delentry)
52
53 -class MediaMember(EntryMember):
54 - def __init__(self, collection, media_type):
55 """ 56 57 Keyword arguments: 58 collection -- AtomPubCollection instance holding this member 59 media_type -- resource mime-type 60 """ 61 EntryMember.__init__(self, collection) 62 self.collection = collection 63 self.media_type = media_type
64
65 - def _getmediacontent(self):
66 return self.collection.get_content(self.collection.get_path(self.media_id))
67
68 - def _setmediacontent(self, entry):
69 raise AttributeError, "Cannot overwrite the underlying content"
70
71 - def _delmediacontent(self):
72 raise AttributeError, "Cannot delete the media content"
73 74 content = property(_getmediacontent, _setmediacontent, _delmediacontent)
75