Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.action.AttachFile.ContainerItem Class Reference

List of all members.

Public Member Functions

def __init__
def member_url
def get
def put
def truncate
def exists

Public Attributes

 request
 pagename
 containername
 container_filename

Detailed Description

A storage container (multiple objects in 1 tarfile) 

Definition at line 582 of file AttachFile.py.


Constructor & Destructor Documentation

def MoinMoin.action.AttachFile.ContainerItem.__init__ (   self,
  request,
  pagename,
  containername 
)

Definition at line 585 of file AttachFile.py.

00585 
00586     def __init__(self, request, pagename, containername):
00587         self.request = request
00588         self.pagename = pagename
00589         self.containername = containername
00590         self.container_filename = getFilename(request, pagename, containername)


Member Function Documentation

Definition at line 632 of file AttachFile.py.

00632 
00633     def exists(self):
00634         return os.path.exists(self.container_filename)

Here is the caller graph for this function:

def MoinMoin.action.AttachFile.ContainerItem.get (   self,
  member 
)
return a file-like object with the member file data

Definition at line 604 of file AttachFile.py.

00604 
00605     def get(self, member):
00606         """ return a file-like object with the member file data
00607         """
00608         tf = tarfile.TarFile(self.container_filename)
00609         return tf.extractfile(member)

Here is the caller graph for this function:

return URL for accessing container member
    (we use same URL for get (GET) and put (POST))

Definition at line 591 of file AttachFile.py.

00591 
00592     def member_url(self, member):
00593         """ return URL for accessing container member
00594             (we use same URL for get (GET) and put (POST))
00595         """
00596         url = Page(self.request, self.pagename).url(self.request, {
00597             'action': 'AttachFile',
00598             'do': 'box',  # shorter to type than 'container'
00599             'target': self.containername,
00600             #'member': member,
00601         })
00602         return url + '&member=%s' % member
00603         # member needs to be last in qs because twikidraw looks for "file extension" at the end

Here is the call graph for this function:

def MoinMoin.action.AttachFile.ContainerItem.put (   self,
  member,
  content,
  content_length = None 
)
save data into a container's member 

Definition at line 610 of file AttachFile.py.

00610 
00611     def put(self, member, content, content_length=None):
00612         """ save data into a container's member """
00613         tf = tarfile.TarFile(self.container_filename, mode='a')
00614         if isinstance(member, unicode):
00615             member = member.encode('utf-8')
00616         ti = tarfile.TarInfo(member)
00617         if isinstance(content, str):
00618             if content_length is None:
00619                 content_length = len(content)
00620             content = StringIO(content) # we need a file obj
00621         elif not hasattr(content, 'read'):
00622             logging.error("unsupported content object: %r" % content)
00623             raise
00624         assert content_length >= 0  # we don't want -1 interpreted as 4G-1
00625         ti.size = content_length
00626         tf.addfile(ti, content)
00627         tf.close()

Definition at line 628 of file AttachFile.py.

00628 
00629     def truncate(self):
00630         f = open(self.container_filename, 'w')
00631         f.close()


Member Data Documentation

Definition at line 589 of file AttachFile.py.

Definition at line 588 of file AttachFile.py.

Definition at line 587 of file AttachFile.py.

Definition at line 586 of file AttachFile.py.


The documentation for this class was generated from the following file: