Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't assign redisworks results (for some object types) to redisworks #3

Open
wojtow opened this issue Jan 14, 2017 · 4 comments
Open
Assignees
Labels

Comments

@wojtow
Copy link

wojtow commented Jan 14, 2017

# works
root.n1=1
root.n2=root.n1
root.a1="a"
root.a2=root.a1
root.l1=[1,2,3,4]
root.l2=root.l1

# fails with exception thrown
root.d1={"a":"b"}
root.d2=root.d1
root.t1=(1,2,3)
root.t2=root.t1

If you convert the LazyDot object back to a normal object before assigning, this works around the problem. If I add the following at the top of Root.__save_in_redis():

    if isinstance(value,LazyDot):
        value.__repr__()
        value=value.__deepcopy__(None) 

But I feel like its a deeper issue in LazyObject, which I'm having a really hard time understanding and debugging since overridding all the operators and the proxying of class attributes makes it behave in unexpected ways.

The exception seems to be an issue with the json dumping of the LazyDot object:

# fails with same exception
root.t1=(1,2,3)
json.dumps(root.t1)
@seperman seperman self-assigned this Jan 17, 2017
@seperman
Copy link
Owner

So this comes back to the fact that all root attributes like root.t1 etc. are lazy dot objects as you have noticed. I have to make DotObject to get the value of another DotObject when it is assigned that DotObject. Regarding json serialization, I will take care of it. Thanks for reporting!

@seperman seperman added the bug label Jan 17, 2017
@wojtow
Copy link
Author

wojtow commented Jan 17, 2017

I think the json serialization problem is the cause of the assignment problem. (The exception thrown when doing the assignment from another DotObject comes from inside the json serialization)

@reubano
Copy link
Contributor

reubano commented Mar 1, 2017

Just came across this today and took a while to figure out what was going on. IMHO this should not error:

root.d1 = {"a": "b"}
root.d2 = root.d1

Unfortunately, root.d2 = dict(root.d1) doesn't work either. I had to resort to this:

root.d2 = {k: root.d1[k] for k in ['a']}

which obviously doesn't work unless you know the keys ahead of time.

@reubano
Copy link
Contributor

reubano commented Mar 1, 2017

This works

root.d2 = root.d1.__dict__['_registry'].evaluated_items['root.d1']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants