Not clear about the dot notation

Tim Roberts timr at probo.com
Mon Jan 17 00:14:59 EST 2011


Zeynel <azeynel1 at gmail.com> wrote:

>On Jan 16, 3:24 pm, TomF <tomf.sess... at gmail.com> wrote:
>
>> vote refers to the Vote instance.
>
>So he must have instatiated previously like
>
>vote = Vote()

No, it's the line immediately above the one you asked about:

        if vote is None:
            vote = Vote(key_name = user.email(), parent = quote)
        if vote.vote == newvote:
            return

If "vote" is empty, it creates a Vote object and assigns it to "vote".  It
then checks the "vote" member of that object.

>class Item(db.Model):
>    title = db.StringProperty()
>    url = db.StringProperty()
>    date = db.DateTimeProperty(auto_now_add=True)
>    author = db.UserProperty()
>
>and to write to the database I do
>
>            item = Item()
>            item.title = self.request.get("title")
>            item.url = self.request.get("url")
>            item.author = users.get_current_user()
>            item.put()
>            self.redirect("/newest")
>
>so his vote.vote is like my item.url ?

Exactly.
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list