def _constructResponse(self, request, entity, context, form, params, template=None): """Updates the context and returns a response for the specified arguments. Args: request: the django request object entity: the entity that is used and set in the context context: the context to be used form: the form that will be used and set in the context params: a dict with params for this View template: if specified, this template is Params usage: name: The name value is used to set the entity_type value in the context so that the template can refer to it. name_plural: same as name, but used to set entity_type_plural name_short: same as name, but used to set entity_type_short url_name: same as name, but used to set entity_type_url edit_template: The edit_template value is used as template when there is an existing entity to display the edit page for the specified entity. create_template: similar to edit_template, but is used when there is no existing entity. """ logic = params['logic'] suffix = entity.key().id_or_name() if entity else None context['form'] = form context['entity'] = entity context['entity_suffix'] = suffix context['entity_type'] = params['name'] context['entity_type_plural'] = params['name_plural'] context['entity_type_short'] = params['name_short'] context['entity_type_url'] = params['url_name'] context['cancel_redirect'] = params.get('cancel_redirect') context['return_url'] = request.path if entity: # when creating, the entity does not exist. context['is_deletable'] = logic.isDeletable(entity) if params.get('export_content_type') and entity: context['export_link'] = redirects.getExportRedirect(entity, params) if not template: if entity: template = params['edit_template'] else: template = params['create_template'] self._editContext(request, context) # remove the seed from the context before dispatching to Django context.pop('seed', None) return helper.responses.respond(request, template, context)
""" logic = params['logic'] try: entity = logic.getFromKeyFieldsOr404(kwargs) except out_of_band.Error, error: error.message_fmt = ( error.message_fmt + self.DEF_CREATE_NEW_ENTITY_MSG_FMT % { 'entity_type_lower' : params['name'].lower(), 'entity_type' : params['name'], 'create' : params['missing_redirect']}) return helper.responses.errorResponse( error, request, template=params['error_edit']) if not logic.isDeletable(entity): page_params = params['cannot_delete_params'] params['suffix'] = entity.key().id_or_name() request.path = params['edit_redirect'] % params # redirect to the edit page # display notice that entity could not be deleted return helper.responses.redirectToChangedSuffix( request, None, params=page_params) logic.delete(entity) redirect = params['delete_redirect'] return http.HttpResponseRedirect(redirect) def select(self, request, view, redirect,