Changeset 12543
- Timestamp:
- 09/18/11 11:45:57 (20 months ago)
- Location:
- branches/scratch/core/lib
- Files:
-
- 10 edited
-
Foswiki.pm (modified) (4 diffs)
-
Foswiki/Access/TopicACLAccess.pm (modified) (3 diffs)
-
Foswiki/Address.pm (modified) (4 diffs)
-
Foswiki/Meta.pm (modified) (51 diffs)
-
Foswiki/Prefs.pm (modified) (6 diffs)
-
Foswiki/Serialise/Embedded.pm (modified) (5 diffs)
-
Foswiki/Store.pm (modified) (8 diffs)
-
Foswiki/Store/VC/Handler.pm (modified) (1 diff)
-
Foswiki/Store/VC/Store.pm (modified) (20 diffs)
-
Foswiki/UI/Register.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/scratch/core/lib/Foswiki.pm
r12540 r12543 1892 1892 #Monitor::MARK("Loaded default prefs"); 1893 1893 1894 #pre-cache the admin user membership before we foswiki-setuid to session user 1895 $this->{users}->eachGroupMember($Foswiki::cfg{SuperAdminGroup}); 1896 1894 1897 # SMELL: what happens if we move this into the Foswiki::Users::new? 1895 1898 $this->{user} = $this->{users}->initialiseUser( $this->{remoteUser} ); 1896 $this-> store->changeDefaultUser($this->{user});1899 $this->{store}->changeDefaultUser($this->{user}); 1897 1900 1898 1901 #Monitor::MARK("Initialised user"); … … 3692 3695 3693 3696 ASSERT( UNTAINTED($web), 'web is tainted' ) if DEBUG; 3694 return $this->{store}-> webExists($web);3697 return $this->{store}->exists( address=>{web=>$web}); 3695 3698 } 3696 3699 … … 3709 3712 ASSERT( UNTAINTED($web), 'web is tainted' ) if DEBUG; 3710 3713 ASSERT( UNTAINTED($topic), 'topic is tainted' ) if DEBUG; 3711 return $this->{store}-> topicExists( $web, $topic);3714 return $this->{store}->exists( address=>{web=>$web, topic=>$topic}); 3712 3715 } 3713 3716 … … 3754 3757 Foswiki - The Free and Open Source Wiki, http://foswiki.org/ 3755 3758 3756 Copyright (C) 2008-201 0Foswiki Contributors. Foswiki Contributors3759 Copyright (C) 2008-2011 Foswiki Contributors. Foswiki Contributors 3757 3760 are listed in the AUTHORS file in the root of this distribution. 3758 3761 NOTE: Please extend that file, not this notice. -
branches/scratch/core/lib/Foswiki/Access/TopicACLAccess.pm
r12153 r12543 28 28 ASSERT( $session->isa('Foswiki') ) if DEBUG; 29 29 my $this = bless( { session => $session }, $class ); 30 31 ASSERT(defined($this->{session})) if DEBUG; 30 32 31 33 return $this; … … 46 48 47 49 sub haveAccess { 50 if ($_[$#_-1] eq 'dontload') { 51 #print STDERR "-------------say its ok, even if its not $_[$#_-1] => $_[$#_]\n"; 52 return 1 ; 53 } 48 54 my ( $this, $mode, $cUID, $param1, $param2, $param3 ) = @_; 49 55 $mode ||= 'VIEW'; 50 56 $cUID ||= $this->{session}->{user}; 57 58 #print STDERR "cUID isa ".ref($cUID)."\n"; 59 ASSERT(ref($cUID) eq '') if DEBUG; 60 61 ASSERT(ref($this) eq 'Foswiki::Access::TopicACLAccess') if DEBUG; 62 ASSERT(defined($this->{session})) if DEBUG; 63 51 64 52 65 my $session = $this->{session}; … … 58 71 59 72 #scalar - treat as web, topic 60 $meta = Foswiki::Meta->load( $session, $param1, $param2 ); 73 $meta = Foswiki::Store::load(address=>{web=>$param1, topic=>$param2}); 74 61 75 ASSERT(not defined($param3)) if DEBUG; #attachment ACL not currently supported in traditional topic ACL 62 76 } 63 77 else { 64 78 if ( ref($param1) eq 'Foswiki::Address' ) { 65 $meta = 66 Foswiki::Meta->load( $session, $param1->web(), $param1->topic() ); 79 $meta = Foswiki::Store::load(address=>$param1); 67 80 } 68 81 else { -
branches/scratch/core/lib/Foswiki/Address.pm
r12542 r12543 70 70 #use Data::Dumper; 71 71 use constant TRACE => 0; # Don't forget to uncomment dumper 72 use constant TRACE2 => 0;72 use constant TRACE2 => 1; 73 73 74 74 my %atomiseAs = ( … … 252 252 253 253 sub new { 254 my ( $class, %opts ) = @_;254 my $class = shift; 255 255 my $this; 256 256 257 if (ref($_[0]) and $_[0]->isa('Foswiki::Address')) { 258 #print STDERR "COPY CONCTRUCTOR ($class, $_[0])\n"; 259 #need a copy construtor 260 #TODO: Paul - help? 261 $this = bless( { 262 webpath => $_[0]->{webpath}, 263 web => $_[0]->web(), 264 topic => $_[0]->{topic}, 265 tompath => $_[0]->{tompath}, 266 rev => $_[0]->{rev}, 267 }, $class ); 268 #$this->parse( $_[0]->{string} ); 269 return $this; 270 } 271 272 my %opts = @_; 273 257 274 if ( $opts{string} ) { 258 275 ASSERT( not $opts{topic} or ( $opts{webpath} and $opts{topic} ) ) … … 1004 1021 1005 1022 sub stringify { 1023 return getPath(@_); 1024 } 1025 1026 1027 sub getPath { 1006 1028 my ( $this, %opts ) = @_; 1007 1029 … … 1117 1139 my ( $this, $web ) = @_; 1118 1140 1119 ASSERT( $this->{web} or ref( $this->{webpath} ) eq 'ARRAY') if DEBUG;1120 if ( scalar(@_) == 2 ) {1141 ASSERT( scalar(@_) == 2 or (defined($this->{webpath}) and ref( $this->{webpath} ) eq 'ARRAY') ) if DEBUG; 1142 if ( scalar(@_) == 2 ) { 1121 1143 $this->webpath( [ split( /[\/\.]/, $web ) ] ); 1122 1144 } 1123 if ( not $this->{web} ) {1145 if ( not $this->{web} and defined($this->{webpath} )) { 1124 1146 $this->{web} = join( '/', @{ $this->{webpath} } ); 1125 1147 } 1126 1148 ASSERT($this->{web}) if DEBUG; 1127 1149 return $this->{web}; 1128 1150 } -
branches/scratch/core/lib/Foswiki/Meta.pm
r12542 r12543 345 345 =cut 346 346 347 sub new {347 sub OLDnew { 348 348 my ( $class, $session, $web, $topic, $text ) = @_; 349 349 die 'no'; 350 350 if ( $session->isa('Foswiki::Meta') ) { 351 351 #die 'ke'; 352 352 # Prototype 353 353 ASSERT( !defined($web) && !defined($topic) && !defined($text) ) … … 355 355 return $class->new( $session->session, $session->web, $session->topic ); 356 356 } 357 358 ASSERT(( caller(0) )[3] eq 'load') if DEBUG; 359 #die 'asdf'; 360 357 361 358 362 my $this = (ref($class) || $class)->SUPER::new( web=>$web, topic=>$topic ); … … 411 415 } 412 416 417 sub new { 418 my ( $class, $session, $web, $topic, $text ) = @_; 419 420 if ( $session->isa('Foswiki::Meta') ) { 421 #die 'ke'; 422 # Prototype 423 ASSERT( !defined($web) && !defined($topic) && !defined($text) ) 424 if DEBUG; 425 return $class->new( $session->session, $session->web, $session->topic ); 426 } 427 428 #ASSERT(( caller(0) )[3] eq 'load') if DEBUG; 429 #die 'asdf'; 430 431 432 #my $this = (ref($class) || $class)->SUPER::new( web=>$web, topic=>$topic ); 433 434 my $metaObject = Foswiki::Store::load(address=>{web=>$web, topic=>$topic}); 435 return $metaObject; 436 } 437 438 #should only be called by the store.. 439 sub NEWnew { 440 my $class = shift; 441 use Data::Dumper; 442 die Dumper(\@_) unless (defined($_[2])); 443 my %args = @_; 444 445 #copy the Foswiki::Address obj (which by this time it is :/) 446 my $this = (ref($class) || $class)->SUPER::new( $args{address} ); 447 #TODO: fix the Foswiki::Address constructor to allow inheritance 448 @{$this}{keys(%{$args{data}})} = values(%{$args{data}}) if (defined($args{data})); 449 450 #TODO: remove this. 451 $this->{_session} = $Foswiki::Plugins::SESSION; 452 # Index keyed on top level type mapping entry names to their 453 # index within the data array. 454 $this->{_indices} = undef; 455 $this->{FILEATTACHMENT} = []; 456 457 #die "-complete NEWnew --- = ".Dumper($this)."\n"; 458 459 return $this; 460 } 461 462 413 463 =begin TML 414 464 … … 548 598 #if its an intentional ref to an object, please add it to the undef's above. 549 599 550 #SMELL: Sven noticed during development that something is adding a $this->{store}to a meta obj - havn't found it yet600 #SMELL: Sven noticed during development that something is adding a Foswiki::Store to a meta obj - havn't found it yet 551 601 #ASSERT(not defined($this->{store})) if DEBUG; 552 602 … … 570 620 sub session { 571 621 return $_[0]->{_session}; 572 }573 574 =begin TML575 576 ---++ ObjectMethod web([$name])577 * =$name= - optional, change the web name in the object578 * *Since* 28 Nov 2008579 Get/set the web name associated with the object.580 581 =cut582 583 sub web {584 my ( $this, $web ) = @_;585 $this->{web} = $web if defined $web;586 return $this->{web};587 }588 589 =begin TML590 591 ---++ ObjectMethod topic([$name])592 * =$name= - optional, change the topic name in the object593 * *Since* 28 Nov 2008594 Get/set the topic name associated with the object.595 596 =cut597 598 sub topic {599 my ( $this, $topic ) = @_;600 $this->{topic} = $topic if defined $topic;601 return $this->{topic};602 622 } 603 623 … … 612 632 =cut 613 633 614 sub getPath {634 sub OLDgetPath { 615 635 my $this = shift; 616 636 my $path = $this->{web}; … … 708 728 $this->addDependency(); 709 729 710 return $this->{_session}->{store} 711 ->exists(address=>$this); 730 return Foswiki::Store->exists(address=>$this); 712 731 } 713 732 elsif ( defined $this->{web} ) { 714 return $this->{_session}->{store}->exists(address=> $this );733 return Foswiki::Store->exists(address=> $this ); 715 734 } 716 735 else { … … 821 840 # Validate that template web exists, or error should be thrown 822 841 if ($templateWeb) { 823 unless ( $session->exists(address=>$templateWeb) ) {842 unless ( Foswiki::Store->exists(address=>{web=>$templateWeb}) ) { 824 843 throw Error::Simple( 825 844 'Template web ' . $templateWeb . ' does not exist' ); … … 830 849 my $prefsTopicObject; 831 850 if ( 832 !$session->exists(address=>[ 833 $this->{web}, $Foswiki::cfg{WebPrefsTopicName} 834 ] 851 !Foswiki::Store->exists(address=>{web=> 852 $this->{web}, topic=>$Foswiki::cfg{WebPrefsTopicName} } 835 853 ) 836 854 ) 837 855 { 838 856 my $prefsText = 'Preferences'; 839 $prefsTopicObject = 840 $this->new( $this->{_session}, $this->{web}, 841 $Foswiki::cfg{WebPrefsTopicName}, $prefsText ); 857 $prefsTopicObject = Foswiki::Store::create(address=>{web=>$this->{web}, 858 topic=>$Foswiki::cfg{WebPrefsTopicName}}, data=>{_text=>$prefsText} ); 842 859 $prefsTopicObject->save(); 843 860 } … … 913 930 sub query { 914 931 my ( $query, $inputTopicSet, $options ) = @_; 915 return $Foswiki::Plugins::SESSION->{store} 916 ->query( $query, $inputTopicSet, $Foswiki::Plugins::SESSION, $options ); 932 return Foswiki::Store->query( $query, $inputTopicSet, $Foswiki::Plugins::SESSION, $options ); 917 933 } 918 934 … … 934 950 # Works on the root, so {web} may be undef 935 951 ASSERT( !$this->{topic}, 'this object may not contain webs' ) if DEBUG; 936 return $this->{_session}->{store}->eachWeb( $this,$all );952 return Foswiki::Store->eachWeb( address=>$this, all=>$all ); 937 953 938 954 } … … 956 972 return new Foswiki::ListIterator( [] ); 957 973 } 958 return $this->{_session}->{store}->eachTopic($this);974 return Foswiki::Store->eachTopic(address=>$this); 959 975 } 960 976 … … 976 992 ASSERT( $this->{web} && $this->{topic}, 'this is not a topic object' ) 977 993 if DEBUG; 978 return $this->{_session}->{store}->eachAttachment($this);994 return Foswiki::Store->eachAttachment(address=>$this); 979 995 } 980 996 … … 999 1015 ASSERT( $this->{web} && !$this->{topic}, 'this is not a web object' ) 1000 1016 if DEBUG; 1001 return $this->{_session}->{store}->eachChange( $this, $time);1017 return Foswiki::Store->eachChange( address=>$this, from=>$time, to=>time()); 1002 1018 } 1003 1019 1004 1020 ############# TOPIC METHODS ############# 1005 1021 1006 =begin TML1007 1008 ---++ ObjectMethod loadVersion($rev) -> $version1009 1010 Load the object from the store. The object must not be already loaded1011 with a different rev (verified by an ASSERT)1012 1013 See =getLoadedRev= to determine what revision is currently being viewed.1014 * =$rev= - revision to load. If undef, 0, '' or > max available rev, will1015 load the latest rev. If the revision is in range but does not exist,1016 then will return an unloaded meta object (getLoadedRev() will be undef)1017 1018 Returns the version identifier for the loaded revision. (and undef if it failed to load)1019 1020 WARNING: see notes on revision numbers under =getLoadedRev=1021 1022 =cut1023 1024 sub loadVersion {1025 my ( $this, $rev ) = @_;1026 1027 return unless $this->{topic};1028 1029 # If no specific rev was requested, check that the latest rev is1030 # loaded.1031 if ( !defined $rev || !$rev ) {1032 1033 # Trying to load the latest1034 if ( $this->{_latestIsLoaded} ) {1035 1036 #TODO: these asserts trip up Comment Plugin1037 #ASSERT(defined($this->{_loadedRev})) if DEBUG;1038 #ASSERT($rev == $this->{_loadedRev}) if DEBUG;1039 return;1040 }1041 ASSERT( not( $this->{_loadedRev} ) ) if DEBUG;1042 }1043 elsif ( defined( $this->{_loadedRev} ) ) {1044 1045 # Cannot load a different rev into an already-loaded1046 # Foswiki::Meta object1047 $rev = -1 unless defined $rev;1048 ASSERT( 0, "Attempt to reload $rev over version $this->{_loadedRev}" )1049 if DEBUG;1050 }1051 1052 # Is it already loaded?1053 ASSERT( !($rev) or $rev =~ /^\s*\d+\s*/ ) if DEBUG; # looks like a number1054 return $this->{_loadedRev}1055 if ( $rev && $this->{_loadedRev} && $rev == $this->{_loadedRev} );1056 1057 ASSERT( not( $this->{_loadedRev} ) ) if DEBUG;1058 1059 ( $this->{_loadedRev}, $this->{_latestIsLoaded} ) =1060 $this->{_session}->{store}->readTopic( $this, $rev );1061 if ( defined( $this->{_loadedRev} ) ) {1062 1063 # Make sure text always has a value once loadVersion has been called1064 # once.1065 $this->{_text} = '' unless defined $this->{_text};1066 1067 $this->addDependency();1068 }1069 else {1070 1071 #we didn't load, so how could it be latest?1072 ASSERT( not $this->{_latestIsLoaded} ) if DEBUG;1073 }1074 1075 return $this->{_loadedRev};1076 }1077 1022 1078 1023 =begin TML … … 1089 1034 sub text { 1090 1035 my ( $this, $val ) = @_; 1036 1091 1037 ASSERT( $this->{web} && $this->{topic}, 'this is not a topic object' ) 1092 1038 if DEBUG; 1093 1039 if ( defined($val) ) { 1094 1040 $this->{_text} = $val; 1095 }1096 else {1097 1098 # Lazy load. Reload with no params will reload the _loadedRev,1099 # or load the latest if that is not defined.1100 $this->loadVersion() unless defined( $this->{_text} );1101 1041 } 1102 1042 return $this->{_text}; … … 1261 1201 } 1262 1202 else { 1203 ASSERT(ref($data) eq 'ARRAY', $data) if DEBUG; 1263 1204 return $data->[0]; 1264 1205 } … … 1377 1318 return if $type =~ /^_/; 1378 1319 my @data; 1320 1321 #HACK. DELETE and replace with serialise only registered tpes? 1322 return unless (ref($other->{$type}) eq 'ARRAY'); #data from Foswiki::Address 1323 return if ($type eq 'webpath'); 1324 1325 1379 1326 foreach my $item ( @{ $other->{$type} } ) { 1380 1327 if ( !$filter … … 1507 1454 1508 1455 # Delegate to the store 1509 $info = $this->{_session}->{store}->getVersionInfo($this);1456 $info = Foswiki::Store->getVersionInfo(address=>$this); 1510 1457 1511 1458 # cache the result … … 1904 1851 my $newRev; 1905 1852 try { 1906 $newRev = $this-> saveAs( $this->{web}, $this->{topic},%opts );1853 $newRev = $this->__internal_save( %opts ); 1907 1854 } 1908 1855 catch Error::Simple with { … … 1937 1884 =begin TML 1938 1885 1939 ---++ ObjectMethod saveAs( $web, $topic,%options ) -> $rev1886 ---++ ObjectMethod __internal_save( %options ) -> $rev 1940 1887 1941 1888 Save the current topic to a store location. Only works on topics. 1942 1889 *without* invoking plugins handlers. 1943 * =$web.$topic= - where to move to1944 1890 * =%options= - Hash of options, may include: 1945 1891 * =forcenewrevision= - force an increment in the revision number, … … 1962 1908 # SMELL: arguably save should only be permitted if the loaded rev 1963 1909 # of the object is the same as the latest rev. 1964 sub saveAs{1910 sub __internal_save { 1965 1911 my $this = shift; 1966 1912 ASSERT( $this->{web} && $this->{topic}, 'this is not a topic object' ) 1967 1913 if DEBUG; 1968 1969 my $newWeb = shift;1970 my $newTopic = shift;1971 1914 ASSERT( scalar(@_) % 2 == 0 ) if DEBUG; 1972 1915 my %opts = @_; 1973 1916 my $cUID = $opts{author} || $this->{_session}->{user}; 1974 $this->{web} = $newWeb if $newWeb;1975 $this->{topic} = $newTopic if $newTopic;1976 1917 ASSERT( $this->{web} && $this->{topic}, 'this is not a topic object' ) 1977 1918 if DEBUG; … … 1981 1922 # Don't verify web existance for WebPreferences, as saving 1982 1923 # WebPreferences creates the web. 1983 unless ( $this->{_session}->{store}->exists(address=> $this->{web} )) {1924 unless ( Foswiki::Store->exists(address=> {web=> $this->web()} )) { 1984 1925 throw Error::Simple( 'Unable to save topic ' 1985 1926 . $this->{topic} … … 1991 1932 1992 1933 $this->_atomicLock($cUID); 1993 my $i = $this->{_session}->{store}->getRevisionHistory($this);1934 my $i = Foswiki::Store->getRevisionHistory(address=>$this); 1994 1935 my $currentRev = $i->hasNext() ? $i->next() : 1; 1995 1936 try { … … 1998 1939 # See if we want to replace the existing top revision 1999 1940 my $mtime1 = 2000 $this->{_session}->{store} 2001 ->getApproxRevTime( $this->{web}, $this->{topic} ); 1941 Foswiki::Store->getApproxRevTime( address=>$this ); 2002 1942 my $mtime2 = time(); 2003 1943 my $dt = abs( $mtime2 - $mtime1 ); 2004 1944 if ( $dt <= $Foswiki::cfg{ReplaceIfEditedAgainWithin} ) { 2005 my $info = $this->{_session}->{store}->getVersionInfo($this);1945 my $info = Foswiki::Store->getVersionInfo(address=>$this); 2006 1946 2007 1947 # same user? … … 2014 1954 $info->{date} = $opts{forcedate} || time(); 2015 1955 $this->setRevisionInfo(%$info); 2016 $this->{_session}->{store}->repRev( $this,$cUID, %opts );1956 Foswiki::Store->repRev( address=>$this, cuid=>$cUID, %opts ); 2017 1957 $this->{_loadedRev} = $currentRev; 2018 1958 return $currentRev; … … 2020 1960 } 2021 1961 } 2022 my $nextRev = $this->{_session}->{store}->getNextRevision($this);1962 my $nextRev = Foswiki::Store->getNextRevision(address=>$this); 2023 1963 $this->setRevisionInfo( 2024 1964 date => $opts{forcedate} || time(), … … 2028 1968 2029 1969 my $checkSave = 2030 $this->{_session}->{store}->saveTopic( $this, $cUID, \%opts );1970 Foswiki::Store->save( address=>$this, cuid=>$cUID, %opts ); 2031 1971 ASSERT( $checkSave == $nextRev, "$checkSave != $nextRev" ) if DEBUG; 2032 1972 $this->{_loadedRev} = $nextRev; … … 2057 1997 while (1) { 2058 1998 my ( $user, $time ) = 2059 $this->{_session}->{store}->atomicLockInfo($this);1999 Foswiki::Store->atomicLockInfo(address=>$this); 2060 2000 last if ( !$user || $cUID eq $user ); 2061 2001 $logger->log( 'warning', … … 2071 2011 $logger->log( 'warning', 2072 2012 $cUID . " broke ${user}s lock on " . $this->getPath() ); 2073 $this->{_session}->{store}->atomicUnlock( $this,$cUID );2013 Foswiki::Store->atomicUnlock( address=>$this, cuid=>$cUID ); 2074 2014 last; 2075 2015 } … … 2080 2020 2081 2021 # Topic 2082 $this->{_session}->{store}->atomicLock( $this,$cUID );2022 Foswiki::Store->atomicLock( address=>$this, cuid=>$cUID ); 2083 2023 } 2084 2024 else { … … 2103 2043 my ( $this, $cUID ) = @_; 2104 2044 if ( $this->{topic} ) { 2105 $this->{_session}->{store}->atomicUnlock($this);2045 Foswiki::Store->atomicUnlock(address=>$this); 2106 2046 } 2107 2047 else { … … 2176 2116 dontlog => 1, # no statistics 2177 2117 ); 2178 $from->{_session}->{store}->moveTopic( $from, $to,$cUID );2118 Foswiki::Store->moveTopic( from=>$from, address=>$to, cuid=>$cUID ); 2179 2119 $to->loadVersion(); 2180 2120 ASSERT( defined($to) and defined( $to->{_loadedRev} ) ) if DEBUG; … … 2191 2131 2192 2132 # Move web 2193 ASSERT( ! $this->{_session}->{store}->exists(address=> $to ),2133 ASSERT( !Foswiki::Store->exists(address=> $to ), 2194 2134 "$to->{web} does not exist" ) 2195 2135 if DEBUG; 2196 2136 $this->_atomicLock($cUID); 2197 $this->{_session}->{store}->moveWeb( $this, $to,$cUID );2137 Foswiki::Store->moveWeb( from=>$this, address=>$to, cuid=>$cUID ); 2198 2138 2199 2139 # No point in unlocking $this - it's moved! … … 2232 2172 $this->_atomicLock($cUID); 2233 2173 try { 2234 $rev = $this->{_session}->{store}->delRev( $this,$cUID );2174 $rev = Foswiki::Store->delRev( address=>$this, cuid=>$cUID ); 2235 2175 } 2236 2176 finally { … … 2295 2235 2296 2236 try { 2297 $this->{_session}->{store}->repRev( $this,$cUID, @_ );2237 Foswiki::Store->repRev( address=>$this, cuid=>$cUID, @_ ); 2298 2238 } 2299 2239 finally { … … 2339 2279 # } 2340 2280 2341 return $this->{_session}->{store}->getRevisionHistory( $this,$attachment );2281 return Foswiki::Store->getRevisionHistory( address=>$this, attachment=>$attachment ); 2342 2282 } 2343 2283 … … 2421 2361 sub removeFromStore { 2422 2362 my ( $this, $attachment ) = @_; 2423 my $store = $this->{_session}->{store};2363 2424 2364 ASSERT( $this->{web}, 'this is not a removable object' ) if DEBUG; 2425 2365 2426 if ( ! $store->exists(address=> $this->{web} )) {2366 if ( !Foswiki::Store->exists(address=> {web=>$this->{web}} )) { 2427 2367 throw Error::Simple( 'No such web ' . $this->{web} ); 2428 2368 } 2429 2369 if ( $this->{topic} 2430 && ! $store->exists(address=>[ $this->{web}, $this->{topic} ]))2370 && !Foswiki::Store->exists(address=>$this )) 2431 2371 { 2432 2372 throw Error::Simple( … … 2442 2382 } 2443 2383 2444 $store->remove( $this->{_session}->{user}, $this,$attachment );2384 Foswiki::Store->remove( address=>$this, attachment=>$attachment ); 2445 2385 } 2446 2386 … … 2468 2408 ASSERT( $this->{web} && $this->{topic}, 'this is not a topic object' ) 2469 2409 if DEBUG; 2470 return $this->{_session}->{store} 2471 ->getRevisionDiff( $this, $rev2, $contextLines ); 2410 return Foswiki::Store->getRevisionDiff( from=>$this, address=>$rev2, contextLines=>$contextLines ); 2472 2411 } 2473 2412 … … 2487 2426 ASSERT( $this->{web} && $this->{topic}, 'this is not a topic object' ) 2488 2427 if DEBUG; 2489 return $this->{_session}->{store}->getRevisionAtTime( $this,$time );2428 return Foswiki::Store->getRevisionAtTime( address=>$this, time=>$time ); 2490 2429 } 2491 2430 … … 2510 2449 taken => $t 2511 2450 }; 2512 return $this->{_session}->{store}->setLease( $this,$lease );2451 return Foswiki::Store->setLease( address=>$this, length=>$lease ); 2513 2452 } 2514 2453 … … 2530 2469 ASSERT( $this->{web} && $this->{topic}, 'this is not a topic object' ) 2531 2470 if DEBUG; 2532 return $this->{_session}->{store}->getLease($this);2471 return Foswiki::Store->getLease(address=>$this); 2533 2472 } 2534 2473 … … 2551 2490 . ' this is not a topic object' 2552 2491 ) if DEBUG; 2553 $this->{_session}->{store}->setLease($this);2492 Foswiki::Store->setLease(address=>$this); 2554 2493 } 2555 2494 … … 2587 2526 # Clean up spurious leases that may have been left behind 2588 2527 # during cancelled topic creation 2589 $this->{_session}->{store}->removeSpuriousLeases( $this->getPath())2528 Foswiki::Store->removeSpuriousLeases( address=>$this ) 2590 2529 if $this->getPath(); 2591 2530 } … … 2616 2555 if DEBUG; 2617 2556 2618 return $this->{_session}->{store}2619 ->getAttachmentVersionInfo( $this, $fromrev,$attachment );2557 return Foswiki::Store 2558 ->getAttachmentVersionInfo( address=>$this, rev=>$fromrev, attachment=>$attachment ); 2620 2559 } 2621 2560 … … 2768 2707 my $error; 2769 2708 try { 2770 $this->{_session}->{store}2771 ->saveAttachment( $this, $opts{name},$opts{stream},2772 $opts{author} || $this->{_session}->{user}, $opts{comment});2709 Foswiki::Store 2710 ->saveAttachment( address=>$this, attachment=>$opts{name}, stream=>$opts{stream}, 2711 cuid=>($opts{author} || $this->{_session}->{user}) ); 2773 2712 } 2774 2713 finally { … … 2839 2778 ASSERT( $this->{web} && $this->{topic}, 'this is not a topic object' ) 2840 2779 if DEBUG; 2841 return $this->{_session}->{store}->attachmentExists( $this,$name );2780 return Foswiki::Store->attachmentExists( address=>$this, attachment=>$name ); 2842 2781 } 2843 2782 … … 2891 2830 2892 2831 return 2893 return $this->{_session}->{store}2894 ->testAttachment( $this, $attachment,$test );2832 return Foswiki::Store 2833 ->testAttachment( address=>$this, attachment=>$attachment, test=>$test ); 2895 2834 } 2896 2835 … … 2924 2863 if DEBUG; 2925 2864 2926 return $this->{_session}->{store}2927 ->openAttachment( $this, $attachment,$mode, @opts );2865 return Foswiki::Store 2866 ->openAttachment( address=>$this, attachment=>$attachment, mode=>$mode, @opts ); 2928 2867 2929 2868 } … … 2958 2897 2959 2898 try { 2960 $this->{_session}->{store}2961 ->moveAttachment( $this, $name, $to, $newName,$cUID );2899 Foswiki::Store 2900 ->moveAttachment( from=>$this, fromattachment=>$name, address=>$to, toattachment=>$newName, cuid=>$cUID ); 2962 2901 2963 2902 # Modify the cache of the old topic … … 3048 2987 3049 2988 try { 3050 $from->{_session}->{store}3051 ->copyAttachment( $from, $name, $to, $newName,$cUID );2989 Foswiki::Store 2990 ->copyAttachment( from=>$from, fromattachment=>$name, address=>$to, toattachment=>$newName, cuid=>$cUID ); 3052 2991 3053 2992 # Add file attachment to new topic by copying the old one -
branches/scratch/core/lib/Foswiki/Prefs.pm
r12404 r12543 137 137 my $this = shift; 138 138 139 my $metaObject = Foswiki::Meta->new( $this->{session}, @_ ); 139 return undef unless (Foswiki::Store::exists(address=>{web=>$_[0], topic=>$_[1]})); 140 my $metaObject = Foswiki::Store::load(address=>{web=>$_[0], topic=>$_[1]}); 140 141 my $path = $metaObject->getPath(); 141 142 unless ( exists $this->{paths}{$path} ) { … … 160 161 $subWeb .= $_; 161 162 $back = $this->_getBackend( $subWeb, $Foswiki::cfg{WebPrefsTopicName} ); 162 $stack->newLevel($back) ;163 $stack->newLevel($back) if (defined($back)); 163 164 } 164 165 } … … 220 221 my ( $this, $topicObject ) = @_; 221 222 222 my $path = $topicObject->getPath(); 223 223 #my $path = $topicObject->getPath(); 224 224 # $topicObject->session->logger->log( 'debug', 225 225 # "Loading preferences for $path\n" ) … … 275 275 $subWeb .= $_; 276 276 $back = $this->_getBackend( $subWeb, $Foswiki::cfg{WebPrefsTopicName} ); 277 $stack->newLevel($back) ;277 $stack->newLevel($back) if (defined($back)); 278 278 } 279 279 $back = $this->_getBackend( $web, $topic ); 280 $stack->newLevel($back) ;280 $stack->newLevel($back) if (defined($back)); 281 281 $stack->newLevel( Foswiki::Prefs::HASH->new() ); 282 282 … … 343 343 my ( $this, $wn ) = @_; 344 344 my $back = $this->_getBackend( $Foswiki::cfg{UsersWebName}, $wn ); 345 $this->{main}->newLevel($back) ;345 $this->{main}->newLevel($back) if (defined($back)); 346 346 } 347 347 … … 375 375 ->normalizeWebTopicName( undef, $Foswiki::cfg{LocalSitePreferences} ); 376 376 my $back = $this->_getBackend( $web, $topic ); 377 $this->{main}->newLevel($back) ;377 $this->{main}->newLevel($back) if (defined($back)); 378 378 } 379 379 } -
branches/scratch/core/lib/Foswiki/Serialise/Embedded.pm
r12339 r12543 19 19 use Assert; 20 20 21 #debug! 22 use Data::Dumper; 23 21 24 =begin TML 22 25 … … 41 44 #really awkward - setEmbeddedStoreForm interleaves reading from text and calling Meta calls to update cache information 42 45 #need to separate these out in a performant way. 43 sub read { 44 die 'not implemented'; 46 sub DELETEMEread { 45 47 my $module = shift; 46 48 my ( $session, $result ) = @_; 47 49 48 ASSERT( $result->isa('Foswiki::Meta') ) if DEBUG; 49 return setEmbeddedStoreForm($result); 50 my @elements = split(/^(%META:.*)%\n/, $result); 51 52 print STDERR "-elements --- = ".Dumper(@elements)."\n"; 53 54 55 #split(/(\%META:.*\%\n)/, $result); 56 my %output; 57 foreach my $element (@elements) { 58 #1.0 compatibility 59 #$text =~ s/^%META:([^{]+){(.*)}%\n/ ..... /gem 60 #$text =~ s/^(%META:([^{]+){(.*)}%\n)/ ..... /gem 61 62 #if ($element =~ /%META:([A..Z0..9]*)({.*})%/ ) { 63 if ($element =~ /^%META/ ) { 64 #TODO: find the marco parsing code? 65 print STDERR "Meta $1 - params $2\n" 66 } else { 67 print STDERR "text - $element\n"; 68 ASSERT(not defined($output{text})) if DEBUG; 69 $output{text} = $element; 70 } 71 } 72 print STDERR "-complete --- = ".Dumper(%output)."\n"; 73 die; 74 return \%output; 75 } 76 sub read { 77 my $module = shift; 78 my ( $session, $result ) = @_; 79 80 my %output; 81 $result =~ s/^%META:([^{]+){(.*)}%\n/push(@{$output{$1}}, _readKeyValues($2));''/gem; 82 83 #correct the META for which there can be only one. (ignore all but first) 84 map { 85 $output{$_} = $output{$_}[0] if (defined($output{$_})); 86 } qw(TOPICINFO TOPICPARENT TOPICMOVED); 87 88 $output{_text} = $result; 89 90 #die "-complete --- = ".Dumper(\%output)."\n"; 91 92 return \%output; 50 93 } 51 94 … … 71 114 my $this = shift; 72 115 73 ASSERT( $this->{ _web} && $this->{_topic}, 'this is not a topic object' )116 ASSERT( $this->{web} && $this->{topic}, 'this is not a topic object' ) 74 117 if DEBUG; 75 118 $this->{_text} ||= ''; … … 130 173 my $data = $this->{$type}; 131 174 next if !defined $data; 175 176 #HACK. DELETE and replace with serialise only registered tpes? 177 next unless (ref($data) eq 'ARRAY'); #data from Foswiki::Address 178 next if ($type eq 'webpath'); 179 132 180 foreach my $item (@$data) { 133 181 next if ($item =~ /^_/ ); … … 180 228 } 181 229 230 =begin TML 231 232 ---++ StaticMethod dataDecode( $encoded ) -> $decoded 233 234 Decode escapes in a string that was encoded using dataEncode 235 236 The encoding has to be exported because Foswiki (and plugins) use 237 encoded field data in other places e.g. RDiff, mainly as a shorthand 238 for the properly parsed meta object. Some day we may be able to 239 eliminate that.... 240 241 =cut 242 243 sub dataDecode { 244 my $datum = shift; 245 246 $datum =~ s/%([\da-f]{2})/chr(hex($1))/gei; 247 return $datum; 248 } 249 250 251 # STATIC Build a hash by parsing name=value comma separated pairs 252 # SMELL: duplication of Foswiki::Attrs, using a different 253 # system of escapes :-( 254 sub _readKeyValues { 255 my ($args) = @_; 256 my %res; 257 258 # Format of data is name='value' name1='value1' [...] 259 $args =~ s/\s*([^=]+)="([^"]*)"/ 260 $res{$1} = dataDecode( $2 ), ''/ge; 261 262 return \%res; 263 } 264 182 265 1; 183 266 __END__ -
branches/scratch/core/lib/Foswiki/Store.pm
r12541 r12543 74 74 75 75 sub changeDefaultUser { 76 $singleton->{cuid} = shift; 76 #pick the last param, so that we can be class or object called. 77 $singleton->{cuid} = $_[$#_]; 78 79 ASSERT(not defined($singleton->{cuid}) or ref($singleton->{cuid}) eq '') if DEBUG; 80 die 'snow '.ref($singleton->{cuid}) if (ref($singleton->{cuid}) ne ''); 81 77 82 ASSERT((not defined($singleton->{cuid})) 78 83 or … … 101 106 102 107 sub load { 103 return template_function( 'load', @_ ); 108 shift if ((ref($_[0]) eq 'Foswiki::Store') or ($_[0] eq 'Foswiki::Store')); 109 110 #default cuid from the singleton 111 my %args = ( cuid=>$singleton->{cuid}, @_ ); 112 $args{functionname} = 'load'; 113 114 #print STDERR ".cUID isa ".ref($args{cuid})." ($args{cuid}) - default (".ref($singleton->{cuid}).")\n"; 115 #ASSERT(not defined($args{cuid}) or ref($args{cuid}) eq '') if DEBUG; 116 #die 'here' if (ref($args{cuid}) ne ''); 117 118 my $access_type = $args{writeable} ? 'CHANGE' : 'VIEW'; 119 120 my $result; 121 $args{address} = $singleton->getResourceAddressOrCachedResource($args{address}); 122 die "recursion? - load(".$singleton->{count}{load}{$args{address}->getPath()}.") ".$args{address}->getPath() if ($singleton->{count}{load}{$args{address}->getPath()}++ > 10); 123 124 print STDERR "-call: load ".($args{address}->getPath())."\n"; 125 126 127 if (ref($args{address}) eq 'Foswiki::Meta') { 128 $result = $args{address}; 129 } else { 130 131 #see if we are _able_ to test permissions using just an unloaded topic, if not, fall through to load&then test 132 throw AccessException( $singleton->{access}->getReason() ) 133 if ( defined( $args{cuid} ) and 134 not ($singleton->{access} 135 ->haveAccess( $access_type, $args{cuid}, $args{address}, 136 dontload => 1 ) )); 137 138 # if ( defined( $args{from} ) ) { 139 # 140 # #load will throw exceptions if things go wrong 141 # $args{from} = load( address => $args{from} ) 142 # unless ( $args{from}->isa('Foswiki::Address') ); 143 # } 144 145 #$cfg::Foswiki{Stores} is an ordered list, managed by configure that prioritises the cache stores first. 146 foreach my $impl ( @{ $singleton->{stores} } ) { 147 148 #the impl is also able to throw exceptions - as there might be a store based permissions impl 149 if (not defined($impl->{impl})) { 150 eval "require ".$impl->{module}; 151 ASSERT( !$@, $@ ) if DEBUG; 152 $impl->{impl} = $Foswiki::cfg{Store}{Implementation}->new(); 153 } 154 #$impl->{impl} ||= $impl.'::new'( store => $impl ) || next; 155 $result = $impl->{impl}->load(%args); 156 last if ( defined($result) ); 157 } 158 if (ref($result) eq 'Foswiki::Meta') { 159 #ok, we have a resource object that actually exists in a store 160 $singleton->cacheResource(%args, return=>$result); 161 } 162 163 if ( not defined($result) and $args{create} ) { 164 $result = create(%args); 165 } 166 167 throw DoesNotExist(%args) 168 unless ( defined($result) ); 169 } 170 171 if (ref($result) eq 'Foswiki::Meta') { 172 #now to make sure we're allowed to give it to the user. 173 174 foreach my $impl ( @{ $singleton->{stores} } ) { 175 if (not defined($impl->{impl})) { 176 eval "require ".$impl->{module}; 177 ASSERT( !$@, $@ ) if DEBUG; 178 $impl->{impl} = $Foswiki::cfg{Store}{Implementation}->new(); 179 } 180 181 #a listener for load events. 182 #TODO: kill this and replace with call to logger, which stores can choose to consume! 183 $impl->{impl}->log( %args, return => $result ); 184 } 185 186 #can't do any better with the __current__ ACL impl, but there should be a call before the readData for real store-fastening 187 ASSERT(ref($args{cuid}) eq ''); 188 #print STDERR "..cUID isa ".ref($args{cuid})." ($args{cuid})\n"; 189 190 throw AccessException( $singleton->{access}->getReason() ) 191 if ( defined( $args{cuid} ) and 192 not ($singleton->{access} 193 ->haveAccess( $access_type, $args{cuid}, $result ) )); 194 } 195 196 $singleton->{count}{load}{$args{address}->getPath()}--; 197 198 return $result; 104 199 } 105 200 … … 117 212 118 213 returns an object of the appropriate type from the Foswiki::Object:: hieracy 119 120 TODO: note that most of the methods here will have the same codepath as load(),121 so it might be better to write it all as a switchboard..122 214 123 215 =cut … … 152 244 =pod 153 245 154 =head2 ClassMethod delete(address=>$address, cuid=>$cuid, -> success?246 =head2 ClassMethod remove(address=>$address, cuid=>$cuid, -> success? 155 247 * =address= - (required) Address - can be a specific revision, in which case it requests the store to =delRev= 156 248 * cuid=>$cuid (canonical user id) - if undefined, presume 'admin' (or no perms check) access … … 162 254 =cut 163 255 164 sub delete {165 return template_function( ' delete', @_ );256 sub remove { 257 return template_function( 'remove', @_ ); 166 258 } 167 259 … … 398 490 =pod 399 491 492 =head2 ClassMethod eachWeb( address=>$address) -> $iterator 493 494 Get an iterator over the list of all elements of type '$type' that are sub elements of the addressed one 495 496 =cut 497 498 sub eachWeb { 499 return template_function( 'eachWeb', @_ ); 500 } 501 502 =pod 503 504 =head2 ClassMethod eachTopic( address=>$address) -> $iterator 505 506 Get an iterator over the list of all elements of type '$type' that are sub elements of the addressed one 507 508 =cut 509 510 sub eachTopic { 511 return template_function( 'eachTopic', @_ ); 512 } 513 514 =pod 515 400 516 =head2 ClassMethod query($query, $inputTopicSet, $session, \%options) -> $outputTopicSet 401 517 … … 457 573 =pod 458 574 459 =head2 ClassMethod setLease( address=>$address, cuid=>$cuid, $length )575 =head2 ClassMethod setLease( address=>$address, cuid=>$cuid, length=>$length ) 460 576 461 577 * =$topicObject= - Foswiki::Meta topic object … … 493 609 sub template_function { 494 610 my $functionname = shift; 495 shift if ( ref($_[0]) eq 'Foswiki::Store');611 shift if ((ref($_[0]) eq 'Foswiki::Store') or ($_[0] eq 'Foswiki::Store')); 496 612 497 613 #default cuid from the singleton 498 614 my %args = ( cuid=>$singleton->{cuid}, @_ ); 499 615 $args{functionname} = $functionname; 500 501 #TODO: or can I delay this to the point where its not needed at all? 502 $args{address} = Foswiki::Address->new( $args{address} ) 503 if (ref($args{address}) eq ''); #justa string/scalar 504 $args{address} = Foswiki::Address->new( @{$args{address}} ) 505 if (ref($args{address}) eq 'ARRAY'); 616 617 #print STDERR ".cUID isa ".ref($args{cuid})." ($args{cuid}) - default (".ref($singleton->{cuid}).")\n"; 618 #ASSERT(not defined($args{cuid}) or ref($args{cuid}) eq '') if DEBUG; 619 #die 'here' if (ref($args{cuid}) ne ''); 620 506 621 my $access_type = $args{writeable} ? 'CHANGE' : 'VIEW'; 507 622 508 #see if we are _able_ to test permissions using just an unloaded topic, if not, fall through to load&then test 509 throw AccessException( store()->{access}->getReason() ) 510 if ( defined( $args{cuid} ) and 511 not (store()->{access} 512 ->haveAccess( $args{address}, $access_type, $args{cuid}, 513 dontload => 1 ) )); 514 515 if ( defined( $args{from} ) ) { 516 517 #load will throw exceptions if things go wrong 518 $args{from} = load( address => $args{from} ) 519 unless ( $args{from}->isa('Foswiki::Address') ); 623 my $result; 624 $args{address} = $singleton->getResourceAddressOrCachedResource($args{address}); 625 die "recursion? - $functionname(".$singleton->{count}{$functionname}{$args{address}->getPath()}.") ".$args{address}->getPath() if ($singleton->{count}{$functionname}{$args{address}->getPath()}++ > 10); 626 627 print STDERR "-call: $functionname: ".($args{address}->getPath())."\n"; 628 629 630 # if (ref($args{address}) eq 'Foswiki::Meta') { 631 # $result = $args{address}; 632 # } else 633 { 634 635 #see if we are _able_ to test permissions using just an unloaded topic, if not, fall through to load&then test 636 throw AccessException( $singleton->{access}->getReason() ) 637 if ( defined( $args{cuid} ) and 638 not ($singleton->{access} 639 ->haveAccess( $access_type, $args{cuid}, $args{address}, 640 dontload => 1 ) )); 641 642 # if ( defined( $args{from} ) ) { 643 # 644 # #load will throw exceptions if things go wrong 645 # $args{from} = load( address => $args{from} ) 646 # unless ( $args{from}->isa('Foswiki::Address') ); 647 # } 648 649 #$cfg::Foswiki{Stores} is an ordered list, managed by configure that prioritises the cache stores first. 650 foreach my $impl ( @{ $singleton->{stores} } ) { 651 652 #the impl is also able to throw exceptions - as there might be a store based permissions impl 653 if (not defined($impl->{impl})) { 654 eval "require ".$impl->{module}; 655 ASSERT( !$@, $@ ) if DEBUG; 656 $impl->{impl} = $Foswiki::cfg{Store}{Implementation}->new(); 657 } 658 #$impl->{impl} ||= $impl.'::new'( store => $impl ) || next; 659 $result = $impl->{impl}->$functionname(%args); 660 last if ( defined($result) ); 661 } 662 if ( 663 ($functionname eq 'exists') or 664 ($functionname eq 'atomicLockInfo') or 665 ($functionname eq 'atomicLock') 666 ) { 667 print STDERR "-$functionname => ".(defined($result)?$result:'undef')."\n"; 668 return $result ; 669 } 670 throw DoesNotExist(%args) 671 unless ( defined($result) ); 672 } 673 674 if (ref($result) eq 'Foswiki::Meta') { 675 #now to make sure we're allowed to give it to the user. 676 677 foreach my $impl ( @{ $singleton->{stores} } ) { 678 if (not defined($impl->{impl})) { 679 eval "require ".$impl->{module}; 680 ASSERT( !$@, $@ ) if DEBUG; 681 $impl->{impl} = $Foswiki::cfg{Store}{Implementation}->new(); 682 } 683 684 #a listener for load events. 685 #TODO: kill this and replace with call to logger, which stores can choose to consume! 686 $impl->{impl}->log( %args, return => $result ); 687 } 688 689 #can't do any better with the __current__ ACL impl, but there should be a call before the readData for real store-fastening 690 ASSERT(ref($args{cuid}) eq ''); 691 #print STDERR "..cUID isa ".ref($args{cuid})." ($args{cuid})\n"; 692 693 throw AccessException( $singleton->{access}->getReason() ) 694 if ( defined( $args{cuid} ) and 695 not ($singleton->{access} 696 ->haveAccess( $access_type, $args{cuid}, $result ) )); 520 697 } 521 698 522 #$cfg::Foswiki{Stores} is an ordered list, managed by configure that prioritises the cache stores first. 523 my $result; 524 foreach my $impl ( @{ $singleton->{stores} } ) { 525 526 #the impl is also able to throw exceptions - as there might be a store based permissions impl 527 if (not defined($impl->{impl})) { 528 eval "require ".$impl->{module}; 529 ASSERT( !$@, $@ ) if DEBUG; 530 $impl->{impl} = $Foswiki::cfg{Store}{Implementation}->new(); 531 } 532 #$impl->{impl} ||= $impl.'::new'( store => $impl ) || next; 533 $result = $impl->{impl}->$functionname(%args); 534 last if ( defined($result) ); 535 } 536 if ( not defined($result) and $args{create} ) { 537 $result = create(%args); 538 } 539 throw DoesNotExist() 540 unless ( defined($result) ); 541 542 foreach my $impl ( @{ $singleton->{stores} } ) { 543 if (not defined($impl->{impl})) { 544 eval "require ".$impl->{module}; 545 ASSERT( !$@, $@ ) if DEBUG; 546 $impl->{impl} = $Foswiki::cfg{Store}{Implementation}->new(); 547 } 548 549 #a listener for load events. 550 #TODO: kill this and replace with call to logger, which stores can choose to consume! 551 $impl->{impl}->log( %args, return => $result ); 552 } 553 554 #can't do any better with the __current__ ACL impl, but there should be a call before the readData for real store-fastening 555 throw AccessException( store()->{access}->getReason() ) 556 if ( defined( $args{cuid} ) and 557 not (store()->{access} 558 ->haveAccess( $args{address}, $access_type, $args{cuid} ) )); 699 700 $singleton->{count}{$functionname}{$args{address}->getPath()}--; 701 559 702 return $result; 560 703 } 704 705 sub cacheResource { 706 my $self = shift; 707 my %args = @_; 708 709 #ASSERT(defined($obj->{_text})) if DEBUG; if itsa topic. 710 print STDERR "cacheResource(".$args{functionname}.", ".$args{return}->getPath().") \n"; 711 712 return unless ($args{functionname} eq 'load'); 713 714 my $name = $args{return}->getPath(); 715 $self->{cache}{$name} = $args{return}; 716 } 717 718 sub getResourceAddressOrCachedResource { 719 my $self = shift; 720 my $address = shift; 721 722 $address = Foswiki::Address->new( string=>$address ) 723 if (ref($address) eq ''); #justa string/scalar 724 $address = Foswiki::Address->new( @$address ) 725 if (ref($address) eq 'ARRAY'); 726 $address = Foswiki::Address->new( %$address ) 727 if (ref($address) eq 'HASH'); 728 729 730 my $name = $address->getPath(); 731 return $self->{cache}{$name} if (defined($self->{cache}{$name})); 732 return $address; 733 } 734 735 sub finish { 736 undef $singleton->{cache}; 737 undef $singleton; 738 print STDERR "--------------------------------- end Store singleton\n"; 739 } 740 561 741 562 742 1; -
branches/scratch/core/lib/Foswiki/Store/VC/Handler.pm
r12542 r12543 57 57 ASSERT( $store->isa('Foswiki::Store::Interfaces::Store') ) if DEBUG; 58 58 59 if ( UNIVERSAL::isa( $web, 'Foswiki:: Meta' ) ) {59 if ( UNIVERSAL::isa( $web, 'Foswiki::Address' ) ) { 60 60 61 61 # $web refers to a meta object -
branches/scratch/core/lib/Foswiki/Store/VC/Store.pm
r12542 r12543 43 43 use Foswiki::Meta (); 44 44 use Foswiki::Sandbox (); 45 use Foswiki::Serialise(); 45 46 46 47 BEGIN { … … 73 74 sub getHandler { 74 75 75 #my ( $this, $web, $topic, $a ttachment) = @_;76 #my ( $this, $web, $topic, $args{attachment} ) = @_; 76 77 ASSERT( 0, "Must be implemented by subclasses" ) if DEBUG; 77 78 } 78 79 79 80 sub readTopic { 80 my ( $this, $topicObject, $version) = @_;81 82 my ( $gotRev, $isLatest ) = $this->askListeners($ topicObject, $version);81 my ( $this, %args ) = @_; 82 83 my ( $gotRev, $isLatest ) = $this->askListeners($args{address}, $args{rev}); 83 84 84 85 if ( defined($gotRev) and ( $gotRev > 0 or ($isLatest)) ) { … … 87 88 ASSERT( not $isLatest ) if DEBUG; 88 89 89 my $handler = $this->getHandler($ topicObject);90 my $handler = $this->getHandler($args{address}); 90 91 $isLatest = 0; 91 92 92 93 # check that the requested revision actually exists 93 if ( defined $ version) {94 if ( !$ version || !$handler->revisionExists($version) ) {95 $ version= $handler->getLatestRevisionID();94 if ( defined $args{rev} ) { 95 if ( !$args{rev} || !$handler->revisionExists($args{rev}) ) { 96 $args{rev} = $handler->getLatestRevisionID(); 96 97 } 97 98 } 98 99 99 ( my $text, $isLatest ) = $handler->getRevision($ version);100 ( my $text, $isLatest ) = $handler->getRevision($args{rev}); 100 101 unless ( defined $text ) { 101 102 ASSERT( not $isLatest ) if DEBUG; … … 104 105 105 106 $text =~ s/\r//g; # Remove carriage returns 106 $ topicObject->setEmbeddedStoreForm($text);107 $args{address}->setEmbeddedStoreForm($text); 107 108 108 109 unless ($handler->noCheckinPending()) { 109 110 # If a checkin is pending, fix the TOPICINFO 110 my $ri = $ topicObject->get('TOPICINFO');111 my $ri = $args{address}->get('TOPICINFO'); 111 112 my $truth = $handler->getInfo($version); 112 113 for my $i qw(author version date) { … … 132 133 # Only check the currently requested topic. 133 134 if ( $Foswiki::cfg{RCS}{AutoAttachPubFiles} 134 && $ topicObject->isSessionTopic() )135 && $args{address}->isSessionTopic() ) 135 136 { 136 my @knownAttachments = $ topicObject->find('FILEATTACHMENT');137 my @knownAttachments = $args{address}->find('FILEATTACHMENT'); 137 138 my @attachmentsFoundInPub = 138 139 $handler->synchroniseAttachmentsList( \@knownAttachments ); … … 150 151 print STDERR 'AutoAttachPubFiles ignoring ' 151 152 . $foundAttachment->{name} . ' in ' 152 . $ topicObject->getPath()153 . $args{address}->getPath() 153 154 . ' - not a valid Foswiki Attachment filename'; 154 155 } … … 157 158 $this->tellListeners( 158 159 verb => 'autoattach', 159 newmeta => $ topicObject,160 newmeta => $args{address}, 160 161 newattachment => $foundAttachment 161 162 ); … … 163 164 } 164 165 165 $ topicObject->putAll( 'FILEATTACHMENT', @validAttachmentsFound )166 $args{address}->putAll( 'FILEATTACHMENT', @validAttachmentsFound ) 166 167 if @validAttachmentsFound; 167 168 } … … 172 173 173 174 sub moveAttachment { 174 my ( $this, $oldTopicObject, $oldAttachment, $newTopicObject, 175 $newAttachment, $cUID ) 175 my ( $this, %args ) 176 176 = @_; 177 177 178 my $handler = $this->getHandler( $ oldTopicObject, $oldAttachment);178 my $handler = $this->getHandler( $args{from}, $args{fromattachment} ); 179 179 if ( $handler->storedDataExists() ) { 180 $handler->moveAttachment( $this, $ newTopicObject->web,181 $ newTopicObject->topic, $newAttachment);180 $handler->moveAttachment( $this, $args{address}->web, 181 $args{address}->topic, $args{attachment} ); 182 182 $this->tellListeners( 183 183 verb => 'update', 184 oldmeta => $ oldTopicObject,185 oldattachment => $ oldAttachment,186 newmeta => $ newTopicObject,187 newattachment => $ newAttachment184 oldmeta => $args{from}, 185 oldattachment => $args{fromattachment}, 186 newmeta => $args{address}, 187 newattachment => $args{attachment} 188 188 ); 189 $handler->recordChange( $ cUID, 0 );189 $handler->recordChange( $args{cuid}, 0 ); 190 190 } 191 191 } 192 192 193 193 sub copyAttachment { 194 my ( $this, $oldTopicObject, $oldAttachment, $newTopicObject, 195 $newAttachment, $cUID ) 194 my ( $this, %args ) 196 195 = @_; 197 196 198 my $handler = $this->getHandler( $ oldTopicObject, $oldAttachment);197 my $handler = $this->getHandler( $args{from}, $args{fromattachment} ); 199 198 if ( $handler->storedDataExists() ) { 200 $handler->copyAttachment( $this, $ newTopicObject->web,201 $ newTopicObject->topic, $newAttachment);199 $handler->copyAttachment( $this, $args{address}->web, 200 $args{address}->topic, $args{attachment} ); 202 201 $this->tellListeners( 203 202 verb => 'insert', 204 newmeta => $ newTopicObject,205 newattachment => $ newAttachment203 newmeta => $args{address}, 204 newattachment => $args{attachment} 206 205 ); 207 $handler->recordChange( $ cUID, 0 );206 $handler->recordChange( $args{cuid}, 0 ); 208 207 } 209 208 } 210 209 211 210 sub attachmentExists { 212 my ( $this, $topicObject, $att) = @_;213 my $handler = $this->getHandler( $ topicObject, $att);211 my ( $this, %args ) = @_; 212 my $handler = $this->getHandler( $args{address}, $args{attachment} ); 214 213 return $handler->storedDataExists(); 215 214 } 216 215 217 216 sub moveTopic { 218 my ( $this, $oldTopicObject, $newTopicObject, $cUID) = @_;219 ASSERT($ cUID) if DEBUG;220 221 my $handler = $this->getHandler( $ oldTopicObject, '' );222 my $rev= $handler->getLatestRevisionID();223 224 $handler->moveTopic( $this, $ newTopicObject->web, $newTopicObject->topic );217 my ( $this, %args ) = @_; 218 ASSERT($args{cuid}) if DEBUG; 219 220 my $handler = $this->getHandler( $args{from}, '' ); 221 $args{rev} = $handler->getLatestRevisionID(); 222 223 $handler->moveTopic( $this, $args{address}->web, $args{address}->topic ); 225 224 226 225 $this->tellListeners( 227 226 verb => 'update', 228 oldmeta => $ oldTopicObject,229 newmeta => $ newTopicObject227 oldmeta => $args{from}, 228 newmeta => $args{address} 230 229 ); 231 230 232 if ( $ newTopicObject->web ne $oldTopicObject->web ) {231 if ( $args{address}->web ne $args{from}->web ) { 233 232 234 233 # Record that it was moved away 235 $handler->recordChange( $ cUID, $rev);236 } 237 238 $handler = $this->getHandler( $ newTopicObject, '' );239 $handler->recordChange( $ cUID, $rev);234 $handler->recordChange( $args{cuid}, $args{rev} ); 235 } 236 237 $handler = $this->getHandler( $args{address}, '' ); 238 $handler->recordChange( $args{cuid}, $args{rev} ); 240 239 } 241 240 242 241 sub moveWeb { 243 my ( $this, $oldWebObject, $newWebObject, $cUID) = @_;244 ASSERT($ cUID) if DEBUG;245 246 my $handler = $this->getHandler($ oldWebObject);247 $handler->moveWeb( $ newWebObject->web );242 my ( $this, %args ) = @_; 243 ASSERT($args{cuid}) if DEBUG; 244 245 my $handler = $this->getHandler($args{from}); 246 $handler->moveWeb( $args{address}->web ); 248 247 249 248 $this->tellListeners( 250 249 verb => 'update', 251 oldmeta => $ oldWebObject,252 newmeta => $ newWebObject250 oldmeta => $args{from}, 251 newmeta => $args{address} 253 252 ); 254 253 255 254 # We have to log in the new web, otherwise we would re-create the dir with 256 255 # a useless .changes. See Item9278 257 $handler = $this->getHandler($ newWebObject);258 $handler->recordChange( $ cUID, 0, 'Moved from ' . $oldWebObject->web );256 $handler = $this->getHandler($args{address}); 257 $handler->recordChange( $args{cuid}, 0, 'Moved from ' . $args{from}->web ); 259 258 } 260 259 261 260 sub testAttachment { 262 my ( $this, $topicObject, $attachment, $test) = @_;263 my $handler = $this->getHandler( $ topicObject, $attachment);264 return $handler->test($ test);261 my ( $this, %args ) = @_; 262 my $handler = $this->getHandler( $args{address}, $args{attachment} ); 263 return $handler->test($args{test}); 265 264 } 266 265 267 266 sub openAttachment { 268 my ( $this, $topicObject, $att, $mode, @opts ) = @_;269 270 my $handler = $this->getHandler( $ topicObject, $att);271 return $handler->openStream( $ mode, @opts );267 my ( $this, %args ) = @_; 268 269 my $handler = $this->getHandler( $args{address}, $args{attachment} ); 270 return $handler->openStream( $args{mode}, %args ); 272 271 } 273 272 274 273 sub getRevisionHistory { 275 my ( $this, $topicObject, $attachment) = @_;276 277 my $itr = $this->askListenersRevisionHistory($ topicObject, $attachment);274 my ( $this, %args ) = @_; 275 276 my $itr = $this->askListenersRevisionHistory($args{address}, $args{attachment}); 278 277 279 278 if ( defined($itr) ) { … … 281 280 } 282 281 283 my $handler = $this->getHandler( $ topicObject, $attachment);282 my $handler = $this->getHandler( $args{address}, $args{attachment} ); 284 283 return $handler->getRevisionHistory(); 285 284 } 286 285 287 286 sub getNextRevision { 288 my ( $this, $topicObject) = @_;289 my $handler = $this->getHandler($ topicObject);287 my ( $this, %args ) = @_; 288 my $handler = $this->getHandler($args{address}); 290 289 return $handler->getNextRevisionID(); 291 290 } 292 291 293 292 sub getRevisionDiff { 294 my ( $this, $topicObject, $rev2, $contextLines ) = @_;295 ASSERT( defined($ contextLines) ) if DEBUG;296 297 my $rcs = $this->getHandler($ topicObject);298 return $rcs->revisionDiff( $ topicObject->getLoadedRev(), $rev2,299 $ contextLines);293 my ( $this, %args ) = @_; 294 ASSERT( defined($args{contextLines}) ) if DEBUG; 295 296 my $rcs = $this->getHandler($args{address}); 297 return $rcs->revisionDiff( $args{address}->getLoadedRev(), $args{rev}, 298 $args{contextLines} ); 300 299 } 301 300 302 301 sub getAttachmentVersionInfo { 303 my ( $this, $topicObject, $rev, $attachment) = @_;304 my $handler = $this->getHandler( $ topicObject, $attachment);305 return $handler->getInfo( $ rev|| 0 );302 my ( $this, %args ) = @_; 303 my $handler = $this->getHandler( $args{address}, $args{attachment} ); 304 return $handler->getInfo( $args{rev} || 0 ); 306 305 } 307 306 308 307 sub getVersionInfo { 309 my ( $this, $topicObject) = @_;310 my $handler = $this->getHandler($ topicObject);311 return $handler->getInfo( $ topicObject->getLoadedRev() );308 my ( $this, %args ) = @_; 309 my $handler = $this->getHandler($args{address}); 310 return $handler->getInfo( $args{address}->getLoadedRev() ); 312 311 } 313 312 314 313 sub saveAttachment { 315 my ( $this, $topicObject, $name, $stream, $cUID, $comment) = @_;316 my $handler = $this->getHandler( $ topicObject, $name);314 my ( $this, %args ) = @_; 315 my $handler = $this->getHandler( $args{address}, $args{name} ); 317 316 my $currentRev = $handler->getLatestRevisionID(); 318 317 my $nextRev = $currentRev + 1; 319 my $verb = ( $ topicObject->hasAttachment($name) ) ? 'update' : 'insert';320 $handler->addRevisionFromStream( $ stream, $comment, $cUID);318 my $verb = ( $args{address}->hasAttachment($args{name}) ) ? 'update' : 'insert'; 319 $handler->addRevisionFromStream( $args{stream}, 'save attachment', $args{cuid} ); 321 320 $this->tellListeners( 322 321 verb => $verb, 323 newmeta => $ topicObject,324 newattachment => $ name322 newmeta => $args{address}, 323 newattachment => $args{name} 325 324 ); 326 $handler->recordChange( $ cUID, $nextRev );325 $handler->recordChange( $args{cuid}, $nextRev ); 327 326 return $nextRev; 328 327 } 329 328 330 329 sub saveTopic { 331 my ( $this, $topicObject, $cUID, $options ) = @_;332 ASSERT( $ topicObject->isa('Foswiki::Meta') ) if DEBUG;333 ASSERT($ cUID) if DEBUG;334 335 my $handler = $this->getHandler($ topicObject);336 337 my $verb = ( $ topicObject->existsInStore() ) ? 'update' : 'insert';330 my ( $this, %args, $options ) = @_; 331 ASSERT( $args{address}->isa('Foswiki::Meta') ) if DEBUG; 332 ASSERT($args{cuid}) if DEBUG; 333 334 my $handler = $this->getHandler($args{address}); 335 336 my $verb = ( $args{address}->existsInStore() ) ? 'update' : 'insert'; 338 337 339 338 # just in case they are not sequential … … 343 342 $ti->{author} = $cUID; 344 343 345 $handler->addRevisionFromText( $ topicObject->getEmbeddedStoreForm(),346 'save topic', $ cUID, $options->{forcedate} );344 $handler->addRevisionFromText( $args{address}->getEmbeddedStoreForm(), 345 'save topic', $args{cuid}, $options->{forcedate} ); 347 346 348 347 my $extra = $options->{minor} ? 'minor' : ''; 349 $handler->recordChange( $ cUID, $nextRev, $extra );350 351 $this->tellListeners( verb => $verb, newmeta => $ topicObject);348 $handler->recordChange( $args{cuid}, $nextRev, $extra ); 349 350 $this->tellListeners( verb => $verb, newmeta => $args{address} ); 352 351 353 352 return $nextRev; … … 355 354 356 355 sub repRev { 357 my ( $this, $topicObject, $cUID, %options ) = @_; 358 ASSERT( $topicObject->isa('Foswiki::Meta') ) if DEBUG; 359 ASSERT($cUID) if DEBUG; 360 my $info = $topicObject->getRevisionInfo(); 361 my $handler = $this->getHandler($topicObject); 362 $handler->replaceRevision( $topicObject->getEmbeddedStoreForm(), 363 'reprev', $cUID, $info->{date} ); 364 my $rev = $handler->getLatestRevisionID(); 365 $handler->recordChange( $cUID, $rev, 'minor, reprev' ); 366 367 $this->tellListeners( verb => 'update', newmeta => $topicObject ); 368 369 return $rev; 356 my ( $this, %args, %options ) = @_; 357 ASSERT( $args{address}->isa('Foswiki::Meta') ) if DEBUG; 358 ASSERT($args{cuid}) if DEBUG; 359 360 my $info = $args{address}->getRevisionInfo(); 361 my $handler = $this->getHandler($args{address}); 362 $handler->replaceRevision( $args{address}->getEmbeddedStoreForm(), 363 'reprev', $info->{author}, $info->{date} ); 364 $args{rev} = $handler->getLatestRevisionID(); 365 $handler->recordChange( $args{cuid}, $args{rev}, 'minor, reprev' ); 366 367 $this->tellListeners( verb => 'update', newmeta => $args{address} ); 368 369 return $args{rev}; 370 370 } 371 371 372 372 sub delRev { 373 my ( $this, $topicObject, $cUID) = @_;374 ASSERT( $ topicObject->isa('Foswiki::Meta') ) if DEBUG;375 ASSERT($ cUID) if DEBUG;376 377 my $handler = $this->getHandler($ topicObject);378 my $rev= $handler->getLatestRevisionID();379 if ( $ rev<= 1 ) {373 my ( $this, %args ) = @_; 374 ASSERT( $args{address}->isa('Foswiki::Meta') ) if DEBUG; 375 ASSERT($args{cuid}) if DEBUG; 376 377 my $handler = $this->getHandler($args{address}); 378 $args{rev} = $handler->getLatestRevisionID(); 379 if ( $args{rev} <= 1 ) { 380 380 throw Error::Simple( 'Cannot delete initial revision of ' 381 . $ topicObject->web . '.'382 . $ topicObject->topic );381 . $args{address}->web . '.' 382 . $args{address}->topic ); 383 383 } 384 384 $handler->deleteRevision(); 385 385 386 386 # restore last topic from repository 387 $handler->restoreLatestRevision($ cUID);387 $handler->restoreLatestRevision($args{cuid}); 388 388 389 389 # reload the topic object 390 $ topicObject->unload();391 $ topicObject->loadVersion();392 393 $this->tellListeners( verb => 'update', newmeta => $ topicObject);394 395 $handler->recordChange( $ cUID, $rev);396 397 return $ rev;390 $args{address}->unload(); 391 $args{address}->loadVersion(); 392 393 $this->tellListeners( verb => 'update', newmeta => $args{address} ); 394 395 $handler->recordChange( $args{cuid}, $args{rev} ); 396 397 return $args{rev}; 398 398 } 399 399 400 400 sub atomicLockInfo { 401 my ( $this, $topicObject) = @_;402 my $handler = $this->getHandler($ topicObject);401 my ( $this, %args ) = @_; 402 my $handler = $this->getHandler($args{address}); 403 403 return $handler->isLocked(); 404 404 } … … 407 407 # (doesn't work on all platforms) 408 408 sub atomicLock { 409 my ( $this, $topicObject, $cUID) = @_;410 my $handler = $this->getHandler($ topicObject);411 $handler->setLock( 1, $ cUID);409 my ( $this, %args ) = @_; 410 my $handler = $this->getHandler($args{address}); 411 $handler->setLock( 1, $args{cuid} ); 412 412 } 413 413 414 414 sub atomicUnlock { 415 my ( $this, $topicObject, $cUID) = @_;416 417 my $handler = $this->getHandler($ topicObject);418 $handler->setLock( 0, $ cUID);415 my ( $this, %args ) = @_; 416 417 my $handler = $this->getHandler($args{address}); 418 $handler->setLock( 0, $args{cuid} ); 419 419 } 420 420 … … 443 443 sub topicExists { 444 444 my ( $this, $web, $topic ) = @_; 445 445 446 446 return 0 unless defined $web && $web ne ''; 447 447 $web =~ s#\.#/#go; … … 467 467 468 468 sub eachAttachment { 469 my ( $this, $topicObject) = @_;470 471 my $handler = $this->getHandler($ topicObject);469 my ( $this, %args ) = @_; 470 471 my $handler = $this->getHandler($args{address}); 472 472 my @list = $handler->getAttachmentList(); 473 473 require Foswiki::ListIterator; … … 510 510 511 511 sub remove { 512 my ( $this, $cUID, $topicObject, $attachment) = @_;513 ASSERT( $ topicObject->web ) if DEBUG;514 515 my $handler = $this->getHandler( $ topicObject, $attachment);512 my ( $this, %args ) = @_; 513 ASSERT( $args{address}->web ) if DEBUG; 514 515 my $handler = $this->getHandler( $args{address}, $args{attachment} ); 516 516 $handler->remove(); 517 517 518 518 $this->tellListeners( 519 519 verb => 'remove', 520 oldmeta => $ topicObject,521 oldattachment => $a ttachment520 oldmeta => $args{address}, 521 oldattachment => $args{attachment} 522 522 ); 523 523 524 524 # Only log when deleting topics or attachment, otherwise we would re-create 525 525 # an empty directory with just a .changes. See Item9278 526 if ( my $topic = $ topicObject->topic ) {527 $handler->recordChange( $ cUID, 0, 'Deleted ' . $topic );528 } 529 elsif ($a ttachment) {530 $handler->recordChange( $ cUID, 0, 'Deleted attachment ' . $attachment);526 if ( my $topic = $args{address}->topic ) { 527 $handler->recordChange( $args{cuid}, 0, 'Deleted ' . $topic ); 528 } 529 elsif ($args{attachment}) { 530 $handler->recordChange( $args{cuid}, 0, 'Deleted attachment ' . $args{attachment} ); 531 531 } 532 532 } … … 566 566 567 567 sub getRevisionAtTime { 568 my ( $this, $topicObject, $time) = @_;569 570 my $handler = $this->getHandler($ topicObject);571 return $handler->getRevisionAtTime($ time);568 my ( $this, %args ) = @_; 569 570 my $handler = $this->getHandler($args{address}); 571 return $handler->getRevisionAtTime($args{time}); 572 572 } 573 573 574 574 sub getLease { 575 my ( $this, $topicObject) = @_;576 577 my $handler = $this->getHandler($ topicObject);575 my ( $this, %args ) = @_; 576 577 my $handler = $this->getHandler($args{address}); 578 578 my $lease = $handler->getLease(); 579 579 return $lease; … … 581 581 582 582 sub setLease { 583 my ( $this, $topicObject, $lease) = @_;584 585 my $handler = $this->getHandler($ topicObject);586 $handler->setLease($ lease);583 my ( $this, %args ) = @_; 584 585 my $handler = $this->getHandler($args{address}); 586 $handler->setLease($args{lease}); 587 587 } 588 588 … … 594 594 ############################################################################ 595 595 # new foswiki 2.0 API methods 596 597 sub save { 598 my $this = shift; 599 my %args = @_; 600 ASSERT($args{address}) if DEBUG; 601 my $type = $args{address}->type(); 602 # ASSERT($type) if DEBUG; 603 if ($type eq 'webpath') { 604 return $this->saveWeb($args{address}->web); 605 } elsif ($type eq 'topic') { 606 return $this->saveTopic(%args); 607 } 608 die "can't call save(".$args{address}->getPath().")" if DEBUG; 609 } 596 610 597 611 sub exists { … … 600 614 ASSERT($args{address}) if DEBUG; 601 615 my $type = $args{address}->type(); 602 ASSERT($type) if DEBUG;603 if ($type eq 'web ') {616 # ASSERT($type) if DEBUG; 617 if ($type eq 'webpath') { 604 618 return $this->webExists($args{address}->web); 605 619 } elsif ($type eq 'topic') { 606 620 return $this->topicExists($args{address}->web, $args{address}->topic); 607 621 } 608 die "can't call exists($type)" if DEBUG; 622 die "can't call exists(".$args{address}->getPath().") cos its type = $type " if DEBUG; 623 } 624 625 sub create { 626 my $this = shift; 627 my %args = @_; 628 ASSERT($args{address}) if DEBUG; 629 my $type = $args{address}->type(); 630 ASSERT($type) if DEBUG; 631 if ($type eq 'webpath') { 632 my $newResource = Foswiki::Meta->NEWnew( @_ ); 633 return $newResource; 634 } elsif ($type eq 'topic') { 635 my $newResource = Foswiki::Meta->NEWnew( @_ ); 636 return $newResource; 637 } 638 die "can't call load($type)" if DEBUG; 639 } 640 641 sub load { 642 my $this = shift; 643 my %args = @_; 644 ASSERT($args{address}) if DEBUG; 645 my $type = $args{address}->type(); 646 ASSERT($type) if DEBUG; 647 if ($type eq 'webpath') { 648 my $newResource = Foswiki::Meta->NEWnew( @_ ); 649 return $newResource; 650 } elsif ($type eq 'topic') { 651 my $handler = $this->getHandler($args{address}); 652 653 # check that the requested revision actually exists 654 $args{rev} = $args{address}->rev(); 655 if ( defined $args{rev} ) { 656 if ( !$args{rev} || !$handler->revisionExists($args{rev}) ) { 657 $args{rev} = $handler->getLatestRevisionID(); 658 } 659 } 660 661 #read the raw text file. 662 my ( $text, $isLatest ) = $handler->getRevision($args{rev}); 663 unless ( defined $text ) { 664 ASSERT( not $isLatest ) if DEBUG; 665 return undef; 666 } 667 668 #parse it into a hash so we can use it to create a new Foswiki::Object 669 #$text =~ s/\r//g; # Remove carriage returns 670 #$args{address}->setEmbeddedStoreForm($text); 671 my $parsedObj = Foswiki::Serialise::deserialise( $Foswiki::Plugins::SESSION, $text, 'embedded' ); 672 673 # return $this->topicExists($args{address}->web, $args{address}->topic); 674 my $newResource = Foswiki::Meta->NEWnew( data=>$parsedObj, @_ ); 675 return $newResource; 676 } 677 die "can't call load($type)" if DEBUG; 609 678 } 610 679 -
branches/scratch/core/lib/Foswiki/UI/Register.pm
r11121 r12543 1007 1007 $fromWeb = $Foswiki::cfg{SystemWebName}; 1008 1008 } 1009 my $tobj = Foswiki:: Meta->load( $session, $fromWeb, $template);1009 my $tobj = Foswiki::Store::load(address=>{web=>$fromWeb, topic=>$template}); 1010 1010 1011 1011 my $log = … … 1036 1036 my $user = $data->{WikiName}; 1037 1037 1038 my $topicObject = 1039 Foswiki::Meta->new( $session, $Foswiki::cfg{UsersWebName}, $user ); 1038 my $topicObject = Foswiki::Store::create(address=>{web=>$Foswiki::cfg{UsersWebName}, topic=>$user}); 1040 1039 my $log; 1041 1040 my $addText;
Note: See TracChangeset
for help on using the changeset viewer.
