[Tutor] Cannot understand object initiation
bob gailer
bgailer at gmail.com
Sat Oct 12 18:47:51 CEST 2013
On 10/12/2013 11:01 AM, Kush Goyal wrote:
> [[snip]
> "user = User.query.filter_by ( username = self.username.data ).first()"
>
> now this I do not understand.
>
> Can a object be create by using a method of a class instead of the
> class consturctor? I
Without seeing the code you reference (User module) I can hazard a guess:
This code is not creating an object - it is returning a reference to an
existing object.
The key to the object is username, and first() returns the first
instance should there be more than one,
User is some objectimported from myapplication.models.
query is a callable object that is an attribute of User.
filter_by is a callable object that is an attribute of query.
first is a callable object that is an attribute of filter_by.
Nothing in the above suggests object creation.
HTH
--
Bob Gailer
919-636-4239
Chapel Hill NC
More information about the Tutor
mailing list