Exemplo n.º 1
0
 def __call__(self):
     data = obj2dict(self.context, 0)
     data["start_date"] = self.context.sitting.start_date
     data["end_date"] = self.context.sitting.end_date
     data["title"] = IDCDescriptiveProperties(self.context).title
     data["url"] = url.absoluteURL(self.context, self.request)
     data["media"] = [obj2dict(m, 0) for m in self.context.debate_media]
     return simplejson.dumps(data, default=dthandler)
Exemplo n.º 2
0
 def __call__(self):
     try:
         context = removeSecurityProxy(self.context)
         
         map = IPrincipalRoleMap(context)
         print list(map.getPrincipalsAndRoles())
         files = []
         path = os.path.join(setupStorageDirectory(), self.context.type)
         if not os.path.exists(path):
             os.makedirs(path)
         file_path = os.path.join(path,context.__name__)
         files.append(file_path+'.xml') 
         with open(file_path+'.xml','w') as file:
             file.write(serialize(obj2dict(context,1,parent=None,include=['event','versions'],exclude=[])))
         if len(context.attached_files) > 0:
             for attachment in context.attached_files:
                 attachment_path = os.path.join(path, attachment.file_name)
                 files.append(attachment_path)
                 with open(os.path.join(path, attachment.file_name), 'wb') as file:
                      file.write(attachment.file_data)
             zip = ZipFile(file_path+'.zip', 'w')
             for file in files:
                 zip.write(file, os.path.split(file)[-1])
                 os.remove(file)
             zip.close()
             
                 
         return 'Done!'
     except:
         traceback.print_exception(*sys.exc_info())
Exemplo n.º 3
0
 def __call__(self):
     data = obj2dict(self.context,
                     0,
                     exclude=[
                         "salt", "_password", "password", "active_p",
                         "principal_id", "user_id", "type"
                     ])
     misc.set_json_headers(self.request)
     return simplejson.dumps(data, default=dthandler)
Exemplo n.º 4
0
 def __call__(self):
     sitting = self.context.sitting
     start_time = sitting.start_date + timedelta(
         seconds=int(self.request.get("start_time", 0)))
     if self.request.get("end_time", 0):
         end_time = sitting.start_date + timedelta(
             seconds=int(self.request.get("end_time", 0)))
     else:
         end_time = sitting.end_date
     session = Session()
     speeches = session.query(domain.DebateSpeech).filter(
         and_(
             domain.DebateSpeech.start_date >= start_time,
             domain.DebateSpeech.end_date <= end_time)).all()
     docs = session.query(domain.DebateDoc).filter(
         and_(
             domain.DebateDoc.start_date >= start_time,
             domain.DebateDoc.end_date <= end_time)).all()
     data = []
     for item in speeches + docs:
         data.append(obj2dict(item, 0))
     misc.set_json_headers(self.request)
     return simplejson.dumps({"nodes": data}, default=dthandler)
Exemplo n.º 5
0
 def __call__(self):
     data = obj2dict(self.context, 0, exclude=["salt", "_password",
         "password", "active_p", "principal_id", "user_id", "type"])
     misc.set_json_headers(self.request)
     return simplejson.dumps(data, default=dthandler)
Exemplo n.º 6
0
 def __call__(self):
     data = obj2dict(self.context, 0)
     misc.set_json_headers(self.request)
     return simplejson.dumps(data, default=dthandler)
Exemplo n.º 7
0
 def __call__(self):
     dthandler = lambda obj: obj.isoformat() if isinstance(
         obj, datetime) else obj
     data = obj2dict(self.context, 0)
     misc.set_json_headers(self.request)
     return simplejson.dumps(data, default=dthandler)
Exemplo n.º 8
0
 def __call__(self):
     data = obj2dict(self.context, 0)
     misc.set_json_headers(self.request)
     return simplejson.dumps(data, default=dthandler)
Exemplo n.º 9
0
 def __call__(self):
     data = obj2dict(self.context, 1, exclude=["data", "versions", "audits", "changes", "permissions"])
     misc.set_json_headers(self.request)
     return simplejson.dumps(data, default=dthandler)
Exemplo n.º 10
0
 def __call__(self):
     dthandler = lambda obj: obj.isoformat() if isinstance(obj, datetime
                                                           ) else obj
     data = obj2dict(self.context, 0)
     misc.set_json_headers(self.request)
     return simplejson.dumps(data, default=dthandler)