Open
Bug 915689
Opened 11 years ago
Updated 2 years ago
Move all of the _*_to_hash methods in the webservice modules to separate shared View.pm module
Categories
(Bugzilla :: WebService, enhancement)
Tracking
()
NEW
People
(Reporter: dkl, Unassigned)
Details
To maintain a consistent data structure and to encourage code re-use as much as possible, I nominate we create a new Bugzilla/WebService/View.pm module to contain all of the various _*_to_hash methods. This will be helpful to all of the modules that sometimes return similar data and can just use the proper methods from View.pm. The methods in View.pm should all have a consistent perimeter signature as well.
dkl
Reporter | ||
Updated•11 years ago
|
Severity: normal → enhancement
OS: Linux → All
Hardware: x86_64 → All
Comment 1•11 years ago
|
||
Why not using Bugzilla/WebService/Util.pm?
Reporter | ||
Comment 2•11 years ago
|
||
(In reply to Frédéric Buclin from comment #1)
> Why not using Bugzilla/WebService/Util.pm?
I thought about that as well but I felt like the _to_hash methods are more about manipulating the data before consumption by the client rather than being general purpose utility methods. I am not against putting them in Util.pm but I felt it was cleaner to keep things separate based on their use cases.
dkl
Comment 3•11 years ago
|
||
What about using a as_hash method for each object? You can have a default Bugzilla::Object to_hash (that gets the basic information), and can then override it for the complex things. Seems better to make it a function of the object itself rather than be in its own perl module.
Comment 4•11 years ago
|
||
The other thing to remember (regardless of the method chosen), is that we have massive performance improvements about getting only the fields that we need (mainly in bug_to_hash, like keywords and groups). It is important that these functions have the ability to know what fields are/aren't needed.
Comment 5•11 years ago
|
||
(In reply to Simon Green from comment #3)
> What about using a as_hash method for each object? You can have a default
> Bugzilla::Object to_hash
I'm not a fan of polluting Bugzilla::Object with WS-specific methods. Also, I fear that you could inadvertently use the default as_hash() method and bypass some security checks. Also, you have no way to know how to format the output data (interger, string, date, ...) by default, making the default as_hash() method useless.
Reporter | ||
Updated•2 years ago
|
Assignee: dkl → webservice
Status: ASSIGNED → NEW
You need to log in
before you can comment on or make changes to this bug.
Description
•