#241 new package model validation - #249
Conversation
| notice = StringType(default=None) | ||
| url = StringType(default=None) | ||
|
|
||
| def as_dict(self): |
There was a problem hiding this comment.
What is this replaced by? the equivalent schematics function?
If this is the case, as_dict is rather clear as a name, I would not want to have the schematics specific to percolat in the codebase everywhere. Instead we should have an as_dict function that wraps schematics calls.
There was a problem hiding this comment.
there is an inbuilt function to_primitive which can serialize an object...so, I removed as_dict
There was a problem hiding this comment.
ok, so do not remove as_dict. Make it available on the top level Package class and just have it call to_primitive : the point is that we do not want the external access to Packages to be tied to schematics.
There was a problem hiding this comment.
Related we should not depend on the default constructor for schematics models to pass a dict vs named arguments: we should instead abstract that and accept **kwargs and pass the kwargs to schematics
There was a problem hiding this comment.
@pombredanne in order to override the default constructor in schematics we need to edit the Model class in schematics.models.py. But everytime we configure scancode we get a fresh install of schematics and we lose the changes. how can we solve this problem?
There was a problem hiding this comment.
maybe we can edit the schematics wheel file...is that a good idea?
There was a problem hiding this comment.
maybe we can edit the schematics wheel file...is that a good idea?
Not really a good idea.
There was a problem hiding this comment.
in order to override the default constructor in schematics we need to edit the Model class in schematics.models.py. But everytime we configure scancode we get a fresh install of schematics and we lose the changes. how can we solve this problem?
do not ever change schematics locally. We can subclass and compose, not override....
|
|
||
| >>> q=Package(version='2') | ||
| >>> p=Package(version='1') | ||
| >>> q=Package(dict(versioning=Version(dict(version='2')))) |
There was a problem hiding this comment.
This is the part we would not want: a direct depdency on the way schematics demands a dict as args.
We want instead to do:
Package(versioning=Version(version='2'))
or Package(versioning=Version('2'))
0afce24 to
bbed9c0
Compare
* use actual types for checksums (SHA1, ...), URLs and URIs * New Version type and subclasses as needed * ensure that the field order is always defined to serialize fields properly in ordered dictionaries. * moved fields choices at the module level vs. class level * improved models for dependencies, created related package model * removed id and added identifier
bbed9c0 to
ddf2aa3
Compare
|
I am merging this in develop now. Thanks @rakeshbalusa ! |
Enforced the correctness of package objects.