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

Add a 'serialized' flag to properties and don't serialize if it's false #3179

Closed
wants to merge 1 commit into from

Conversation

havocp
Copy link
Contributor

@havocp havocp commented Nov 23, 2015

properties_with_values() now returns only serializable properties, since
it's used in contexts such as to_json() and clone() which should only
use serializable stuff.

properties_with_values() now returns only serializable properties, since
it's used in contexts such as to_json() and clone() which should only
use serializable stuff.
@mattpap
Copy link
Contributor

mattpap commented Nov 23, 2015

Is there any existing example where this is needed?

@havocp
Copy link
Contributor Author

havocp commented Nov 23, 2015

Yes, it's needed to get foo_units out of the json (since it's already "foo" : { "units" : "rad" })

self.assertTrue('start_angle' in json)
self.assertTrue('start_angle_units' not in json)
self.assertTrue('outer_radius' in json)
self.assertTrue('outer_radius_units' not in json)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is the reason for the PR. (though it's not just AnnularWedge affected of course, it's all DistanceSpec and AngleSpec)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I see the point of this PR. Although in the case of *_units properties, I think this is only a temporary measure and there should be a special class of property to encode them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working on that now. I have a follow-on PR that will make it a lot easier to make _units props truly 'virtual'.
Hmm. This may actually remove the need to put serialized= kwarg on every constructor, come to think of it.

@@ -124,13 +124,14 @@ class DeserializationError(Exception):
class Property(object):
""" Base class for all type properties. """

def __init__(self, default=None, help=None):
def __init__(self, default=None, help=None, serialized=True):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the default is True and later you change this with prop._serialized = False, so maybe this argument is unnecessary? If it's left, then specific property classes should be allowed to get this argument as well, so you would have to change a lot of constructors (won't be pretty).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized this later, yeah. The "right thing" is to add this keyword arg to all the other constructors, I think. it sort of sucks, but.

@mattpap mattpap added this to the 0.11.0 milestone Nov 24, 2015
@bryevdv bryevdv closed this Nov 25, 2015
@bryevdv
Copy link
Member

bryevdv commented Nov 25, 2015

superseded by #3190

@damianavila damianavila deleted the not-serialized-props branch November 25, 2015 22:52
@damianavila damianavila removed this from the 0.11.0 milestone Nov 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants