def post(self, user_name, collection_name):
        """Bulk update of WBOs in a collection"""
        out = { 'modified': None, 'success': [], 'failed': {} }

        collection = Collection.get_by_profile_and_name(
            self.request.profile, collection_name
        )

        wbos = []
        for wbo_data in self.request.body_json:
            if 'id' not in wbo_data: continue
            wbo_data['collection'] = collection
            wbo_id = wbo_data['id']
            (wbo, errors) = WBO.from_json(wbo_data)
            if wbo:
                out['modified'] = wbo.modified
                out['success'].append(wbo_id)
                wbos.append(wbo)
            else:
                out['failed'][wbo_id] = errors

        if (len(wbos) > 0):
            db.put(wbos)

        return out
 def put(self, user_name, collection_name, wbo_id):
     """Insert or update an item in the collection"""
     self.request.body_json.update({
         'profile': self.request.profile,
         'collection_name': collection_name,
         'wbo_id': wbo_id
     })
     (wbo, errors) = WBO.from_json(self.request.body_json)
     if not wbo:
         self.response.set_status(400, message="Bad Request")
         self.response.out.write(WEAVE_ERROR_INVALID_WBO)
         return None
     else:
         wbo.put()
         return wbo.modified
 def put(self, user_name, collection_name, wbo_id):
     """Insert or update an item in the collection"""
     self.request.body_json.update({
         'profile': self.request.profile, 
         'collection_name': collection_name,
         'wbo_id': wbo_id
     })
     (wbo, errors) = WBO.from_json(self.request.body_json)
     if not wbo:
         self.response.set_status(400, message="Bad Request")
         self.response.out.write(WEAVE_ERROR_INVALID_WBO)
         return None
     else:
         wbo.put()
         return wbo.modified
    def post(self, user_name, collection_name):
        """Bulk update of WBOs in a collection"""
        out = {'modified': None, 'success': [], 'failed': {}}

        collection = Collection.get_by_profile_and_name(
            self.request.profile, collection_name)

        wbos = []
        for wbo_data in self.request.body_json:
            if 'id' not in wbo_data: continue
            wbo_data['collection'] = collection
            wbo_id = wbo_data['id']
            (wbo, errors) = WBO.from_json(wbo_data)
            if wbo:
                out['modified'] = wbo.modified
                out['success'].append(wbo_id)
                wbos.append(wbo)
            else:
                out['failed'][wbo_id] = errors

        if (len(wbos) > 0):
            db.put(wbos)

        return out