You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.
In case he wants to reclaim his master branch, here is the diff:
return proto_model(**proto_args)
@classmethod
- def FromMessage(cls, message):
+ def FromMessage(cls, message, ignore_defaults=False):
"""Converts a ProtoRPC message to an entity of the model class.
Makes sure the message being converted is an instance of a ProtoRPC message
and
Args:
message: A ProtoRPC message.
+ ignore_defaults: When true, property default values are ignored for fields
+ that are not provided in the message.
Returns:
The entity of the current class that was created using the
and
(message_class.__name__))
raise TypeError(error_msg)
- entity_kwargs = {}
alias_args = []
+ # By creating the object first we can default values to None if
+ # required (when ignore_defaults is True).
+ entity = cls()
+
+ # Ignoring defaults means we need to initially set all fields to None
+ if ignore_defaults:
+ for property_name, property in cls._properties.iteritems():
+ if property._default:
+ setattr(entity, property._code_name, None)
+
for field in sorted(message_class.all_fields(),
key=lambda field: field.number):
name = field.name
and
if isinstance(value_property, EndpointsAliasProperty):
alias_args.append((local_name, to_add))
else:
- entity_kwargs[local_name] = to_add
-
- # Will not throw exception if a required property is not included. This
- # sort of exception is only thrown when attempting to put the entity.
- entity = cls(**entity_kwargs)
+ setattr(entity, local_name, to_add)
# Set alias properties, will fail on an alias property if that
# property was not defined with a setter
and
"""
if user_required and endpoints.get_current_user() is None:
raise endpoints.UnauthorizedException('Invalid token.')
-
- request_entity = cls.FromMessage(request)
+
+ # Ignore the default values of properties so all entities are returned
+ request_entity = cls.FromMessage(request, ignore_defaults=True)
query_info = request_entity._endpoints_query_info
query_info.SetQuery()
The text was updated successfully, but these errors were encountered:
How does one go about figuring out what the original values of the entities were VS. what was passed in from the request? Second, how does the filter population handle properties that have a indexed=False? If you needed to do some custom logic at the endpoints, is it best to just create a webapp2 handler instead?
How does one go about figuring out what the original values of the
entities were VS. what was passed in from the request? Second, how does the
filter population handle properties that have a indexed=False? If you
needed to do some custom logic at the endpoints, is it best to just create
a webapp2 handler instead?
—
Reply to this email directly or view it on GitHub #100 (comment)
.
Danny Hermes
University of Michigan
B.S. Economics and Mathematics 2010
(815) 440-7093
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
See #82 by @onimitch
In case he wants to reclaim his master branch, here is the diff:
and
and
and
and
The text was updated successfully, but these errors were encountered: