Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(12354)

Issue 2552041: TrytondAsModule

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 6 months ago by yangoon1
Modified:
13 years, 4 months ago
Reviewers:
yangoon, udono, ced
Visibility:
Public.

Description

Example works here. python -m doctest trytondasmodule.rst: ok 1 items passed all tests: 27 tests in trytondasmodule.rst 27 tests in 1 items. 27 passed and 0 failed. Test passed.

Patch Set 1 #

Total comments: 8

Patch Set 2 : Updated to run directly from sources #

Total comments: 44
Unified diffs Side-by-side diffs Delta from patch set Stats (+126 lines, -1 line) Patch
M doc/conf.py View 1 chunk +2 lines, -1 line 0 comments Download
M doc/topics/index.rst View 1 chunk +1 line, -0 lines 0 comments Download
A doc/topics/trytondasmodule.rst View 1 1 chunk +123 lines, -0 lines 44 comments Download

Messages

Total messages: 5
udono
Looks good. http://codereview.appspot.com/2552041/diff/1/doc/topics/index.rst File doc/topics/index.rst (right): http://codereview.appspot.com/2552041/diff/1/doc/topics/index.rst#newcode16 doc/topics/index.rst:16: trytondasmodule here maybe I would use a ...
13 years, 6 months ago (2010-10-18 16:30:00 UTC) #1
yangoon1
http://codereview.appspot.com/2552041/diff/1/doc/topics/index.rst File doc/topics/index.rst (right): http://codereview.appspot.com/2552041/diff/1/doc/topics/index.rst#newcode16 doc/topics/index.rst:16: trytondasmodule On 2010/10/18 16:30:00, udono wrote: > here maybe ...
13 years, 6 months ago (2010-10-18 21:41:06 UTC) #2
ced
http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rst File doc/topics/trytondasmodule.rst (right): http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rst#newcode5 doc/topics/trytondasmodule.rst:5: Tryton Code as Library Why Library? http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rst#newcode9 doc/topics/trytondasmodule.rst:9: a ...
13 years, 6 months ago (2010-10-25 14:09:42 UTC) #3
yangoon1
http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rst File doc/topics/trytondasmodule.rst (right): http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rst#newcode5 doc/topics/trytondasmodule.rst:5: Tryton Code as Library On 2010/10/25 14:09:42, ced wrote: ...
13 years, 6 months ago (2010-10-25 21:38:01 UTC) #4
ced
13 years, 4 months ago (2010-12-04 16:13:48 UTC) #5
http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rst
File doc/topics/trytondasmodule.rst (right):

http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rs...
doc/topics/trytondasmodule.rst:5: Tryton Code as Library
On 2010/10/25 21:38:01, yangoon wrote:
> On 2010/10/25 14:09:42, ced wrote:
> > Why Library?
> 
> Took it from http://code.google.com/p/tryton/wiki/HowToUseTrytondAsAModule .

It will be more consisting to have the same title than the file name.

http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rs...
doc/topics/trytondasmodule.rst:9: a trytond/tryton instance on the same machine
providing the internal API to
On 2010/10/25 21:38:01, yangoon wrote:
> On 2010/10/25 14:09:42, ced wrote:
> > It is not access to instance but to data
> 
> For me it is access to data by means of an API. And trytondasmodule is access
to
> that API.

Ok. But it is not accessing to an instance of trytond.
So I propose this:

Using trytond as a module allow to access to data by using the internal Python
API.

http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rs...
doc/topics/trytondasmodule.rst:17: Interaction with a Tryton server (trytond)
with a simple import
On 2010/10/25 21:38:01, yangoon wrote:
> On 2010/10/25 14:09:42, ced wrote:
> > It is not to a server.
> 
> ??
> If trytond is not a server why do you write
> http://news.tryton.org/2010/09/some-news-from-development.html
> ?

I don't say that. I said that you don't interact with a server.
You use the same code.

http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rs...
doc/topics/trytondasmodule.rst:22: can do something like export
PYTHONPATH=/path/to/trytond/:$PYTHONPATH .
On 2010/10/25 21:38:01, yangoon wrote:
> On 2010/10/25 14:09:42, ced wrote:
> > I don't see why speaking about this.
> > This is general concept from Python
> 
> It is a preliminary with which not each user is familiar. Answering those
> questions in docs prevents people from asking on mailing list or IRC.

This should not be part of Tryton documentation. Just point to the Python doc:
http://docs.python.org/tutorial/modules.html#the-module-search-path

http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rs...
doc/topics/trytondasmodule.rst:28: modules with the profiling tools of Python.
On 2010/10/25 21:38:01, yangoon wrote:
> On 2010/10/25 14:09:42, ced wrote:
> > Why?
> 
> Dont't understand.

I don't why this sentence is there. There is no example of this usage and
personally I don't see why it is easier for that.

http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rs...
doc/topics/trytondasmodule.rst:30: database only after a cursor.commit() is
issued.
On 2010/10/25 21:38:01, yangoon wrote:
> On 2010/10/25 14:09:42, ced wrote:
> > Once again it is linked to PEPxxx which is database connection.
> 
> This doc is intended to provide a code snippet to show an example of the usage
> of trytond as module, not a reference. So same as above applies: help the
users
> to avoid errors. Makes especially sense with the following sentence.

We must not duplicate documentation because it is too hard to maintain it.
If you really want to describe the usage of database cursor in Python, just link
to http://www.python.org/dev/peps/pep-0249/

http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rs...
doc/topics/trytondasmodule.rst:31: * It is possible to do safe tests just by
avoiding the cursor.commit() call.
Same as above.

http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rs...
doc/topics/trytondasmodule.rst:38: >>> #! /usr/bin/env python
On 2010/10/25 21:38:01, yangoon wrote:
> On 2010/10/25 14:09:42, ced wrote:
> > No need of shebang for Python shell
> 
> Not here, but if copied into a script it will be necessary. I will omit it.

Neither, you can run it with `python script.py`
You will never see this in the Python documentation.

http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rs...
doc/topics/trytondasmodule.rst:43: ...     sys.path.insert(0,
os.path.dirname(DIR))
On 2010/10/25 21:38:01, yangoon wrote:
> On 2010/10/25 14:09:42, ced wrote:
> > I find this code is not clear for tutorial
> 
> I can elaborate, that here the path to trytond is set by other means than
> environment.

As we said above that trytond must be in the PYTHONPATH, it is not required to
have this code. And moreover it can confuse reader with unnecessary trick.

http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rs...
doc/topics/trytondasmodule.rst:55: >>> CONFIG['db_type'] = 'sqlite'
Why changing configuration from trytond.conf ?
It is confusing.

http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rs...
doc/topics/trytondasmodule.rst:73: >>> USER = 1
On 2010/10/25 21:38:01, yangoon wrote:
> On 2010/10/25 14:09:42, ced wrote:
> > I will not use uppercase here
> 
>
http://hg.tryton.org/trytond/file/5749fbc08672/trytond/tests/test_tryton.py#l44

Yes because it is a global variable used by others modules.
Here we are in an example and using uppercase doesn't help the readability.

http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rs...
doc/topics/trytondasmodule.rst:102: ...     cursor.commit()
On 2010/10/25 21:38:01, yangoon wrote:
> On 2010/10/25 14:09:42, ced wrote:
> > Why do you commit
> 
>
http://hg.tryton.org/trytond/file/5749fbc08672/trytond/tests/test_tryton.py#l123

Perhaps it is not required.

http://codereview.appspot.com/2552041/diff/6001/doc/topics/trytondasmodule.rs...
doc/topics/trytondasmodule.rst:118: 1
On 2010/10/25 21:38:01, yangoon wrote:
> On 2010/10/25 14:09:42, ced wrote:
> > This test is not reliable
> 
> It is a simple check on the expected result. This doc is not a test.

But someone could run it and get an error message which is odd.

Why not create a category and add the party on it and then browse it to check if
the category is there.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b