Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Overriding returned contents of user objects

View parsed - Show only message text

Received: by 10.35.22.9 with SMTP id z9mr7742210pyi.1.1208087778012;
        Sun, 13 Apr 2008 04:56:18 -0700 (PDT)
Return-Path: <digitalspaghe...@googlemail.com>
Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.152])
        by mx.google.com with ESMTP id z53si2471245pyg.1.2008.04.13.04.56.16;
        Sun, 13 Apr 2008 04:56:18 -0700 (PDT)
Received-SPF: pass (google.com: domain of digitalspaghe...@googlemail.com designates 72.14.220.152 as permitted sender) client-ip=72.14.220.152;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of digitalspaghe...@googlemail.com designates 72.14.220.152 as permitted sender) smtp.mail=digitalspaghe...@googlemail.com; dkim=pass (test mode) header...@googlemail.com
Received: by fg-out-1718.google.com with SMTP id d23so1045672fga.32
        for <django-users@googlegroups.com>; Sun, 13 Apr 2008 04:56:16 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlemail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;
        bh=NaoswtLc6Lpw6ObDFQi/KN18s8Cr8TMNZpfogl1tKdc=;
        b=it+nQW+zRlHQqiIBrPz1nvEgToBmUnb33HN38TNBkX1WE9lytfefmMI4cWywahNtFvEHm7IDkK8hypvndXE1jR4cQ1diHF++Vzb8zYmXJlcQgFLGDZyfpkLx1x+qYDvJ53TSMWp0Wk6ENz+cuCm3WtFmPKnMFlPAK0jM7y7VVkw=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=googlemail.com; s=gamma;
        h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;
        b=aGk913b6ZeYfrlGs8Ctx9CVK3u0TcX7q6Ko9VbJSkzpqg7Dni4/8H3S5HVo/FGdrcGTHY93E4/c0aPR30e6NiaQ12ermPZQt/WtHYEWbpuEuKns4Iqlxm7czaJMdBkXHnwzvO3mAmhhDhHTM9hrbq538xeBJBFwnWwmHs8BFrDw=
Received: by 10.86.89.4 with SMTP id m4mr10756375fgb.14.1208087775979;
        Sun, 13 Apr 2008 04:56:15 -0700 (PDT)
Received: by 10.86.77.15 with HTTP; Sun, 13 Apr 2008 04:56:15 -0700 (PDT)
Message-ID: <eacff6d20804130456q4eefc258h4bc28f800e4c69a@mail.gmail.com>
Date: Sun, 13 Apr 2008 12:56:15 +0100
From: "Tane Piper" <digitalspaghe...@googlemail.com>
To: django-users@googlegroups.com
Subject: Re: Overriding returned contents of user objects
In-Reply-To: <1208084386.17060.19.ca...@counterweight.tredinnick.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
References: <eacff6d20804130346j4a2b0e6ai9e9ea68de6523...@mail.gmail.com>
	 <1208084386.17060.19.ca...@counterweight.tredinnick.org>

Hi Malcolm,

values() seems to be the way to go for now.  I've extracted some of
the code back to a context variable, and anything within a view I'll
just have to try and make it as efficient as possible, while still
removing the user object from the context.

On Sun, Apr 13, 2008 at 11:59 AM, Malcolm Tredinnick
<malc...@pointy-stick.com> wrote:
>
>
>  On Sun, 2008-04-13 at 11:46 +0100, Tane Piper wrote:
>  [...]
>
> > What I want to
>  > know is there any way I could simplify the method and have it remove
>  > the password field any time a user object is being selected as part of
>  > a related query??
>
>  Not really, unless you use values(). For any model, if the Python object
>  is being constructed, it pulls back all the values it needs to populate
>  the attributes. The password hash is an attribute of the User model.
>
>
>  >  I'm sure there is a need for it when doing
>  > authorisation, but once a session has been confirmed, is it needed
>  > again?
>
>  Login isn't the only time when the password hash might be needed (for
>  example, it's displayed and editable in the admin screen) and it would
>  be quite hacky to introduce a special case for saying when that field
>  shouldn't be displayed. You're using the User object in public-readable
>  situations, which isn't really part of the design. So change your design
>  a bit so that you're not throwing around this information if you don't
>  want it displayed. Yes, anything can be serialised using json, but that
>  doesn't mean you should indiscriminately do so or that the framework
>  should accommodate that.
>
>  It might make sense in your situation to just pull back the values()
>  that you need for various objects and serialise that dictionary. Or you
>  could make another pass through the projects list and blank out the
>  attribute(s) you aren't interested in, such as _project_manager_cache.
>
>  Regards,
>  Malcolm
>
>  --
>  A clear conscience is usually the sign of a bad memory.
>  http://www.pointy-stick.com/blog/
>
>
>  >
>



-- 
Tane Piper
Blog - http://digitalspaghetti.me.uk
Skype: digitalspaghetti

This email is: [ ] blogable [ x ] ask first [ ] private

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google