Not clear about the dot notation

TomF tomf.sessile at gmail.com
Sun Jan 16 16:34:57 EST 2011


On 2011-01-16 12:44:35 -0800, Zeynel said:

> 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()
> 
> is this correct?

Yes.

> 
> So I have a model
> 
> 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 ?

I believe so.  Though you're now talking about an extension to db.Model 
which looks like it's doing a lot more behind the scenes than a simple 
variable access.

-Tom




More information about the Python-list mailing list