Example #1
0
 def writeHTML(self):
   req= self._request
   res= self._response
   if req.hasField('key'):
     which= req.field('key')
     username= self.getUsername()
     if username:
       user= self.getUsername()
       path= None
       if which == 'pri':
         path= Gale.privPath(user)
       elif which == 'pub':
         path= Gale.pubPath(user)
       if path:
         fp= open(path, 'r')
         content= fp.read()
         res.setHeader('Content-Type', 'application/octet-stream')
         res.setHeader('Content-Length', str(len(content)))
         res.setHeader('Content-Disposition', 'inline; ' + \
           'filename=' + os.path.basename(path))
         res.write(content)
       else:
         res.write("bad key header")
   else:
     res.write("meow meow")
Example #2
0
 def actionPostMessage(self, trans):
   import traceback
   req= trans.request()
   locations= self.formDecode(req.field('locations'))
   message= self.formDecode(req.field('message'))
   private= self.getGaleId()
   try:
     gc= YGaleClient.YGaleClient()
     Gale.filetraces('before gsend %s, %s', private, locations)
     gc.gsend(private, locations.split(), message)
     Gale.filetraces('after gsend %s, %s', private, locations)
     #gc.gsend(private, locations.encode('utf-8').split(), message)
     self.message= ''
   except Gale.PyGaleErr, x:
     traceback.print_tb(sys.exc_info()[2])
     self.error= x
     self.message= message