1602: post-review is extremly useless as external library

Jan.Ko*******@gmai***** (Google Code) (Is this you? Claim this profile.)
April 7, 2010
What version are you running?
git master

What's the URL of the page containing the problem?
post-review script architecture


What is the expected output? What do you see instead?

1.
---
Problem:
-----------------
(the biggest one) When I import postreview in mod_python and some function
from postreview just end by die() function I don't see anything on output

Solution:
-----------------
die should raise exception which should be catch in calling main() block,
print and then sys.exit(1) which have sens only when running as command
line program

2.
---
Problem:
-----------------
Variable "options" in postreview is global, and "only" way to pass
"options" is use command line parameters. This isn't good.

Solution:
-----------------
Some solution is parametrize main() by current options.*

Workaround (example):
-----------------
import rbtools.postreview as rb

class Empty():
    pass

rb.options = Empty()
rb.options.rid = None
rb.options.debug = None
rb.options.username = USERNAME
rb.options.password = PASSOWRD
rb.options.server = SERVER
rb.options.publish = False
rb.options.summary = TITLE
rb.options.bugs_closed = BUGS
rb.options.description = DESCRIPTION
rb.options.submit_as = SUBMIT_AS
rb.options.repository_url = REPOSITORY_URL
rb.options.diff_filename = None
rb.options.ccroot_path = None
rb.options.target_groups = None
rb.options.target_people = REVIEWER
rb.options.branch = None
rb.options.testing_done = None

3.
---
Problem:
-----------------
Run main() with custom tool or home is impossible

Solution:
-----------------
Add main() additional parameters like tool, home or something and make the
logic only for run tool as command line before

Workaround:
-----------------
Some things is could be modified by inject some environment variables as
HOME or APPDATA

What operating system are you using? What browser?
Linux / Unix

Please provide any additional information below.
chipx86
#1 chipx86
It's in no way intended to be used this way. In time we'll have a Python API, but
post-review itself isn't designed to be a library and shouldn't be used as one. You
should call out to post-review as an external program, pass the parameters, and parse
the output, unless your caller can just handle the web API itself.
  • +NotABug
#2 Jan.Ko*******@gmai***** (Google Code) (Is this you? Claim this profile.)
Ok but there is very simple, fast and safe quick fix witch change everything for me
and nothing for You. I post it and we will see.
#3 Jan.Ko*******@gmai***** (Google Code) (Is this you? Claim this profile.)
This was bad idea. Typo was fixed.
#4 Jan.Ko*******@gmai***** (Google Code) (Is this you? Claim this profile.)
Review was discarded.
chipx86
#5 chipx86
I mainly just don't want to support this and break people when we make changes. It's
hard for us to test and maintain compatibility here. I'd rather focus efforts on a
proper API for people to use.