Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
an advice about tornado.database
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
贾晓磊  
View profile  
 More options Jan 9 2012, 9:50 pm
From: 贾晓磊 <jiaxiaolei19871...@gmail.com>
Date: Tue, 10 Jan 2012 10:50:01 +0800
Local: Mon, Jan 9 2012 9:50 pm
Subject: an advice about tornado.database

hi, all

I have been using tornado for nearly 2 years!  Now, I begin to read the
resource code, and find some code can be more beautiful. show  a instance
 as follows:

In the page “
https://github.com/jaixiaolei/tornado/blob/master/tornado/database.py”,we
can find the code:

def close(self):
        """Closes this database connection."""
        if getattr(self, "_db", None) is not None:
            self._db.close()
            self._db = None

in my views,  if getattr(self, "_db", None) is not None: can be replaced to
if hasattr(self,"_db"):

def close(self):
        """Closes this database connection."""
        if hasattr(self, "_db"):
            self._db.close()
            self._db = None

Is someone agree me?

#NOTE: first time give an advice to tornado. maybe in the following days, i
will send more thinking about tornado.

-- Jia Xiaolei


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
smallfish  
View profile  
 More options Jan 9 2012, 9:53 pm
From: smallfish <smallfish...@gmail.com>
Date: Tue, 10 Jan 2012 10:53:42 +0800
Local: Mon, Jan 9 2012 9:53 pm
Subject: Re: [tornado] an advice about tornado.database

yes, i think so. perhaps enhance readability
--
blog: http://chenxiaoyu.org

2012/1/10 贾晓磊 <jiaxiaolei19871...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
贾晓磊  
View profile  
 More options Jan 9 2012, 10:00 pm
From: 贾晓磊 <jiaxiaolei19871...@gmail.com>
Date: Tue, 10 Jan 2012 11:00:56 +0800
Local: Mon, Jan 9 2012 10:00 pm
Subject: Re: [tornado] an advice about tornado.database

2012/1/10 smallfish <smallfish...@gmail.com>

> yes, i think so. perhaps enhance readability

hehe, thanks for your response.
I read your blog in "http://chenxiaoyu.org". Good easy!  nginx+tornado are
also be used in our projject and they work perfect.
an extra question: how to give advices or bugs to the maintainer of
tornado. it seems terrible to use  "
http://www.apache.org/licenses/LICENSE-2.0".

Nice to meet you!

-- Jia Xiaolei

--
NAME: 贾晓磊/Jia Xiaolei
MOBILE: 13011292217
QQ: 281304051
MICRO-BLOG:  http://weibo.com/2183890715
GMAIL: jiaxiaolei19871...@gmail.com <gmail%3Ajiaxiaolei19871...@gmail.com>

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
smallfish  
View profile  
 More options Jan 9 2012, 10:09 pm
From: smallfish <smallfish...@gmail.com>
Date: Tue, 10 Jan 2012 11:09:49 +0800
Local: Mon, Jan 9 2012 10:09 pm
Subject: Re: [tornado] an advice about tornado.database

see more of github issue page (
https://github.com/facebook/tornado/issues?sort=created&direction=des...
)
or add the maillist feedback.
i'm new user :)
--
blog: http://chenxiaoyu.org

在 2012年1月10日 上午11:00,贾晓磊 <jiaxiaolei19871...@gmail.com>写道:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cliff Wells  
View profile  
 More options Jan 9 2012, 10:26 pm
From: Cliff Wells <cl...@develix.com>
Date: Mon, 09 Jan 2012 19:26:33 -0800
Local: Mon, Jan 9 2012 10:26 pm
Subject: Re: [tornado] an advice about tornado.database

On Tue, 2012-01-10 at 10:50 +0800, 贾晓磊 wrote:

> in my views,  if getattr(self, "_db", None) is not None: can be
> replaced to if hasattr(self,"_db"):

Actually that's not the same test at all.  hasattr(self, "_db") will be
True even if self._db == None.

>>> class Foo (object):

...     def __init__ (self):
...         self.bar = None
...

>>> f = Foo ()
>>> hasattr (f, "bar")
True

Therefore you must have getattr (self, "_db") == None.  Except perhaps
there is no attribute _db, which will throw an exception, so you must
have a default:

if getattr(self, "_db", None) is not None

And now you are back to the original code.

Regards,
Cliff


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
贾晓磊  
View profile  
 More options Jan 9 2012, 10:41 pm
From: 贾晓磊 <jiaxiaolei19871...@gmail.com>
Date: Tue, 10 Jan 2012 11:41:32 +0800
Local: Mon, Jan 9 2012 10:41 pm
Subject: Re: [tornado] an advice about tornado.database

sorry for my fault and misunderstand. I did not think it deeply and it's
all my fault.
thanks for the points. Thanks!

-- Jia Xiaolei

--
NAME: 贾晓磊/Jia Xiaolei
MOBILE: 13011292217
QQ: 281304051
MICRO-BLOG:  http://weibo.com/2183890715
GMAIL: jiaxiaolei19871...@gmail.com <gmail%3Ajiaxiaolei19871...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »