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
Motor tutorial
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
  8 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
 
A. Jesse Jiryu Davis  
View profile  
 More options Oct 6 2012, 5:59 pm
From: "A. Jesse Jiryu Davis" <ajesseda...@gmail.com>
Date: Sat, 6 Oct 2012 14:59:44 -0700 (PDT)
Local: Sat, Oct 6 2012 5:59 pm
Subject: Motor tutorial

I wrote up a tutorial on Motor, my MongoDB driver for Tornado:

http://emptysquare.net/motor/pymongo/api/motor/tutorial.html

Let me know if it helps or hinders you, or if you can see ways to improve
it.


 
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.
aliane abdelouahab  
View profile  
 More options Oct 6 2012, 6:09 pm
From: aliane abdelouahab <alabdeloua...@gmail.com>
Date: Sat, 6 Oct 2012 15:09:19 -0700 (PDT)
Local: Sat, Oct 6 2012 6:09 pm
Subject: Re: Motor tutorial
first one to answer :D
i'll make a good night reading this jewel :D
thank you ;)

On 6 oct, 22:59, "A. Jesse Jiryu Davis" <ajesseda...@gmail.com> wrote:


 
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.
aliane abdelouahab  
View profile  
 More options Oct 6 2012, 6:20 pm
From: aliane abdelouahab <alabdeloua...@gmail.com>
Date: Sat, 6 Oct 2012 15:20:27 -0700 (PDT)
Local: Sat, Oct 6 2012 6:20 pm
Subject: Re: Motor tutorial
just as a contribution:

A single instance of MongoDB can support multiple independent
databases. From an open connection, you can get a reference to a
particular database with dot-notation or bracket-notation:

>>> db = connection.test_database
>>> db = connection['test_database']

the second one (connection['name_of_the_database']) is used when the
name of database dont respects python variable naming.

On 6 oct, 22:59, "A. Jesse Jiryu Davis" <ajesseda...@gmail.com> wrote:


 
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.
aliane abdelouahab  
View profile  
 More options Oct 6 2012, 6:27 pm
From: aliane abdelouahab <alabdeloua...@gmail.com>
Date: Sat, 6 Oct 2012 15:26:59 -0700 (PDT)
Local: Sat, Oct 6 2012 6:26 pm
Subject: Re: Motor tutorial
am sorry for asking this dumb question, but can i use this technique
(which is used in the examples of projects made by tornado users) to
make inheritence?

class BaseHandler(tornado.web.RequestHandler):
    def get_current_user(self):
        user = self.get_secure_cookie("current_user") or False
        if not user: return None
        return tornado.escape.json_decode(user)

    @property
    def db(self):
        if not hasattr(BaseHandler,"_db"):
            _db = pymongo.Connection().tuxhub
        return _db

    @property
    def fs(self):
        if not hasattr(BaseHandler,"_fs"):
            _fs = gridfs.GridFS(self.db)
        return _fs

it will work in the same maneer in Motor? because i've seen a
parameter:

application = tornado.web.Application([
    (r'/', MainHandler)
], db=db)

if i use the first technique, then i will add the db=db ?

On 6 oct, 22:59, "A. Jesse Jiryu Davis" <ajesseda...@gmail.com> wrote:


 
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.
A. Jesse Jiryu Davis  
View profile  
 More options Oct 7 2012, 12:07 am
From: "A. Jesse Jiryu Davis" <ajesseda...@gmail.com>
Date: Sat, 6 Oct 2012 21:07:14 -0700 (PDT)
Local: Sun, Oct 7 2012 12:07 am
Subject: Re: Motor tutorial

No, because your properties are accessed synchronously.

So, this line:

   _fs = gridfs.GridFS(self.db)

... opens a GridFS object in a *blocking* style. The next line isn't
executed until the object has been created. The IOLoop is blocked and no
more requests can be processed until the GridFS object is created. In
Motor, on the other hand, you need to open it asynchronously:

    fs = motor.MotorGridFS(self.db)
    fs.open(my_callback)

The object isn't "open" until the callback has been executed, some time
later. See my GridFSHandler for an example of using MotorGridFS:

https://github.com/ajdavis/mongo-python-driver/blob/motor/motor/web.py

On the other hand, if you look at the code for the regular PyMongo
gridfs.GridFS constructor, you'll see all it does is an ensure_index(),
which (assuming the index is already created) is so fast that it's probably
not a problem. *Reading* from a PyMongo GridFS object, however, will block
the IOLoop until complete, which for large files *will* be a problem.


 
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.
aliane abdelouahab  
View profile  
 More options Oct 7 2012, 4:18 am
From: aliane abdelouahab <alabdeloua...@gmail.com>
Date: Sun, 7 Oct 2012 01:18:48 -0700 (PDT)
Local: Sun, Oct 7 2012 4:18 am
Subject: Re: Motor tutorial
so i'll avoid the classic way to make gridfs and pymongo inherit and
declare them in each class?

On 7 oct, 05:07, "A. Jesse Jiryu Davis" <ajesseda...@gmail.com> wrote:


 
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.
A Jesse Jiryu Davis  
View profile  
 More options Oct 7 2012, 12:21 pm
From: A Jesse Jiryu Davis <ajda...@cs.oberlin.edu>
Date: Sun, 7 Oct 2012 09:20:57 -0700
Local: Sun, Oct 7 2012 12:20 pm
Subject: Re: [tornado] Re: Motor tutorial

I think you should just keep using PyMongo.

On Sun, Oct 7, 2012 at 1:18 AM, aliane abdelouahab
<alabdeloua...@gmail.com>wrote:


 
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.
aliane abdelouahab  
View profile  
 More options Oct 7 2012, 5:12 pm
From: aliane abdelouahab <alabdeloua...@gmail.com>
Date: Sun, 7 Oct 2012 14:12:43 -0700 (PDT)
Local: Sun, Oct 7 2012 5:12 pm
Subject: Re: Motor tutorial
yes you're right ;)
thank you  :)

On 7 oct, 17:21, A Jesse Jiryu Davis <ajda...@cs.oberlin.edu> wrote:


 
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 »