Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
mentors.debian.net
debexpo
Commits
5d5e7015
Commit
5d5e7015
authored
Jul 11, 2012
by
Clément Schreiner
Browse files
Rename 'plugin' column to 'entity' and update BasePlugin to allow multiple result models.
parent
7a8a8184
Changes
2
Hide whitespace changes
Inline
Side-by-side
debexpo/model/plugin_results.py
View file @
5d5e7015
...
...
@@ -40,7 +40,7 @@ from debexpo.model.package_versions import PackageVersion
t_plugin_results
=
sa
.
Table
(
'plugin_results'
,
meta
.
metadata
,
sa
.
Column
(
'id'
,
sa
.
types
.
Integer
,
primary_key
=
True
),
sa
.
Column
(
'
plugin
'
,
sa
.
types
.
String
(
200
)),
sa
.
Column
(
'
entity
'
,
sa
.
types
.
String
(
200
)),
sa
.
Column
(
'package_version_id'
,
sa
.
types
.
Integer
,
sa
.
ForeignKey
(
'package_versions.id'
),
...
...
@@ -64,7 +64,7 @@ class PluginResultData(OrmObject):
plugin_result_mapper
=
orm
.
mapper
(
PluginResult
,
t_plugin_results
,
polymorphic_on
=
t_plugin_results
.
c
.
plugin
,
polymorphic_on
=
t_plugin_results
.
c
.
entity
,
polymorphic_identity
=
'plugin_results'
,
properties
=
{
'package_version'
:
orm
.
relation
(
PackageVersion
,
...
...
debexpo/plugins/__init__.py
View file @
5d5e7015
...
...
@@ -41,8 +41,9 @@ from debexpo.model.plugin_results import PluginResultData
class
BasePlugin
(
object
):
result_model
=
None
"""
Base class for importer plugins.
"""
def
__init__
(
self
,
package_version
,
**
kw
):
self
.
_db_objects
=
[]
self
.
package_version
=
package_version
...
...
@@ -58,14 +59,15 @@ class BasePlugin(object):
def
_add_db_objects
(
self
,
*
db_objects
):
self
.
_db_objects
.
extend
(
db_objects
)
# TODO/NOTE: maybe we should do this into PluginResult? (through an association proxy?)
def
_add_data
(
self
,
result
,
**
data
):
result_data
=
[
PluginResultData
(
plugin_result
=
result
,
key
=
key
,
value
=
data
[
key
])
for
key
in
data
]
self
.
_add_db_objects
(
*
result_data
)
def
_new_result
(
self
,
**
data
):
result
=
self
.
result_
model
(
package_version
=
self
.
package_version
)
def
_new_result
(
self
,
result_cls
,
**
data
):
result
=
result_
cls
(
package_version
=
self
.
package_version
)
self
.
_add_db_objects
(
result
)
self
.
_add_data
(
result
,
**
data
)
return
result
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment