Skip to content

#241 new package model validation - #249

Merged
pombredanne merged 41 commits into
developfrom
241-new-package-model
Jun 24, 2016
Merged

pombredanne merged 41 commits into
developfrom
241-new-package-model

Conversation

@balusarakesh

Copy link
Copy Markdown
Contributor

Enforced the correctness of package objects.

Comment thread src/packagedcode/models.py Outdated
notice = StringType(default=None)
url = StringType(default=None)

def as_dict(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

there is an inbuilt function to_primitive which can serialize an object...so, I removed as_dict

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

@balusarakesh balusarakesh Apr 20, 2016

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

maybe we can edit the schematics wheel file...is that a good idea?

@pombredanne pombredanne Apr 20, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe we can edit the schematics wheel file...is that a good idea?

Not really a good idea.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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....

@pombredanne pombredanne changed the title 241 new package model #241 new package model validation Apr 20, 2016
Comment thread src/packagedcode/models.py Outdated

>>> q=Package(version='2')
>>> p=Package(version='1')
>>> q=Package(dict(versioning=Version(dict(version='2'))))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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'))

@pombredanne
pombredanne force-pushed the 241-new-package-model branch 2 times, most recently from 0afce24 to bbed9c0 Compare May 18, 2016 09:25
rakesh balusa and others added 26 commits May 18, 2016 13:56
 * 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
@pombredanne
pombredanne force-pushed the 241-new-package-model branch from bbed9c0 to ddf2aa3 Compare May 20, 2016 15:27
@pombredanne

Copy link
Copy Markdown
Member

I am merging this in develop now. Thanks @rakeshbalusa !
In hindsight the use of schematics may not be my best choice, but we can fix that later

@pombredanne
pombredanne merged commit 91b8f0f into develop Jun 24, 2016
@pombredanne
pombredanne deleted the 241-new-package-model branch June 24, 2016 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants