-
Notifications
You must be signed in to change notification settings - Fork 4
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
Figure out why we need to __getitem__ #5
Comments
Comment by vodik Looking at the code quickly, I bet you its because you're letting Calling I see this comment in your code under
Not sure what |
Comment by vodik In all honestly, you should probably not use As far as I understand, its also how virt-manager does it: https://github.com/virt-manager/virt-manager/blob/master/virtinst/xmlbuilder.py |
Comment by tgoodlet Alright so I found the obvious answer to this question. It's so that obj.appendfrom('newkey', 'oldkey') is obj['newkey'] == True The reason that this it not true with Couple things to note here:
@vodik to counter your points:
No side effects are triggered other then of course assigning the new element in the config (whether this is a simple scalar value or a sub-mapping type depends on the context).
No,
Right and this is the main question: can we avoid the settings = {'sip-ip': '10.10.10.9'}
profiles['doggy'] = {'settings': settings }
settings['sip-ip'] = '10.10.10.11'
assert profiles['doggy']['settings']['sip-ip'] == '10.10.10.11' but you're right ^ is more consistent with traditional mutable mappings.
Old comment.
It's a factory method for creating new instances of the same type but with the some of the current instance's state (explicit instance vars in this case) passed to the new obj. You can always modify internals by reference afaict.
I don't think that's a good idea. That code in |
Comment by vodik
Well key word was can.
I agree its overly complicated, but I wouldn't argue its due to the approach, its consequences to how they chose to expose/architect details. I really do thing you want to do a full serialise/deserialise rather than this live editing. If you don't want to do that, just drop |
Comment by tgoodlet
Let me clarify, the code currently does serialise/deserialise before it hits the target file system (so it's not live edited from the perspective of the target FreeSWITCH's config) but the in-memory I don't see why this is a problem? Maybe you have a reason why this shouldn't be allowed? Secondly, I'm pretty sure I can make |
Comment by vodik When I mean serialize/deserialize, I mean don't use etree as your internal representation. That should only be at the boundary if you can't make it work. But whatever, if you can make it work as expected. |
Comment by tgoodlet @vodik if I don't modify the Imo this complexity is unjustified when
But why? I need to know why this makes the design simpler/better and/or my life easier. |
Issue by tgoodlet
Thursday Sep 22, 2016 at 00:50 GMT
Originally opened as sangoma/sandswitches#1
@vodik made a note and I can't remember why I needed it to get things working but the
__getitem__
call here seems superfluous.The text was updated successfully, but these errors were encountered: