Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8250463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:53:55+00:00 2026-06-07T23:53:55+00:00

I am using the facade-like pattern described here: http://django-tastypie.readthedocs.org/en/latest/non_orm_data_sources.html def obj_get(self, request=None, **kwargs): rv

  • 0

I am using the facade-like pattern described here: http://django-tastypie.readthedocs.org/en/latest/non_orm_data_sources.html

def obj_get(self, request=None, **kwargs):
    rv = MyObject(init=kwargs['pk'])
    audit_trail.message( ... )
    return rv

I can’t return None, tosses an error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:53:58+00:00Added an answer on June 7, 2026 at 11:53 pm

    You should raise an exception: tastypie.exceptions.NotFound (according to the code documentation).

    I am working on tastypie for CouchDB and delved into the issue. In the tastypie.resources.Resource class you can find the method that you have to override:

    def obj_get(self, request=None, **kwargs):
        """
        Fetches an individual object on the resource.
    
        This needs to be implemented at the user level. If the object can not
        be found, this should raise a ``NotFound`` exception.
    
        ``ModelResource`` includes a full working version specific to Django's
        ``Models``.
        """
        raise NotImplementedError()
    

    My example:

    def obj_get(self, request=None, **kwargs):
        """
        Fetches an individual object on the resource.
    
        This needs to be implemented at the user level. If the object can not
        be found, this should raise a ``NotFound`` exception.
        """
        id_ = kwargs['pk']
        ups = UpsDAO().get_ups(ups_id = id_)
        if ups is None:
            raise NotFound(
                    "Couldn't find an instance of '%s' which matched id='%s'."%
                    ("UpsResource", id_))
        return ups
    

    One thing is strange for me. When I had a look at obj_get method in ModelResource class (the superclass of Resource class):

    def obj_get(self, request=None, **kwargs):
        """
        A ORM-specific implementation of ``obj_get``.
    
        Takes optional ``kwargs``, which are used to narrow the query to find
        the instance.
        """
        try:
            base_object_list = self.get_object_list(request).filter(**kwargs)
            object_list = self.apply_authorization_limits(request, base_object_list)
            stringified_kwargs = ', '.join(["%s=%s" % (k, v) for k, v in kwargs.items()])
    
            if len(object_list) <= 0:
                raise self._meta.object_class.DoesNotExist("Couldn't find an instance of '%s' which matched '%s'." % (self._meta.object_class.__name__, stringified_kwargs))
            elif len(object_list) > 1:
                raise MultipleObjectsReturned("More than '%s' matched '%s'." % (self._meta.object_class.__name__, stringified_kwargs))
    
            return object_list[0]
        except ValueError:
            raise NotFound("Invalid resource lookup data provided (mismatched type).")
    

    an exception: self._meta.object_class.DoesNotExist is raised when object is not found, which eventually becomes ObjectDoesNotExist exception – so it is not consensus inside the project.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I like the idea of using Singleton mentioned here http://www.adobe.com/devnet/html5/articles/javascript-design-patterns-pt1-singleton-composite-facade.html : var Namespace =
I am using a facade design pattern for a C# program. The program basically
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
When using the facade design pattern to structure an application's business EJB layer, why
I have a 3rd party library i am interfacing with using a facade pattern.
I hear about using the facade design pattern with remoting but I can't see
I am using the Dynamic Linq library found here: http://speakingin.net/2008/01/08/dynamic-linqparte-1-usando-la-libreria-de-linq-dynamic/ http://msdn.microsoft.com/en-us/vstudio//bb894665.aspx I have the
Since I asked How has to be written the signature in facade pattern? question,
using MVC3, Code First (DbContext) Is there a way to implement (ideally) a facade
I'm using a Facade to access the methods and classes inside package, but and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.