Changeset 466


Ignore:
Timestamp:
Oct 20, 2008, 12:03:15 AM (13 years ago)
Author:
Dominic Hargreaves
Message:

write_node: return the version of the node that was just committed, if successful (fixes #42)

Location:
wiki-toolkit/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • wiki-toolkit/trunk/Changes

    r457 r466  
    44        Add store->list_metadata_names, which will tell you all the
    55          different metadata types (names)
     6        write_node: return the version of the node that was just committed,
     7        if successful
    68
    790.76    13 July 2008
  • wiki-toolkit/trunk/lib/Wiki/Toolkit.pm

    r465 r466  
    793793$wiki->toggle_node_moderation to change the node moderation flag.
    794794
    795 Returns 1 on success, 0 on conflict, croaks on error.
     795Returns the version of the updated node on success, 0 on conflict, croaks on
     796error.
    796797
    797798B<Note> on the metadata hashref: Any data in here that you wish to
     
    853854        $search->index_node($node, $store->charset_encode($content) );
    854855    }
    855     return 1;
     856    return $ret;
    856857}
    857858
  • wiki-toolkit/trunk/lib/Wiki/Toolkit/Store/Database.pm

    r457 r466  
    451451you (or your chosen subclass). This method shouldn't really be used
    452452directly as it might overwrite someone else's changes. Croaks on error
    453 but otherwise returns true.
     453but otherwise returns the version number of the update just made.
    454454
    455455Supplying a ref to an array of nodes that this ones links to is
     
    658658    }
    659659
    660     return 1;
     660    return $version;
    661661}
    662662
  • wiki-toolkit/trunk/lib/Wiki/Toolkit/Store/MySQL.pm

    r431 r466  
    4646Locks the node, verifies the checksum, calls
    4747C<write_node_post_locking> with all supplied arguments, unlocks the
    48 node. Returns 1 on successful writing, 0 if checksum doesn't match,
    49 croaks on error.
     48node. Returns the version of the updated node on successful writing, 0 if
     49checksum doesn't match, croaks on error.
    5050
    5151Note:  Uses MySQL's user level locking, so any locks are released when
  • wiki-toolkit/trunk/lib/Wiki/Toolkit/Store/Pg.pm

    r431 r466  
    4646Locks the node, verifies the checksum, calls
    4747C<write_node_post_locking> with all supplied arguments, unlocks the
    48 node. Returns 1 on successful writing, 0 if checksum doesn't match,
    49 croaks on error.
     48node. Returns the version of the updated node on successful writing, 0 if
     49checksum doesn't match, croaks on error.
    5050
    5151=cut
  • wiki-toolkit/trunk/lib/Wiki/Toolkit/Store/SQLite.pm

    r431 r466  
    5757Locks the node, verifies the checksum, calls
    5858C<write_node_post_locking> with all supplied arguments, unlocks the
    59 node. Returns 1 on successful writing, 0 if checksum doesn't match,
    60 croaks on error.
     59node. Returns the version of the updated node on successful writing, 0 if
     60checksum doesn't match, croaks on error.
    6161
    6262=cut
  • wiki-toolkit/trunk/t/021_moderation.t

    r366 r466  
    77    plan skip_all => "no backends configured";
    88} else {
    9     plan tests => ( 86 * scalar @Wiki::Toolkit::TestLib::wiki_info );
     9    plan tests => ( 89 * scalar @Wiki::Toolkit::TestLib::wiki_info );
    1010}
    1111
     
    6262
    6363        # Update it
    64     ok( $wiki->write_node("Moderation", "yy", $mn_data{checksum}),
    65                 "Can update where moderation is enabled" );
     64    my $nmn_ver = $wiki->write_node("Moderation", "yy", $mn_data{checksum});
     65    ok( $nmn_ver, "Can update where moderation is enabled" );
    6666    my %nmn_data = $wiki->retrieve_node("Moderation");
    6767    my %nmnv_data = $wiki->retrieve_node(name=>"Moderation", version=>2);
     68    is( $nmn_data{version}, '1', "Latest moderated version" );
     69    is( $nmnv_data{version}, '2', "Latest unmoderated version" );
     70    is( $nmn_ver, '2', "Latest (unmoderated) version returned by write_node" );
    6871
    6972        # Check content was updated right
Note: See TracChangeset for help on using the changeset viewer.