Public Member Functions | Private Attributes | List of all members
ECLAPI.ECLEntry Class Reference

Public Member Functions

def __init__ (self, category, tags=[], formname='default', text='', preformatted=False, private=False, textile=False, related=None)
 
def setValue (self, name, value)
 
def setAuthor (self, name)
 
def addAttachment (self, name, filename, data=None)
 
def addImage (self, name, filename, image=None)
 
def addSubject (self, text)
 
def xshow (self)
 

Private Attributes

 _category
 
 _tags
 
 _formname
 
 _text
 
 _entry
 
 _form
 

Detailed Description

Definition at line 166 of file ECLAPI.py.

Constructor & Destructor Documentation

def ECLAPI.ECLEntry.__init__ (   self,
  category,
  tags = [],
  formname = 'default',
  text = '',
  preformatted = False,
  private = False,
  textile = False,
  related = None 
)

Definition at line 169 of file ECLAPI.py.

169  private=False, textile=False, related=None):
170  self._category = category
171  self._tags = tags
172  self._formname = formname
173  self._text = text
174  # Create the top level element
175  self._entry = etree.Element('entry', category=category)
176  if not preformatted:
177  self._entry.attrib['formatted']='yes'
178  if textile:
179  self._entry.attrib['html_safe']='no'
180  if private:
181  self._entry.attrib['private'] = 'yes'
182  if related:
183  self._entry.attrib['related'] = '%s' % (related,)
184  # Create the form
185  self._form = etree.SubElement(self._entry, 'form', name=formname)
186  if text:
187  # Create the text field
188  textfield = etree.SubElement(self._form, 'field', name='text')
189  # Store the text
190  textfield.text = text
191  for tag in tags:
192  etree.SubElement(self._entry, 'tag', name=tag)
193 

Member Function Documentation

def ECLAPI.ECLEntry.addAttachment (   self,
  name,
  filename,
  data = None 
)

Definition at line 203 of file ECLAPI.py.

203  def addAttachment(self, name, filename, data=None):
204  # Create the field
205  field = etree.SubElement(self._entry, 'attachment', type='file', name=name, filename=os.path.basename(filename))
206  if data:
207  # Store the text
208  field.text = base64.b64encode(data)
209  else:
210  f = open(filename,'r')
211  b = f.read()
212  field.text = base64.b64encode(b)
213  f.close()
214 
def addAttachment(self, name, filename, data=None)
Definition: ECLAPI.py:203
int open(const char *, int)
Opens a file descriptor.
def ECLAPI.ECLEntry.addImage (   self,
  name,
  filename,
  image = None 
)

Definition at line 215 of file ECLAPI.py.

215  def addImage(self, name, filename, image=None):
216  # Create the field
217  field = etree.SubElement(self._entry, 'attachment', type='image', name=name, filename=os.path.basename(filename))
218  # Store the text
219  if image:
220  # Store the text
221  field.text = base64.b64encode(image)
222  else:
223  f = open(filename,'r')
224  b = f.read()
225  field.text = base64.b64encode(b)
226  f.close()
227 
int open(const char *, int)
Opens a file descriptor.
def addImage(self, name, filename, image=None)
Definition: ECLAPI.py:215
def ECLAPI.ECLEntry.addSubject (   self,
  text 
)

Definition at line 228 of file ECLAPI.py.

228  def addSubject(self, text):
229  self._entry.attrib['subject'] = text
230 
def addSubject(self, text)
Definition: ECLAPI.py:228
def ECLAPI.ECLEntry.setAuthor (   self,
  name 
)

Definition at line 200 of file ECLAPI.py.

200  def setAuthor(self, name):
201  self._entry.attrib['author'] = name
202 
def setAuthor(self, name)
Definition: ECLAPI.py:200
def ECLAPI.ECLEntry.setValue (   self,
  name,
  value 
)

Definition at line 194 of file ECLAPI.py.

194  def setValue(self, name, value):
195  # Create the field
196  field = etree.SubElement(self._form, 'field', name=name)
197  # Store the text
198  field.text = value
199 
def setValue(self, name, value)
Definition: ECLAPI.py:194
def ECLAPI.ECLEntry.xshow (   self)

Definition at line 231 of file ECLAPI.py.

231  def xshow(self):
232  return etree.tostring(self._entry)
233 
def xshow(self)
Definition: ECLAPI.py:231

Member Data Documentation

ECLAPI.ECLEntry._category
private

Definition at line 170 of file ECLAPI.py.

ECLAPI.ECLEntry._entry
private

Definition at line 175 of file ECLAPI.py.

ECLAPI.ECLEntry._form
private

Definition at line 185 of file ECLAPI.py.

ECLAPI.ECLEntry._formname
private

Definition at line 172 of file ECLAPI.py.

ECLAPI.ECLEntry._tags
private

Definition at line 171 of file ECLAPI.py.

ECLAPI.ECLEntry._text
private

Definition at line 173 of file ECLAPI.py.


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