Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
New transaction-scheme
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 36 of 36 - Collapse all  -  Translate all to Translated (View all originals) < Older 
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jan Schukat  
View profile  
 More options Oct 15, 4:52 am
From: Jan Schukat <shoo...@email.de>
Date: Thu, 15 Oct 2009 10:52:39 +0200
Local: Thurs, Oct 15 2009 4:52 am
Subject: Re: [Trac-dev] Re: New transaction-scheme

Ok, so best would probably be, to include add the decorator  
definitions to the trunk, since they don't interfere with anything,  
maybe without the WikiPage adjustments in delete and save. And then  
the new db functionality, like my rename stuff, can start using it, so  
we can get experience.

Attached is a diff, that just contains the decorators.

So either apply this patch, or the one in the mail before with the  
changed WikiPage. Either way, some conclusion would be nice, so it's  
clear how to proceed.

Regards

Jan

  transaction_decorators.diff
2K Download

On 14.10.2009, at 22:57, Remy Blank wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christian Boos  
View profile  
 More options Oct 15, 5:45 am
From: Christian Boos <cb...@neuf.fr>
Date: Thu, 15 Oct 2009 11:45:10 +0200
Local: Thurs, Oct 15 2009 5:45 am
Subject: Re: [Trac-dev] Re: New transaction-scheme
Hello Jan,

Thanks for your continued efforts, we're getting there ... but not yet.

First, some general remarks. Apparently your mail program and my
Thunderbird are not friendly to each other ;-)

The first patch (transactions_py2.5.diff) was completely garbled. From
the web interface however, the patch can be obtained correctly
(http://groups.google.com/group/trac-dev/msg/dfbfd93adaabfb06?hl=en).
So, in doubt, let's blame Thunderbird here, but I would be interested to
know how it worked for others.

The second patch (transactions_py2.4.diff) contained the changes
*twice*. You must have done svn diff >> .diff at some point...
Ok, those were uninteresting comments about the form of the patches,
sorry but this is just getting in the way of being able to review
comfortably the changes.

Now, slightly more on topic, you should really try to conform to the
coding style adopted by the Trac project, as those are prerequisites for
any changes (remember that I already made such comments in #1106 - (1)).
In particular, we try to conform to the standard Python coding style
(PEP 8 (2)), and there are constructs in your changes that are quite at
odds with those guidelines (more than one statement per line, if(test),
...).

Jan Schukat wrote:
> Hello again,

> I have installed a python2.4 again, and created two implementations of  
> the transaction scheme, one for 2.4, which uses decorators, and one  
> for 2.5, which uses with statements. In both cases I converted the  
> WikiPage class to use the scheme, and both pass the complete unit test  
> and functional test suits in the python versions they are supposed to  
> work in.

Good, that's indeed *the* recommended way to validate the changes.
Writing additional tests for newly introduced features is also useful.

> Both are very very similar in their use, but I do think now, it would  
> be unwise to have both implementations present at the same time in the  
> code. Whether both implementations are present or not, it wold need  
> need cleanup, once 2.4 support is dropped, and in the case of just  
> having to replace the decorators with with-statements and the context  
> managers, without all that version check code, this could be done with  
> a quite simple sed script ...

Right, we only need the decorator based approach for now. Doing the
context manager based approach during the experimental stage is
nevertheless important so that we can be confident we're on the right
track and that the migration will be painless.

> What I did notice though is, that you can't get variables out of the  
> with block. The overwriting of the new_name variable in the Trac 0.13  
> example by Christian below isn't visible outside the with block. At  
> least that is what the unit tests told me when I tried it. Maybe I'm  
> not aware of something here.

Well, it should work. What do you see when you run my test program (the
one from (3))?

$ /C/Dev/Python254/python with_transaction.py
...
== (fail=False, do_rename=<function do_rename_with at 0x027E6970>)

-- testing automatic transaction
 >> Environment.get_db_cnx
 >> execute something successfully...
 >> commit transaction
 > it worked: renamed

-- testing explicit transaction
 >> Environment.get_db_cnx
 >> execute something successfully...
 > it worked: renamed
 >> execute something successfully...
 > it worked: renamed
 >> commit transaction
...

The "it worked: renamed" part shows that the assignment in the with
block modified the reference from the containing block:

# Trac 0.13
def do_rename_with(env, db=None):
    new_name = None

    with transaction(env, db) as db:
        db.execute()
        new_name = 'renamed' # modifies `new_name` above

    if new_name:
        print '> it worked:', new_name
        return True

This should work, therefore we should also use the modification "by
reference" suggested by Remy for the decorator approach, modifying the
single element of an array, rather than my clumsy way of returning a
value via the function name ;-)

Btw, please take all of this as /constructive/ criticisms, I wouldn't
bother making them if I wasn't interested in seeing your contributions
integrated in the end ;-)

Now heading to your next patch...

-- Christian

> If this proposal gets accepted, I would start converting all code to  
> use the new scheme, as I have stated before.
> If there are still objections, I would like to hear them.

(1) - http://trac.edgewall.org/ticket/1106#comment:110
(2) - http://www.python.org/dev/peps/pep-0008/
(3) - http://groups.google.com/group/trac-dev/msg/7ec20d1f259aa046

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christian Boos  
View profile  
 More options Oct 15, 6:17 am
From: Christian Boos <cb...@neuf.fr>
Date: Thu, 15 Oct 2009 12:17:35 +0200
Local: Thurs, Oct 15 2009 6:17 am
Subject: Re: [Trac-dev] Re: New transaction-scheme

Jan Schukat wrote:
> Ok, so best would probably be, to include add the decorator  
> definitions to the trunk, since they don't interfere with anything,  
> maybe without the WikiPage adjustments in delete and save. And then  
> the new db functionality, like my rename stuff, can start using it, so  
> we can get experience.

> Attached is a diff, that just contains the decorators.

This time the patch was fine for Thunderbird ;-)

Some additional comments I could have made for the previous patch as well:
 - from the rest of discussion, you should have seen that Remy and me
agreed on a version without the "raise_exceptions" approach, so you
shouldn't have reintroduced that, at least not without argumentation;
same thing for the "return" part, as I already commented
 - you introduced two very similar decorators, with_transaction and
with_db_transaction; the only benefit of the with_transaction one is to
get a cursor from the db, which is something very trivial to do anyway
(db.cursor()), so I don't think this warrants the extra complexity of
having *2* decorators; with_db_transaction is enough and should be
renamed with_transaction.

> So either apply this patch, or the one in the mail before with the  
> changed WikiPage. Either way, some conclusion would be nice, so it's  
> clear how to proceed.

Once we find the patch satisfying (i.e. all the feedback taken into
account), we'll integrate it in trunk or perhaps first in a tmp branch,
as we see fit.

(Remy wrote)

>> I wouldn't convert all database writes to the new scheme in one big
>> patch.

Agreed.

>> Instead, I would rather introduce it with new code (IIRC, you
>> wanted to work on wiki page renames) and get familiar with it, maybe
>> refine the scheme somewhat with the experience gained, and only then,
>> transition old code progressively.

Or, as there were also a bunch of #1106 specific issues to address
first, do it for one module, exactly like you did in your
transactions_py2.4.diff patch.

>> Converting all writes at the same time sounds like a good way to
>> introduce subtle bugs all over the code. Instead, if the new
>> functionality is initially confined to a small section of code, the
>> potential damage should be confined as well.

Also agreed. But we might want to make all these changes on a branch, in
order to get an overview of all the changes implied.

In particular, I'm wondering how this will interact with #6348
(http://trac.edgewall.org/ticket/6348), which I should really get around
to ...

-- Christian


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jan Schukat  
View profile  
 More options Oct 15, 6:57 am
From: Jan Schukat <shoo...@email.de>
Date: Thu, 15 Oct 2009 12:57:49 +0200
Local: Thurs, Oct 15 2009 6:57 am
Subject: Re: [Trac-dev] Re: New transaction-scheme
1. Mail
I'm using the  OS X Mail.app now, don't think that is unable to handle  
mailing lists. I guess my mail provider is more at fault here and  
messes up MessageIDs. But that would be strange, since I used that  
same mail provider for apache-dev mailing lists, libstdc++-dev mailing  
lists and mozilla-dev mailing lists, and no one complained.
Maybe I should dig out my gmail account, which I mainly use for spam  
catching now.

2. Me messing up
Don't worry about how I might feel. When I'm wrong, I'm wrong, when I  
don't know something or missed something, then I don't know or missed  
something. No big deal. Only made very minor one line patch  
contributions to open source projects up to now though, so this is a  
little new to me, culture wise, as I mainly worked on internal  
projects for big corporations so far. Also, I lack experience in  
python, as you can tell, used it only for quick and dirty stuff up to  
now.
Ok, enough excuses.

3. Actual issues
  - have read the python coding style now
  - only one decorator, that passes the db. Ok, wasn't sure about that  
anyway.
  - leave out raise_exceptions, always propagate
  - don't like the reference approach to pass values out, since it is  
sort of a hack, but it is structurally the same to what will be used  
later in the with statement, it's best I guess, will not be that  
common anyway
  - new patch with the adjustments and the WikiPage using the  
decorators will come shortly

4. Your test script
  - works fine, don't know what went wrong in my tests within the trac  
code
  - will look into that a little more

Now I got to run some errands

Jan

On 15.10.2009, at 11:45, Christian Boos wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jan Schukat  
View profile  
 More options Oct 15, 12:13 pm
From: Jan Schukat <shoo...@email.de>
Date: Thu, 15 Oct 2009 18:13:02 +0200
Local: Thurs, Oct 15 2009 12:13 pm
Subject: Re: [Trac-dev] Re: New transaction-scheme

Ok, a new patch, just one decorator, WikiPage implemented.

Also did some tests concerning the with-block variable scoping, got no  
problems this time, so I guess my problems earlier, while I was  
testing different approaches, were something entirely different.

  transactions.diff
7K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christian Boos  
View profile  
 More options Oct 15, 12:51 pm
From: Christian Boos <cb...@neuf.fr>
Date: Thu, 15 Oct 2009 18:51:15 +0200
Local: Thurs, Oct 15 2009 12:51 pm
Subject: Re: [Trac-dev] Re: New transaction-scheme

Jan Schukat wrote:
> Ok, a new patch, just one decorator, WikiPage implemented.

Hey, this one looks great!

Remy, OK for an experimental branch, starting with this change?

-- Christian


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Remy Blank  
View profile  
 More options Oct 16, 4:27 pm
From: Remy Blank <remy.bl...@pobox.com>
Date: Fri, 16 Oct 2009 22:27:14 +0200
Local: Fri, Oct 16 2009 4:27 pm
Subject: Re: [Trac-dev] Re: New transaction-scheme

Christian Boos wrote:
> Hey, this one looks great!

I have got some minor nitpicks:

 - Use WikiFormatting for docstrings.

 - The "try: except: raise" in the case where db is not None is not
necessary, just call fn(db).

 - Sort imports alphabetically.

 - Use "cursor" for cursors. That's the convention for the rest of Trac.

 - There's still an "if(new_text)" in save().

> Remy, OK for an experimental branch, starting with this change?

A branch sounds a bit overkill for this, I would have opened a ticket
and tracked progress with patches, and integrated the result into trunk.
But I'm ok if you think it is worth the overhead.

-- Remy

  signature.asc
< 1K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
shoo...@email.de  
View profile  
 More options Oct 16, 7:34 pm
From: shoo...@email.de
Date: Sat, 17 Oct 2009 01:34:24 +0200
Local: Fri, Oct 16 2009 7:34 pm
Subject: Re: [Trac-dev] Re: New transaction-scheme
Agreed with all nitpicks, and will prepare new patch on Sunday (I'm away now).

Except, what is the issue with the new_text variable? That's  my way of moving validity checks out of the transaction, since they don't belong there and should be done before the transaction is started. I could make the checks multiple times though, first to rule out the error case, and then to distinguish between the two update types. Just makes the code longer and less clear IMHO.

Regards

Jan

Remy Blank <remy.bl...@pobox.com> schrieb am 16.10.2009 22:28:19:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Remy Blank  
View profile  
 More options Oct 17, 3:36 am
From: Remy Blank <remy.bl...@pobox.com>
Date: Sat, 17 Oct 2009 09:36:30 +0200
Local: Sat, Oct 17 2009 3:36 am
Subject: Re: [Trac-dev] Re: New transaction-scheme

shoo...@email.de wrote:
> Except, what is the issue with the new_text variable? That's
> my way of moving validity checks out of the transaction, since
> they don't belong there and should be done before the transaction
> is started. I could make the checks multiple times though, first
> to rule out the error case, and then to distinguish between the
> two update types. Just makes the code longer and less clear IMHO.

I should have been more explicit, sorry. I was referring to:

  if(new_text):

This looks so much like C code ;-) Use this instead:

  if new_text:

-- Remy

  signature.asc
< 1K Download

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jan Schukat  
View profile  
 More options Oct 18, 9:30 am
From: Jan Schukat <shoo...@email.de>
Date: Sun, 18 Oct 2009 15:30:11 +0200
Local: Sun, Oct 18 2009 9:30 am
Subject: Re: [Trac-dev] Re: New transaction-scheme

Ok, here the updated diff, with those little things taken care of.

Jan

  transactions.diff
6K Download

On 16.10.2009, at 22:27, Remy Blank wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christian Boos  
View profile  
 More options Oct 18, 4:12 pm
From: Christian Boos <cb...@neuf.fr>
Date: Sun, 18 Oct 2009 22:12:11 +0200
Local: Sun, Oct 18 2009 4:12 pm
Subject: Re: [Trac-dev] Re: New transaction-scheme

Jan Schukat wrote:
> Ok, here the updated diff, with those little things taken care of.

Thanks!

I've now created http://trac.edgewall.org/ticket/8751 for tracking
progresses on the sandbox/8751-with_transaction branch, which will be
used to generalize this approach to the rest of Trac.
Once the whole code base is converted and if in the meantime the
approach is confirmed to be sound, we'll merge it back to trunk.

-- Christian


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google