[opensuse-buildservice] [gsoc] osc code cleanup - summary of week 2

Hi, here's a small summary of the 2nd (coding) week. This week I spent most of my time with working on an OO-style class for doing http requests: * it's possible to switch the http(s) implementation without touching any library code * supports response validation (if a schema was specified for the request) Currently I'm still working on the "remote models": * decided to use lxml.objectify [1]: - goal is to encapsulate the xml logic solely into the object itself - example workflow: prj = RemoteProject('some_name') prj.title = 'dummy' prj.description = 'foo bar' repo = prj.add_repository(name='openSUSE_Factory') repo.add_path(project='openSUSE:Factory', repository='standard') repo.add_arch('i586') # change arch to x86_64 repo.arch[0] = 'x86_64' repo.save() Minor stuff: * decided to use the "logging" module: this way we can easily add "debug" and "info" etc. messages and it's up to the "client" which messages it wants to display (I'm not talking about the messages which are displayed when "osc up" is called or something like that) Marcus [1] http://lxml.de/objectify.html -- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org

On Saturday 04 June 2011 00:56:24 Marcus Hüwe wrote: > Hi, > > here's a small summary of the 2nd (coding) week. This > week I spent most of my time with working on an OO-style class > for doing http requests: > * it's possible to switch the http(s) implementation without touching any > library code > * supports response validation (if a schema was specified for the request) I've looked at the code and tests and like it. As far as I have seen, you included a 'directory' schema from the OBS. At some point in time we may either want to move schemas into a shared module or move osc2 back into the OBS repo. > Currently I'm still working on the "remote models": > * decided to use lxml.objectify [1]: > - goal is to encapsulate the xml logic solely into the object itself > - example workflow: > prj = RemoteProject('some_name') > prj.title = 'dummy' > prj.description = 'foo bar' > repo = prj.add_repository(name='openSUSE_Factory') > repo.add_path(project='openSUSE:Factory', repository='standard') > repo.add_arch('i586') > # change arch to x86_64 > repo.arch[0] = 'x86_64' > repo.save() Good choice, this will greatly reduce the need for XML parsing, does lxml.objectify allow validation when you create an object from a XML string? > > Minor stuff: > * decided to use the "logging" module: > this way we can easily add "debug" and "info" etc. messages and it's up > to the "client" which messages it wants to display (I'm not talking about > the messages which are displayed when "osc up" is called or something like > that) Natural choice, I've seen you used it already in the httprequest module. -- Mit freundlichen Grüßen, Sascha Peilicke http://saschpe.wordpress.com

On 2011-06-06 10:31:59 +0200, Sascha Peilicke wrote: > On Saturday 04 June 2011 00:56:24 Marcus Hüwe wrote: > > Hi, > > > > here's a small summary of the 2nd (coding) week. This > > week I spent most of my time with working on an OO-style class > > for doing http requests: > > * it's possible to switch the http(s) implementation without touching any > > library code > > * supports response validation (if a schema was specified for the request) > I've looked at the code and tests and like it. As far as I have seen, you > included a 'directory' schema from the OBS. At some point in time we may > either want to move schemas into a shared module or move osc2 back into the > OBS repo. > The directory schema is just a "dummy" schema which is used for testing only (I was too lazy to write a new schema that's why I copied it). > > Currently I'm still working on the "remote models": > > * decided to use lxml.objectify [1]: > > - goal is to encapsulate the xml logic solely into the object itself > > - example workflow: > > prj = RemoteProject('some_name') > > prj.title = 'dummy' > > prj.description = 'foo bar' > > repo = prj.add_repository(name='openSUSE_Factory') > > repo.add_path(project='openSUSE:Factory', repository='standard') > > repo.add_arch('i586') > > # change arch to x86_64 > > repo.arch[0] = 'x86_64' > > repo.save() > Good choice, this will greatly reduce the need for XML parsing, does > lxml.objectify allow validation when you create an object from a XML string? > It's possible to validate the string before you create the object. In our case the xml validation should happen anyway in the httprequest module (if the xml string comes from the api). If we send a "constructed" xml to the server the validation should happen in the corresponding model (before passing the data to the http class). > > > Minor stuff: > > * decided to use the "logging" module: > > this way we can easily add "debug" and "info" etc. messages and it's up > > to the "client" which messages it wants to display (I'm not talking about > > the messages which are displayed when "osc up" is called or something like > > that) > Natural choice, I've seen you used it already in the httprequest module. Marcus -- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
participants (2)
-
Marcus Hüwe
-
Sascha Peilicke