简体   繁体   中英

Using the recommended python parse.com library to wrap their REST api, why does the following occur

Code:

for k in dir(parse_rest.User):
    print parse_rest.User[k]

Error:

Traceback (most recent call last):
   File "/home/ntresch/Development/webapp/appcode.py", line 53, in <module>
     for k in dir(parse_rest.User):
AttributeError: 'module' object has no attribute 'User'

The docs show the following:

#Users
#You can sign up, log in, modify or delete users as well, using the User object. You sign a user up as follows:

u = parse_rest.User.signup("dhelmet", "12345", phone="555-555-5555")

#or log in an existing user with

u = parse_rest.User.login("dhelmet", "12345")
# Once a User has been logged in, it saves its session so that it can be edited or deleted:

u.highscore = 300
u.save()
u.delete()

I really want to know what all I can do with the user object. This behavior seems wonky.

This was a case of (at the time) out-of-date documentation, fixed as of 3/11/2013 . The way to access the User class is not parse_rest.User but:

from parse_rest.user import User

The answer is don't use that library. My colleague has one we home rolled checked into our source tree and we're planning on releasing one. When we do I will post a link here for completeness. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM