def __init__(self, queryset, responder, receiver=None, authentication=None, permitted_methods=None, expose_fields=None, entry_class=None, form_class=None): """ queryset: determines the subset of objects (of a Django model) that make up this resource responder: the data format instance that creates HttpResponse objects from single or multiple model objects and renders forms receiver: the data format instance that handles POST and PUT data authentication: the authentication instance that checks whether a request is authenticated permitted_methods: the HTTP request methods that are allowed for this resource e.g. ('GET', 'PUT') expose_fields: the model fields that can be accessed by the HTTP methods described in permitted_methods entry_class: class used for entries in create() and get_entry(); default: class Entry (see below) form_class: base form class used for data validation and conversion in self.create() and Entry.update() """ # Available data self.queryset = queryset # Input format if not receiver: receiver = FormReceiver() self.receiver = receiver # Input validation if not form_class: form_class = ModelForm self.form_class = form_class # Output format / responder setup self.responder = responder if not expose_fields: expose_fields = [field.name for field in queryset.model._meta.fields] responder.expose_fields = expose_fields if hasattr(responder, 'create_form'): responder.create_form = curry(responder.create_form, queryset=queryset, form_class=form_class) if hasattr(responder, 'update_form'): responder.update_form = curry(responder.update_form, queryset=queryset, form_class=form_class) # Resource class for individual objects of the collection if not entry_class: entry_class = Entry self.entry_class = entry_class ResourceBase.__init__(self, authentication, permitted_methods)
def __init__(self, queryset, responder, receiver=None, authentication=None, permitted_methods=None, expose_fields=None, entry_class=None, form_class=None): """ queryset: determines the subset of objects (of a Django model) that make up this resource responder: the data format instance that creates HttpResponse objects from single or multiple model objects and renders forms receiver: the data format instance that handles POST and PUT data authentication: the authentication instance that checks whether a request is authenticated permitted_methods: the HTTP request methods that are allowed for this resource e.g. ('GET', 'PUT') expose_fields: the model fields that can be accessed by the HTTP methods described in permitted_methods entry_class: class used for entries in create() and get_entry(); default: class Entry (see below) form_class: base form class used for data validation and conversion in self.create() and Entry.update() """ # Available data self.queryset = queryset # Input format if not receiver: receiver = FormReceiver() self.receiver = receiver # Input validation if not form_class: form_class = BaseForm self.form_class = form_class # Output format / responder setup self.responder = responder if not expose_fields: expose_fields = [field.name for field in queryset.model._meta.fields] responder.expose_fields = expose_fields if hasattr(responder, 'create_form'): responder.create_form = curry(responder.create_form, queryset=queryset, form_class=form_class) if hasattr(responder, 'update_form'): responder.update_form = curry(responder.update_form, queryset=queryset, form_class=form_class) # Resource class for individual objects of the collection if not entry_class: entry_class = Entry self.entry_class = entry_class ResourceBase.__init__(self, authentication, permitted_methods)
def __init__(self, model, queryset=None, responder=None, receiver=None, authentication=None, permitted_methods=None, expose_fields=None, entry_class=None, form_class=None, api=False, baseurl=None): """ model: model to use for this collection queryset: determines the subset of objects that make up this resource responder: the data format instance that creates HttpResponse objects from single or multiple model objects and renders forms, default uses a smart method based on the accept header. receiver: the data format instance that handles POST and PUT data authentication: the authentication instance that checks whether a request is authenticated permitted_methods: the HTTP request methods that are allowed for this resource e.g. ('GET', 'PUT') expose_fields: the model fields that can be accessed by the HTTP methods described in permitted_methods entry_class: class used for entries in create() and get_entry(); default: class Entry (see below) form_class: base form class used for data validation and conversion in self.create() and Entry.update() api: enable if you want API generation enabled. base_url: base url where this resource will be availabe. """ # model to use self.model = model # Available data self.queryset = queryset or model.objects.all() # Input format self.receiver = receiver or InteligentReceiver() # api self.api = api # Input validation self.form_class = form_class or ModelForm # Output format / responder setup self.responder = responder or responders.InteligentResponder() self.expose_fields = expose_fields or [ field.name for field in self.model._meta.fields ] self.responder.expose_fields = self.expose_fields # this is used by template responder only if hasattr(self.responder, 'create_form'): self.responder.create_form = curry(responder.create_form, queryset=queryset, form_class=form_class) if hasattr(self.responder, 'update_form'): self.responder.update_form = curry(responder.update_form, queryset=queryset, form_class=form_class) # Resource class for individual objects of the collection self.entry_class = entry_class or Entry self._base_url = baseurl ResourceBase.__init__(self, authentication, permitted_methods)
def __init__(self, model, queryset=None, responder=None, receiver=None, authentication=None, permitted_methods=None, expose_fields=None, entry_class=None, form_class=None, api=False, baseurl=None): """ model: model to use for this collection queryset: determines the subset of objects that make up this resource responder: the data format instance that creates HttpResponse objects from single or multiple model objects and renders forms, default uses a smart method based on the accept header. receiver: the data format instance that handles POST and PUT data authentication: the authentication instance that checks whether a request is authenticated permitted_methods: the HTTP request methods that are allowed for this resource e.g. ('GET', 'PUT') expose_fields: the model fields that can be accessed by the HTTP methods described in permitted_methods entry_class: class used for entries in create() and get_entry(); default: class Entry (see below) form_class: base form class used for data validation and conversion in self.create() and Entry.update() api: enable if you want API generation enabled. base_url: base url where this resource will be availabe. """ # model to use self.model = model # Available data self.queryset = queryset or model.objects.all() # Input format self.receiver = receiver or InteligentReceiver() # api self.api = api # Input validation self.form_class = form_class or ModelForm # Output format / responder setup self.responder = responder or responders.InteligentResponder() self.expose_fields = expose_fields or [field.name for field in self.model._meta.fields] self.responder.expose_fields = self.expose_fields # this is used by template responder only if hasattr(self.responder, 'create_form'): self.responder.create_form = curry(responder.create_form, queryset=queryset, form_class=form_class) if hasattr(self.responder, 'update_form'): self.responder.update_form = curry(responder.update_form, queryset=queryset, form_class=form_class) # Resource class for individual objects of the collection self.entry_class = entry_class or Entry self._base_url = baseurl ResourceBase.__init__(self, authentication, permitted_methods)