Closed flound1129 closed 9 years ago
The code you posted does not have any Question object. Can you post the code that has the Question object.
class Question(Object): pass
That doesn't help. When is answer
defined, and when is user
defined? Is one of them a Question
object?
yes, answer is a question object.
answers = Question.Query.filter(parent__exists=False).filter(autoquestionid__exists=True).limit(1000).skip(skip)
if len(answers) > 1000:
done = True
else:
skip += 1000
for answer in answers:
print "id was %s" % answer.objectId
asker = answer.askedof
user = User()
user.objectId = asker
answer.parent = answer.autoquestionid
answer.User = user
It seems to work if the answer object already has an ACL set. However if there is not currently an ACL set, it throws the exception.
Also, if I try to initialiaze an ACL object like so:
class acl(ACL): pass
answer.ACL = acl()
I get this exception.
Traceback (most recent call last):
File "./fix_Question.py", line 32, in
It's not clear what it's expecting to get as an argument.
Hi were you able to reproduce this issue? Or am I doing something stupid?
This is indeed a bug that happens when first trying to set the ACL for an object. I've gotten around this using, as written for your example:
answer.ACL = ACL({user.objectId: {'read': True, 'write': True}})
Subsequently, the ACL can be set and retrieved using the method described in the docs.
Workaround seems to work. Thanks!
returns:
Traceback (most recent call last): File "./fix_Question.py", line 32, in
answer.ACL.set_user(user, read=True, write=True)
File "/usr/local/lib/python2.7/dist-packages/parse_rest-0.2.20141004-py2.7.egg/parse_rest/datatypes.py", line 326, in getattr
return object.getattribute(self, attr) #preserve default if attr not exists
AttributeError: 'Question' object has no attribute 'ACL'