paylogic / halogen Goto Github PK
View Code? Open in Web Editor NEWPython HAL generation/parsing library
Home Page: http://halogen.readthedocs.org/
License: MIT License
Python HAL generation/parsing library
Home Page: http://halogen.readthedocs.org/
License: MIT License
Looking through the code it appears curies are initially constructed as a set() but subsequently converted to a plain list(). Therefore the order of curies is randomised.
This not only seems at odds with the expected behaviour of a list (or list-like) structure, but means tests become more complex --- having to convert the actual, and expected output to compare curies as sets is painful.
Perhaps this is more of an edge case, but would the developers be willing to discuss this possibility?
When implementing collection endpoints with paging support, the _link
relations usually have next
and prev
links. A corresponding schema for a user
collection could be something like
class UserCollectionSchema(Schema):
self = halogen.Link(attr=lambda u: f"url?page={u.page}")
next = halogen.Link(attr=lambda u: f"url?page={u.page + 1}")
prev = halogen.Link(attr=lambda u: f"url?page={u.page - 1}")
users = halogen.Embedded(halogen.types.List(UserSchema), attr=...)
Is it possible to only serialize/render the next
and prev
links only when a certain condition is met, e.g. when there is actually a next or a previous page?
Given these schema
class ChildSchema(halogen.Schema):
some_other_field = halogen.Attr(halogen.types.String())
class ParentSchema(halogen.Schema):
some_field = halogen.Attr(ChildSchema)
To make some_field
nullable during deserialization, I have to create a deserialize
class method on ChildSchema
:
class ChildSchema(halogen.Schema):
some_other_field = halogen.Attr(halogen.types.String())
@classmethod
def deserialize(self, value, **kwargs):
return None if value is None else super().deserialize(value)
It would be nice if halogen.Attr
supported a nullable
parameter:
some_field = halogen.Attr(ChildSchema, nullable=True)
Or alternatively support wrapping:
some_field = halogen.Attr(halogen.Nullable(ChildSchema))
Haven't thought about how this might be done, but it would be very nice if there was a way to control the order of fields when the HAL document is created/rendered.
I'm trying to deserialize an object which occasionally may contain a field. If the field is not present, I want to use a default value to deserialize the object.
If in the schema I use just the default value, during deserialization a validation error raises. If is use occasional = halogen.Attr(required=False, default="custom")
, the deserialization works but the field occasional field is not populated with "custom" value.
Schema's are hierarchical, but we need to come up with somewhat more usable data structure than what ValidationError.to_dict() returns. It should be easy to associate the error with the field of the web form.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.