Package =TWiki::StoreThis module hosts the generic storage backend. This module provides the interface layer between the "real" store provider - which is hidden behind a handler - and the rest of the system. it is responsible for checking for topic existance, access permissions, and all the other general admin tasks that are common to all store implementations. This module knows nothing about how the data is actually stored - that knowledge is entirely encapsulated in the handlers. The general contract for methods in the class requires that errors are signalled using exceptions. TWiki::AccessControlException is used for access control exceptions, and Error::Simple for all other types of error.On this page:
ClassMethod new ($session)Construct a Store module, linking in the chosen sub-implementation.ObjectMethod finish ()Break circular references.ObjectMethod readTopic ($user,$web,$topic,$version) -> ($metaObject,$text)Reads the given version of a topic and it's meta-data. If the version is undef, then read the most recent version. The version number must be an integer, or undef for the latest version. if $user is defined, view permission will be required for the topic read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user name passed in. If the topic contains a web specification (is of the form Web.Topic) the web specification will override whatever is passed in $web. The metadata and topic text are returned separately, with the metadata in a TWiki::Meta object. (The topic text is, as usual, just a string.)ObjectMethod *_findAttachments ($session,$web,$topic,$knownAttachments) -> @attachmentsFoundInPubSynchronise the attachment list with what's actually on disk Returns an ARRAY of FILEATTACHMENTs. These can be put in the new meta using meta->put('FILEATTACHMENTS', $tree) This function is only called when the AutoAttachPubFiles configuration option is set. IDEA On Windows machines where the underlying filesystem can store arbitary meta data against files, this might replace/fulfil the COMMENT purpose TODO consider logging when things are added to metadataObjectMethod readTopicRaw ($user,$web,$topic,$version) -> $topicTextReads the given version of a topic, without separating out any embedded meta-data. If the version is undef, then read the most recent version. The version number must be an integer or undef. If $user is defined, view permission will be required for the topic read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user name passed in. If the topic contains a web specification (is of the form Web.Topic) the web specification will override whatever is passed in $web. SMELL: DO NOT CALL THIS METHOD UNLESS YOU HAVE NO CHOICE. This method breaks encapsulation of the store, as it assumes meta is stored embedded in the text. Other implementors of store will be forced to insert meta-data to ensure correct operation of View raw=debug and the 'repRev' mode of Edit. $web and $topic must be untainted.ObjectMethod moveAttachment ($oldWeb,$oldTopic,$oldAttachment,$newWeb,$newTopic,$newAttachment,$user)Move an attachment from one topic to another. The caller to this routine should check that all topics are valid. All parameters must be defined, and must be untainted.ObjectMethod *getAttachmentStream ($user,$web,$topic,$attName) -> \*STREAM
ObjectMethod *getAttachmentList ($web,$topic)returns @($attachmentName => [stat]) for any given web, topicObjectMethod *attachmentExists ($web,$topic,$att) -> $booleanDetermine if the attachment already exists on the given topicObjectMethod *_removeAutoAttachmentsFromMetaThis is where we are going to remove from meta any entry that is marked as an automatic attachment.ObjectMethod moveTopic ($oldWeb,$oldTopic,$newWeb,$newTopic,$user)All parameters must be defined and must be untainted.ObjectMethod moveWeb ($oldWeb,$newWeb,$user)Move a web. All parrameters must be defined and must be untainted.ObjectMethod readAttachment ($user,$web,$topic,$attachment,$theRev) -> $textRead the given version of an attachment, returning the content. View permission on the topic is required for the read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user passed in. If $theRev is not given, the most recent rev is assumed.ObjectMethod *getRevisionNumber ($web,$topic,$attachment) -> $integerGet the revision number of the most recent revision. Returns the integer revision number or '' if the topic doesn't exist. WORKS FOR ATTACHMENTS AS WELL AS TOPICSObjectMethod getWorkArea ($key) -> $directorypathGets a private directory uniquely identified by $key. The directory is intended as a work area for plugins. The directory will exist.ObjectMethod *getRevisionDiff ($user,$web,$topic,$rev1,$rev2,$contextLines) -> \@diffArrayReturn reference to an array of [ diffType, $right, $left ]
ObjectMethod *getRevisionInfo ($web,$topic,$rev,$attachment) -> ($date,$user,$rev,$comment)Get revision info of a topic.
StaticMethod dataEncode ($uncoded) -> $codedEncode meta-data fields, escaping out selected characters. The encoding is chosen to avoid problems with parsing the attribute values, while minimising the number of characters encoded so searches can still work (fairly) sensibly. The encoding has to be exported because TWiki (and plugins) use encoded field data in other places e.g. RDiff, mainly as a shorthand for the properly parsed meta object. Some day we may be able to eliminate that....StaticMethod dataDecode ($encoded) -> $decodedDecode escapes in a string that was encoded using dataEncode The encoding has to be exported because TWiki (and plugins) use encoded field data in other places e.g. RDiff, mainly as a shorthand for the properly parsed meta object. Some day we may be able to eliminate that....ObjectMethod saveTopic ($user,$web,$topic,$text,$meta,$options)
$options may include:
ObjectMethod saveAttachment ($web,$topic,$attachment,$user,$opts)
$opts may include:
ObjectMethod repRev ($user,$web,$topic,$text,$meta,$options)Replace last (top) revision with different text. Parameters and return value as saveTopic, except
ObjectMethod delRev ($user,$web,$topic,$text,$meta,$options)Parameters and return value as saveTopic. Provided as a means for administrators to rewrite history. Delete last entry in repository, restoring the previous revision. It is up to the store implementation whether this actually does delete a revision or not; some implementations will simply promote the previous revision up to the head.ObjectMethod lockTopic ($web,$topic)Grab a topic lock on the given topic. A topic lock will cause other processes that also try to claim a lock to block. A lock has a maximum lifetime of 2 minutes, so operations on a locked topic must be completed within that time. You cannot rely on the lock timeout clearing the lock, though; that should always be done by calling unlockTopic. The best thing to do is to guard the locked section with a try..finally clause. See man Error for more info. Topic locks are used to make store operations atomic. They are note the locks used when a topic is edited; those are Leases (seegetLease )
ObjectMethod unlockTopic ($user,$web,$topic)Release the topic lock on the given topic. A topic lock will cause other processes that also try to claim a lock to block. It is important to release a topic lock after a guard section is complete. This should normally be done in a 'finally' block. See man Error for more info. Topic locks are used to make store operations atomic. They are note the locks used when a topic is edited; those are Leases (seegetLease )
ObjectMethod webExists ($web) -> $booleanTest if web exists
ObjectMethod topicExists ($web,$topic) -> $booleanTest if topic exists
| |||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||
< < | Warning: topicExists does not call ( $web, $topic ) = $this->{session}->normalizeWebTopicName( $web, $topic ); for you (it'd make TWiki even slower) so make sure you do so. | ||||||||||||||||||||||||||||||||||||||||||
> > | Warning: topicExists does not call ( $web, $topic ) = $this->{session}->normalizeWebTopicName( $web, $topic ); for you (it'd make TWiki even slower) so make sure you do so. | ||||||||||||||||||||||||||||||||||||||||||
Deleted: | |||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||
ObjectMethod getTopicParent ($web,$topic) -> $stringGet the name of the topic parent. Needs to be fast because of use by Render.pm.ObjectMethod *getTopicLatestRevTime ($web,$topic) -> $epochSecsGet an approximate rev time for the latest rev of the topic. This method is used to optimise searching. Needs to be as fast as possible.ObjectMethod eachChange ($web,$time) -> $iteratorGet an iterator over the list of all the changes in the given web between$time and now. $time is a time in seconds since 1st Jan 1970, and is not
guaranteed to return any changes that occurred before (now -
{Store}{RememberChangesFor}). Changes are returned in most-recent-first
order.
ObjectMethod getTopicNames ($web) -> @topicsGet list of all topics in a web
( 'WebChanges', 'WebHome', 'WebIndex', 'WebNotify' )
ObjectMethod getListOfWebs ($filter) -> @webNamesGets a list of webs, filtered according to the spec in the $filter, which may include one of:
ObjectMethod createWeb ($user,$newWeb,$baseWeb,$opts)$newWeb is the name of the new web. $baseWeb is the name of an existing web (a template web). If the base web is a system web, all topics in it will be copied into the new web. If it is a normal web, only topics starting with 'Web' will be copied. If no base web is specified, an empty web (with no topics) will be created. If it is specified but does not exist, an error will be thrown. $opts is a ref to a hash that contains settings to be modified in the web preferences topic in the new web.ObjectMethod removeWeb ($user,$web)
ObjectMethod getDebugText ($meta,$text) -> $textGenerate a debug text form of the text/meta, for use in debug displays, by annotating the text with meta informtion.ObjectMethod cleanUpRevID ($rev) -> $integerCleans up (maps) a user-supplied revision ID and converts it to an integer number that can be incremented to create a new revision number. This method should be used to sanitise user-provided revision IDs.ObjectMethod copyTopic ($user,$fromweb,$fromtopic,$toweb,$totopic)Copy a topic and all it's attendant data from one web to another. SMELL: Does not fix up meta-data!ObjectMethod searchMetaData ($params) -> $textSearch meta-data associated with topics. Parameters are passed in the $params hash, which may contain:
ObjectMethod *searchInWebMetaData ($query,$web,\@topics) -> \%matchesSearch for a meta-data expression in the content of a web.$query must be a TWiki::Query object.
Returns a reference to a hash that maps the names of topics that all matched
to the result of the query expression (e.g. if the query expression is
'TOPICPARENT.name' then you will get back a hash that maps topic names
to their parent.
ObjectMethod *searchInWebContent ($searchString,$web,\@topics,\%options) -> \%mapSearch for a string in the content of a web. The search must be over all content and all formatted meta-data, though the latter search type is deprecated (use searchMetaData instead).
\%options hash may contain the following options:
files_without_match is specified, it will
return on the first match in each topic (i.e. it will return only one
match per topic, and will not return matching lines).
ObjectMethod *getRevisionAtTime ($web,$topic,$time) -> $rev
ObjectMethod getLease ($web,$topic) -> $lease
user , taken and expires ).
Leases are taken out when a topic is edited. Only one lease
can be active on a topic at a time. Leases are used to warn if
another user is already editing a topic.
ObjectMethod setLease ($web,$topic,$user,$length)Take out an lease on the given topic for this user for $length seconds. SeegetLease for more details about Leases.
ObjectMethod clearLease ($web,$topic)Cancel the current lease. SeegetLease for more details about Leases.
ObjectMethod *removeSpuriousLeases ($web)Remove leases that are not related to a topic. These can get left behind in some store implementations when a topic is created, but never saved. |
Package =TWiki::StoreThis module hosts the generic storage backend. This module provides the interface layer between the "real" store provider - which is hidden behind a handler - and the rest of the system. it is responsible for checking for topic existance, access permissions, and all the other general admin tasks that are common to all store implementations. This module knows nothing about how the data is actually stored - that knowledge is entirely encapsulated in the handlers. The general contract for methods in the class requires that errors are signalled using exceptions. TWiki::AccessControlException is used for access control exceptions, and Error::Simple for all other types of error.On this page:
ClassMethod new ($session)Construct a Store module, linking in the chosen sub-implementation.ObjectMethod finish ()Break circular references.ObjectMethod readTopic ($user,$web,$topic,$version) -> ($metaObject,$text)Reads the given version of a topic and it's meta-data. If the version is undef, then read the most recent version. The version number must be an integer, or undef for the latest version. if $user is defined, view permission will be required for the topic read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user name passed in. If the topic contains a web specification (is of the form Web.Topic) the web specification will override whatever is passed in $web. The metadata and topic text are returned separately, with the metadata in a TWiki::Meta object. (The topic text is, as usual, just a string.)ObjectMethod *_findAttachments ($session,$web,$topic,$knownAttachments) -> @attachmentsFoundInPubSynchronise the attachment list with what's actually on disk Returns an ARRAY of FILEATTACHMENTs. These can be put in the new meta using meta->put('FILEATTACHMENTS', $tree) This function is only called when the AutoAttachPubFiles configuration option is set. IDEA On Windows machines where the underlying filesystem can store arbitary meta data against files, this might replace/fulfil the COMMENT purpose TODO consider logging when things are added to metadataObjectMethod readTopicRaw ($user,$web,$topic,$version) -> $topicTextReads the given version of a topic, without separating out any embedded meta-data. If the version is undef, then read the most recent version. The version number must be an integer or undef. If $user is defined, view permission will be required for the topic read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user name passed in. If the topic contains a web specification (is of the form Web.Topic) the web specification will override whatever is passed in $web. SMELL: DO NOT CALL THIS METHOD UNLESS YOU HAVE NO CHOICE. This method breaks encapsulation of the store, as it assumes meta is stored embedded in the text. Other implementors of store will be forced to insert meta-data to ensure correct operation of View raw=debug and the 'repRev' mode of Edit. $web and $topic must be untainted.ObjectMethod moveAttachment ($oldWeb,$oldTopic,$oldAttachment,$newWeb,$newTopic,$newAttachment,$user)Move an attachment from one topic to another. The caller to this routine should check that all topics are valid. All parameters must be defined, and must be untainted.ObjectMethod *getAttachmentStream ($user,$web,$topic,$attName) -> \*STREAM
ObjectMethod *getAttachmentList ($web,$topic)returns @($attachmentName => [stat]) for any given web, topicObjectMethod *attachmentExists ($web,$topic,$att) -> $booleanDetermine if the attachment already exists on the given topicObjectMethod *_removeAutoAttachmentsFromMetaThis is where we are going to remove from meta any entry that is marked as an automatic attachment.ObjectMethod moveTopic ($oldWeb,$oldTopic,$newWeb,$newTopic,$user)All parameters must be defined and must be untainted.ObjectMethod moveWeb ($oldWeb,$newWeb,$user)Move a web. All parrameters must be defined and must be untainted.ObjectMethod readAttachment ($user,$web,$topic,$attachment,$theRev) -> $textRead the given version of an attachment, returning the content. View permission on the topic is required for the read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user passed in. If $theRev is not given, the most recent rev is assumed.ObjectMethod *getRevisionNumber ($web,$topic,$attachment) -> $integerGet the revision number of the most recent revision. Returns the integer revision number or '' if the topic doesn't exist. WORKS FOR ATTACHMENTS AS WELL AS TOPICSObjectMethod getWorkArea ($key) -> $directorypathGets a private directory uniquely identified by $key. The directory is intended as a work area for plugins. The directory will exist.ObjectMethod *getRevisionDiff ($user,$web,$topic,$rev1,$rev2,$contextLines) -> \@diffArrayReturn reference to an array of [ diffType, $right, $left ]
ObjectMethod *getRevisionInfo ($web,$topic,$rev,$attachment) -> ($date,$user,$rev,$comment)Get revision info of a topic.
StaticMethod dataEncode ($uncoded) -> $codedEncode meta-data fields, escaping out selected characters. The encoding is chosen to avoid problems with parsing the attribute values, while minimising the number of characters encoded so searches can still work (fairly) sensibly. The encoding has to be exported because TWiki (and plugins) use encoded field data in other places e.g. RDiff, mainly as a shorthand for the properly parsed meta object. Some day we may be able to eliminate that....StaticMethod dataDecode ($encoded) -> $decodedDecode escapes in a string that was encoded using dataEncode The encoding has to be exported because TWiki (and plugins) use encoded field data in other places e.g. RDiff, mainly as a shorthand for the properly parsed meta object. Some day we may be able to eliminate that....ObjectMethod saveTopic ($user,$web,$topic,$text,$meta,$options)
$options may include:
ObjectMethod saveAttachment ($web,$topic,$attachment,$user,$opts)
$opts may include:
ObjectMethod repRev ($user,$web,$topic,$text,$meta,$options)Replace last (top) revision with different text. Parameters and return value as saveTopic, except
ObjectMethod delRev ($user,$web,$topic,$text,$meta,$options)Parameters and return value as saveTopic. Provided as a means for administrators to rewrite history. Delete last entry in repository, restoring the previous revision. It is up to the store implementation whether this actually does delete a revision or not; some implementations will simply promote the previous revision up to the head.ObjectMethod lockTopic ($web,$topic)Grab a topic lock on the given topic. A topic lock will cause other processes that also try to claim a lock to block. A lock has a maximum lifetime of 2 minutes, so operations on a locked topic must be completed within that time. You cannot rely on the lock timeout clearing the lock, though; that should always be done by calling unlockTopic. The best thing to do is to guard the locked section with a try..finally clause. See man Error for more info. Topic locks are used to make store operations atomic. They are note the locks used when a topic is edited; those are Leases (seegetLease )
ObjectMethod unlockTopic ($user,$web,$topic)Release the topic lock on the given topic. A topic lock will cause other processes that also try to claim a lock to block. It is important to release a topic lock after a guard section is complete. This should normally be done in a 'finally' block. See man Error for more info. Topic locks are used to make store operations atomic. They are note the locks used when a topic is edited; those are Leases (seegetLease )
ObjectMethod webExists ($web) -> $booleanTest if web exists
ObjectMethod topicExists ($web,$topic) -> $booleanTest if topic exists
| |||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||
> > | Warning: topicExists does not call ( $web, $topic ) = $this->{session}->normalizeWebTopicName( $web, $topic ); for you (it'd make TWiki even slower) so make sure you do so. | ||||||||||||||||||||||||||||||||||||||||||
ObjectMethod getTopicParent ($web,$topic) -> $stringGet the name of the topic parent. Needs to be fast because of use by Render.pm.ObjectMethod *getTopicLatestRevTime ($web,$topic) -> $epochSecsGet an approximate rev time for the latest rev of the topic. This method is used to optimise searching. Needs to be as fast as possible.ObjectMethod eachChange ($web,$time) -> $iteratorGet an iterator over the list of all the changes in the given web between$time and now. $time is a time in seconds since 1st Jan 1970, and is not
guaranteed to return any changes that occurred before (now -
{Store}{RememberChangesFor}). Changes are returned in most-recent-first
order.
ObjectMethod getTopicNames ($web) -> @topicsGet list of all topics in a web
( 'WebChanges', 'WebHome', 'WebIndex', 'WebNotify' )
ObjectMethod getListOfWebs ($filter) -> @webNamesGets a list of webs, filtered according to the spec in the $filter, which may include one of:
ObjectMethod createWeb ($user,$newWeb,$baseWeb,$opts)$newWeb is the name of the new web. $baseWeb is the name of an existing web (a template web). If the base web is a system web, all topics in it will be copied into the new web. If it is a normal web, only topics starting with 'Web' will be copied. If no base web is specified, an empty web (with no topics) will be created. If it is specified but does not exist, an error will be thrown. $opts is a ref to a hash that contains settings to be modified in the web preferences topic in the new web.ObjectMethod removeWeb ($user,$web)
ObjectMethod getDebugText ($meta,$text) -> $textGenerate a debug text form of the text/meta, for use in debug displays, by annotating the text with meta informtion.ObjectMethod cleanUpRevID ($rev) -> $integerCleans up (maps) a user-supplied revision ID and converts it to an integer number that can be incremented to create a new revision number. This method should be used to sanitise user-provided revision IDs.ObjectMethod copyTopic ($user,$fromweb,$fromtopic,$toweb,$totopic)Copy a topic and all it's attendant data from one web to another. SMELL: Does not fix up meta-data!ObjectMethod searchMetaData ($params) -> $textSearch meta-data associated with topics. Parameters are passed in the $params hash, which may contain:
ObjectMethod *searchInWebMetaData ($query,$web,\@topics) -> \%matchesSearch for a meta-data expression in the content of a web.$query must be a TWiki::Query object.
Returns a reference to a hash that maps the names of topics that all matched
to the result of the query expression (e.g. if the query expression is
'TOPICPARENT.name' then you will get back a hash that maps topic names
to their parent.
ObjectMethod *searchInWebContent ($searchString,$web,\@topics,\%options) -> \%mapSearch for a string in the content of a web. The search must be over all content and all formatted meta-data, though the latter search type is deprecated (use searchMetaData instead).
\%options hash may contain the following options:
files_without_match is specified, it will
return on the first match in each topic (i.e. it will return only one
match per topic, and will not return matching lines).
ObjectMethod *getRevisionAtTime ($web,$topic,$time) -> $rev
ObjectMethod getLease ($web,$topic) -> $lease
user , taken and expires ).
Leases are taken out when a topic is edited. Only one lease
can be active on a topic at a time. Leases are used to warn if
another user is already editing a topic.
ObjectMethod setLease ($web,$topic,$user,$length)Take out an lease on the given topic for this user for $length seconds. SeegetLease for more details about Leases.
ObjectMethod clearLease ($web,$topic)Cancel the current lease. SeegetLease for more details about Leases.
ObjectMethod *removeSpuriousLeases ($web)Remove leases that are not related to a topic. These can get left behind in some store implementations when a topic is created, but never saved. |
Package =TWiki::StoreThis module hosts the generic storage backend. This module provides the interface layer between the "real" store provider - which is hidden behind a handler - and the rest of the system. it is responsible for checking for topic existance, access permissions, and all the other general admin tasks that are common to all store implementations. This module knows nothing about how the data is actually stored - that knowledge is entirely encapsulated in the handlers. The general contract for methods in the class requires that errors are signalled using exceptions. TWiki::AccessControlException is used for access control exceptions, and Error::Simple for all other types of error.On this page:
| |||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||
< < | ClassMethod new () | ||||||||||||||||||||||||||||||||||||||||
> > | ClassMethod new ($session) | ||||||||||||||||||||||||||||||||||||||||
Construct a Store module, linking in the chosen sub-implementation. | |||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||
< < | ObjectMethod *finish | ||||||||||||||||||||||||||||||||||||||||
> > | ObjectMethod finish () | ||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||
> > | Break circular references. | ||||||||||||||||||||||||||||||||||||||||
Deleted: | |||||||||||||||||||||||||||||||||||||||||
< < | Complete processing after the client's HTTP request has been responded
to.
| ||||||||||||||||||||||||||||||||||||||||
Deleted: | |||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||
ObjectMethod readTopic ($user,$web,$topic,$version) -> ($metaObject,$text)Reads the given version of a topic and it's meta-data. If the version is undef, then read the most recent version. The version number must be an integer, or undef for the latest version. if $user is defined, view permission will be required for the topic read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user name passed in. If the topic contains a web specification (is of the form Web.Topic) the web specification will override whatever is passed in $web. The metadata and topic text are returned separately, with the metadata in a TWiki::Meta object. (The topic text is, as usual, just a string.)ObjectMethod *_findAttachments ($session,$web,$topic,$knownAttachments) -> @attachmentsFoundInPubSynchronise the attachment list with what's actually on disk Returns an ARRAY of FILEATTACHMENTs. These can be put in the new meta using meta->put('FILEATTACHMENTS', $tree) This function is only called when the AutoAttachPubFiles configuration option is set. IDEA On Windows machines where the underlying filesystem can store arbitary meta data against files, this might replace/fulfil the COMMENT purpose TODO consider logging when things are added to metadataObjectMethod readTopicRaw ($user,$web,$topic,$version) -> $topicTextReads the given version of a topic, without separating out any embedded meta-data. If the version is undef, then read the most recent version. The version number must be an integer or undef. If $user is defined, view permission will be required for the topic read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user name passed in. If the topic contains a web specification (is of the form Web.Topic) the web specification will override whatever is passed in $web. SMELL: DO NOT CALL THIS METHOD UNLESS YOU HAVE NO CHOICE. This method breaks encapsulation of the store, as it assumes meta is stored embedded in the text. Other implementors of store will be forced to insert meta-data to ensure correct operation of View raw=debug and the 'repRev' mode of Edit. $web and $topic must be untainted.ObjectMethod moveAttachment ($oldWeb,$oldTopic,$oldAttachment,$newWeb,$newTopic,$newAttachment,$user)Move an attachment from one topic to another. The caller to this routine should check that all topics are valid. All parameters must be defined, and must be untainted.ObjectMethod *getAttachmentStream ($user,$web,$topic,$attName) -> \*STREAM
ObjectMethod *getAttachmentList ($web,$topic)returns @($attachmentName => [stat]) for any given web, topicObjectMethod *attachmentExists ($web,$topic,$att) -> $booleanDetermine if the attachment already exists on the given topicObjectMethod *_removeAutoAttachmentsFromMetaThis is where we are going to remove from meta any entry that is marked as an automatic attachment.ObjectMethod moveTopic ($oldWeb,$oldTopic,$newWeb,$newTopic,$user)All parameters must be defined and must be untainted.ObjectMethod moveWeb ($oldWeb,$newWeb,$user)Move a web. All parrameters must be defined and must be untainted.ObjectMethod readAttachment ($user,$web,$topic,$attachment,$theRev) -> $textRead the given version of an attachment, returning the content. View permission on the topic is required for the read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user passed in. If $theRev is not given, the most recent rev is assumed.ObjectMethod *getRevisionNumber ($web,$topic,$attachment) -> $integerGet the revision number of the most recent revision. Returns the integer revision number or '' if the topic doesn't exist. WORKS FOR ATTACHMENTS AS WELL AS TOPICSObjectMethod getWorkArea ($key) -> $directorypathGets a private directory uniquely identified by $key. The directory is intended as a work area for plugins. The directory will exist.ObjectMethod *getRevisionDiff ($user,$web,$topic,$rev1,$rev2,$contextLines) -> \@diffArrayReturn reference to an array of [ diffType, $right, $left ] | |||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||
ObjectMethod *getRevisionInfo ($web,$topic,$rev,$attachment) -> ($date,$user,$rev,$comment)Get revision info of a topic.
| |||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||
< < | Return list with: ( last update date, last user object, = | ||||||||||||||||||||||||||||||||||||||||
> > | Return list with: ( last update date, last user id, = | ||||||||||||||||||||||||||||||||||||||||
StaticMethod dataEncode ($uncoded) -> $codedEncode meta-data fields, escaping out selected characters. The encoding is chosen to avoid problems with parsing the attribute values, while minimising the number of characters encoded so searches can still work (fairly) sensibly. The encoding has to be exported because TWiki (and plugins) use encoded field data in other places e.g. RDiff, mainly as a shorthand for the properly parsed meta object. Some day we may be able to eliminate that....StaticMethod dataDecode ($encoded) -> $decodedDecode escapes in a string that was encoded using dataEncode The encoding has to be exported because TWiki (and plugins) use encoded field data in other places e.g. RDiff, mainly as a shorthand for the properly parsed meta object. Some day we may be able to eliminate that....ObjectMethod saveTopic ($user,$web,$topic,$text,$meta,$options)
$options may include:
ObjectMethod saveAttachment ($web,$topic,$attachment,$user,$opts)
$opts may include:
| |||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||
Saves a new revision of the attachment, invoking plugin handlers as
appropriate.
If file is not set, this is a properties-only save.
ObjectMethod repRev ($user,$web,$topic,$text,$meta,$options)Replace last (top) revision with different text. Parameters and return value as saveTopic, except
ObjectMethod delRev ($user,$web,$topic,$text,$meta,$options)Parameters and return value as saveTopic. Provided as a means for administrators to rewrite history. Delete last entry in repository, restoring the previous revision. It is up to the store implementation whether this actually does delete a revision or not; some implementations will simply promote the previous revision up to the head.ObjectMethod lockTopic ($web,$topic)Grab a topic lock on the given topic. A topic lock will cause other processes that also try to claim a lock to block. A lock has a maximum lifetime of 2 minutes, so operations on a locked topic must be completed within that time. You cannot rely on the lock timeout clearing the lock, though; that should always be done by calling unlockTopic. The best thing to do is to guard the locked section with a try..finally clause. See man Error for more info. Topic locks are used to make store operations atomic. They are note the locks used when a topic is edited; those are Leases (seegetLease )
ObjectMethod unlockTopic ($user,$web,$topic)Release the topic lock on the given topic. A topic lock will cause other processes that also try to claim a lock to block. It is important to release a topic lock after a guard section is complete. This should normally be done in a 'finally' block. See man Error for more info. Topic locks are used to make store operations atomic. They are note the locks used when a topic is edited; those are Leases (seegetLease )
ObjectMethod webExists ($web) -> $booleanTest if web exists
| |||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||
< < | A web has to have a home topic to be a web. | ||||||||||||||||||||||||||||||||||||||||
> > | A web has to have a preferences topic to be a web. | ||||||||||||||||||||||||||||||||||||||||
ObjectMethod topicExists ($web,$topic) -> $booleanTest if topic exists
ObjectMethod getTopicParent ($web,$topic) -> $stringGet the name of the topic parent. Needs to be fast because of use by Render.pm.ObjectMethod *getTopicLatestRevTime ($web,$topic) -> $epochSecsGet an approximate rev time for the latest rev of the topic. This method is used to optimise searching. Needs to be as fast as possible. | |||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||
< < | ObjectMethod readMetaData ($web,$name) -> $text | ||||||||||||||||||||||||||||||||||||||||
> > | ObjectMethod eachChange ($web,$time) -> $iterator | ||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||
< < | Read a named meta-data string. If web is given the meta-data is stored alongside a web. | ||||||||||||||||||||||||||||||||||||||||
> > | Get an iterator over the list of all the changes in the given web between
$time and now. $time is a time in seconds since 1st Jan 1970, and is not | ||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||
> > | guaranteed to return any changes that occurred before (now - {Store}{RememberChangesFor}). Changes are returned in most-recent-first order. | ||||||||||||||||||||||||||||||||||||||||
Deleted: | |||||||||||||||||||||||||||||||||||||||||
< < | ObjectMethod saveMetaData ($web,$name) -> $textWrite a named meta-data string. If web is given the meta-data is stored alongside a web. | ||||||||||||||||||||||||||||||||||||||||
ObjectMethod getTopicNames ($web) -> @topicsGet list of all topics in a web
( 'WebChanges', 'WebHome', 'WebIndex', 'WebNotify' )
ObjectMethod getListOfWebs ($filter) -> @webNamesGets a list of webs, filtered according to the spec in the $filter, which may include one of:
ObjectMethod createWeb ($user,$newWeb,$baseWeb,$opts)$newWeb is the name of the new web. $baseWeb is the name of an existing web (a template web). If the base web is a system web, all topics in it will be copied into the new web. If it is a normal web, only topics starting with 'Web' will be copied. If no base web is specified, an empty web (with no topics) will be created. If it is specified but does not exist, an error will be thrown. $opts is a ref to a hash that contains settings to be modified in the web preferences topic in the new web.ObjectMethod removeWeb ($user,$web)
ObjectMethod getDebugText ($meta,$text) -> $textGenerate a debug text form of the text/meta, for use in debug displays, by annotating the text with meta informtion.ObjectMethod cleanUpRevID ($rev) -> $integerCleans up (maps) a user-supplied revision ID and converts it to an integer number that can be incremented to create a new revision number. This method should be used to sanitise user-provided revision IDs.ObjectMethod copyTopic ($user,$fromweb,$fromtopic,$toweb,$totopic)Copy a topic and all it's attendant data from one web to another. SMELL: Does not fix up meta-data!ObjectMethod searchMetaData ($params) -> $textSearch meta-data associated with topics. Parameters are passed in the $params hash, which may contain:
| |||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||
The idea is that people can search for meta-data values without having to be aware of how or where meta-data is stored. SMELL: should be replaced with a proper SQL-like search, c.f. DBCacheContrib. | |||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||
> > |
ObjectMethod *searchInWebMetaData ($query,$web,\@topics) -> \%matchesSearch for a meta-data expression in the content of a web.$query must be a TWiki::Query object.
Returns a reference to a hash that maps the names of topics that all matched
to the result of the query expression (e.g. if the query expression is
'TOPICPARENT.name' then you will get back a hash that maps topic names
to their parent. | ||||||||||||||||||||||||||||||||||||||||
ObjectMethod *searchInWebContent ($searchString,$web,\@topics,\%options) -> \%mapSearch for a string in the content of a web. The search must be over all content and all formatted meta-data, though the latter search type is deprecated (use searchMetaData instead).
\%options hash may contain the following options:
files_without_match is specified, it will
return on the first match in each topic (i.e. it will return only one
match per topic, and will not return matching lines).
ObjectMethod *getRevisionAtTime ($web,$topic,$time) -> $rev
ObjectMethod getLease ($web,$topic) -> $lease
user , taken and expires ).
Leases are taken out when a topic is edited. Only one lease
can be active on a topic at a time. Leases are used to warn if
another user is already editing a topic.
ObjectMethod setLease ($web,$topic,$user,$length)Take out an lease on the given topic for this user for $length seconds. SeegetLease for more details about Leases.
ObjectMethod clearLease ($web,$topic)Cancel the current lease. SeegetLease for more details about Leases.
ObjectMethod *removeSpuriousLeases ($web)Remove leases that are not related to a topic. These can get left behind in some store implementations when a topic is created, but never saved. |
Package =TWiki::StoreThis module hosts the generic storage backend. This module provides the interface layer between the "real" store provider - which is hidden behind a handler - and the rest of the system. it is responsible for checking for topic existance, access permissions, and all the other general admin tasks that are common to all store implementations. This module knows nothing about how the data is actually stored - that knowledge is entirely encapsulated in the handlers. The general contract for methods in the class requires that errors are signalled using exceptions. TWiki::AccessControlException is used for access control exceptions, and Error::Simple for all other types of error.On this page:
ClassMethod new ()Construct a Store module, linking in the chosen sub-implementation.ObjectMethod *finishComplete processing after the client's HTTP request has been responded to.
ObjectMethod readTopic ($user,$web,$topic,$version) -> ($metaObject,$text)Reads the given version of a topic and it's meta-data. If the version is undef, then read the most recent version. The version number must be an integer, or undef for the latest version. if $user is defined, view permission will be required for the topic read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user name passed in. If the topic contains a web specification (is of the form Web.Topic) the web specification will override whatever is passed in $web. The metadata and topic text are returned separately, with the metadata in a TWiki::Meta object. (The topic text is, as usual, just a string.) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | ObjectMethod *_findAttachments ($session,$web,$topic,$knownAttachments) -> @attachmentsFoundInPubSynchronise the attachment list with what's actually on disk Returns an ARRAY of FILEATTACHMENTs. These can be put in the new meta using meta->put('FILEATTACHMENTS', $tree) This function is only called when the AutoAttachPubFiles configuration option is set. IDEA On Windows machines where the underlying filesystem can store arbitary meta data against files, this might replace/fulfil the COMMENT purpose TODO consider logging when things are added to metadata | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
ObjectMethod readTopicRaw ($user,$web,$topic,$version) -> $topicTextReads the given version of a topic, without separating out any embedded meta-data. If the version is undef, then read the most recent version. The version number must be an integer or undef. If $user is defined, view permission will be required for the topic read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user name passed in. If the topic contains a web specification (is of the form Web.Topic) the web specification will override whatever is passed in $web. SMELL: DO NOT CALL THIS METHOD UNLESS YOU HAVE NO CHOICE. This method breaks encapsulation of the store, as it assumes meta is stored embedded in the text. Other implementors of store will be forced to insert meta-data to ensure correct operation of View raw=debug and the 'repRev' mode of Edit. $web and $topic must be untainted.ObjectMethod moveAttachment ($oldWeb,$oldTopic,$oldAttachment,$newWeb,$newTopic,$newAttachment,$user)Move an attachment from one topic to another. The caller to this routine should check that all topics are valid. All parameters must be defined, and must be untainted.ObjectMethod *getAttachmentStream ($user,$web,$topic,$attName) -> \*STREAM
ObjectMethod *getAttachmentList ($web,$topic)returns @($attachmentName => [stat]) for any given web, topicObjectMethod *attachmentExists ($web,$topic,$att) -> $booleanDetermine if the attachment already exists on the given topicObjectMethod *_removeAutoAttachmentsFromMetaThis is where we are going to remove from meta any entry that is marked as an automatic attachment.ObjectMethod moveTopic ($oldWeb,$oldTopic,$newWeb,$newTopic,$user)All parameters must be defined and must be untainted.ObjectMethod moveWeb ($oldWeb,$newWeb,$user)Move a web. All parrameters must be defined and must be untainted.ObjectMethod readAttachment ($user,$web,$topic,$attachment,$theRev) -> $textRead the given version of an attachment, returning the content. View permission on the topic is required for the read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user passed in. If $theRev is not given, the most recent rev is assumed.ObjectMethod *getRevisionNumber ($web,$topic,$attachment) -> $integerGet the revision number of the most recent revision. Returns the integer revision number or '' if the topic doesn't exist. WORKS FOR ATTACHMENTS AS WELL AS TOPICSObjectMethod getWorkArea ($key) -> $directorypathGets a private directory uniquely identified by $key. The directory is intended as a work area for plugins. The directory will exist.ObjectMethod *getRevisionDiff ($user,$web,$topic,$rev1,$rev2,$contextLines) -> \@diffArrayReturn reference to an array of [ diffType, $right, $left ]
ObjectMethod *getRevisionInfo ($web,$topic,$rev,$attachment) -> ($date,$user,$rev,$comment)Get revision info of a topic.
StaticMethod dataEncode ($uncoded) -> $codedEncode meta-data fields, escaping out selected characters. The encoding is chosen to avoid problems with parsing the attribute values, while minimising the number of characters encoded so searches can still work (fairly) sensibly. The encoding has to be exported because TWiki (and plugins) use encoded field data in other places e.g. RDiff, mainly as a shorthand for the properly parsed meta object. Some day we may be able to eliminate that....StaticMethod dataDecode ($encoded) -> $decodedDecode escapes in a string that was encoded using dataEncode The encoding has to be exported because TWiki (and plugins) use encoded field data in other places e.g. RDiff, mainly as a shorthand for the properly parsed meta object. Some day we may be able to eliminate that....ObjectMethod saveTopic ($user,$web,$topic,$text,$meta,$options)
$options may include:
ObjectMethod saveAttachment ($web,$topic,$attachment,$user,$opts)
$opts may include:
ObjectMethod repRev ($user,$web,$topic,$text,$meta,$options)Replace last (top) revision with different text. Parameters and return value as saveTopic, except
ObjectMethod delRev ($user,$web,$topic,$text,$meta,$options)Parameters and return value as saveTopic. Provided as a means for administrators to rewrite history. Delete last entry in repository, restoring the previous revision. It is up to the store implementation whether this actually does delete a revision or not; some implementations will simply promote the previous revision up to the head.ObjectMethod lockTopic ($web,$topic)Grab a topic lock on the given topic. A topic lock will cause other processes that also try to claim a lock to block. A lock has a maximum lifetime of 2 minutes, so operations on a locked topic must be completed within that time. You cannot rely on the lock timeout clearing the lock, though; that should always be done by calling unlockTopic. The best thing to do is to guard the locked section with a try..finally clause. See man Error for more info. Topic locks are used to make store operations atomic. They are note the locks used when a topic is edited; those are Leases (seegetLease )
ObjectMethod unlockTopic ($user,$web,$topic)Release the topic lock on the given topic. A topic lock will cause other processes that also try to claim a lock to block. It is important to release a topic lock after a guard section is complete. This should normally be done in a 'finally' block. See man Error for more info. Topic locks are used to make store operations atomic. They are note the locks used when a topic is edited; those are Leases (seegetLease )
ObjectMethod webExists ($web) -> $booleanTest if web exists
ObjectMethod topicExists ($web,$topic) -> $booleanTest if topic exists
ObjectMethod getTopicParent ($web,$topic) -> $stringGet the name of the topic parent. Needs to be fast because of use by Render.pm.ObjectMethod *getTopicLatestRevTime ($web,$topic) -> $epochSecsGet an approximate rev time for the latest rev of the topic. This method is used to optimise searching. Needs to be as fast as possible.ObjectMethod readMetaData ($web,$name) -> $textRead a named meta-data string. If web is given the meta-data is stored alongside a web.ObjectMethod saveMetaData ($web,$name) -> $textWrite a named meta-data string. If web is given the meta-data is stored alongside a web.ObjectMethod getTopicNames ($web) -> @topicsGet list of all topics in a web
( 'WebChanges', 'WebHome', 'WebIndex', 'WebNotify' )
ObjectMethod getListOfWebs ($filter) -> @webNamesGets a list of webs, filtered according to the spec in the $filter, which may include one of:
ObjectMethod createWeb ($user,$newWeb,$baseWeb,$opts)$newWeb is the name of the new web. $baseWeb is the name of an existing web (a template web). If the base web is a system web, all topics in it will be copied into the new web. If it is a normal web, only topics starting with 'Web' will be copied. If no base web is specified, an empty web (with no topics) will be created. If it is specified but does not exist, an error will be thrown. $opts is a ref to a hash that contains settings to be modified in the web preferences topic in the new web.ObjectMethod removeWeb ($user,$web)
ObjectMethod getDebugText ($meta,$text) -> $textGenerate a debug text form of the text/meta, for use in debug displays, by annotating the text with meta informtion.ObjectMethod cleanUpRevID ($rev) -> $integerCleans up (maps) a user-supplied revision ID and converts it to an integer number that can be incremented to create a new revision number. This method should be used to sanitise user-provided revision IDs.ObjectMethod copyTopic ($user,$fromweb,$fromtopic,$toweb,$totopic)Copy a topic and all it's attendant data from one web to another. SMELL: Does not fix up meta-data!ObjectMethod searchMetaData ($params) -> $textSearch meta-data associated with topics. Parameters are passed in the $params hash, which may contain:
ObjectMethod *searchInWebContent ($searchString,$web,\@topics,\%options) -> \%mapSearch for a string in the content of a web. The search must be over all content and all formatted meta-data, though the latter search type is deprecated (use searchMetaData instead).
\%options hash may contain the following options:
files_without_match is specified, it will
return on the first match in each topic (i.e. it will return only one
match per topic, and will not return matching lines).
ObjectMethod *getRevisionAtTime ($web,$topic,$time) -> $rev
ObjectMethod getLease ($web,$topic) -> $lease
user , taken and expires ).
Leases are taken out when a topic is edited. Only one lease
can be active on a topic at a time. Leases are used to warn if
another user is already editing a topic.
ObjectMethod setLease ($web,$topic,$user,$length)Take out an lease on the given topic for this user for $length seconds. SeegetLease for more details about Leases.
ObjectMethod clearLease ($web,$topic)Cancel the current lease. SeegetLease for more details about Leases.
ObjectMethod *removeSpuriousLeases ($web)Remove leases that are not related to a topic. These can get left behind in some store implementations when a topic is created, but never saved. |
Package =TWiki::StoreThis module hosts the generic storage backend. This module provides the interface layer between the "real" store provider - which is hidden behind a handler - and the rest of the system. it is responsible for checking for topic existance, access permissions, and all the other general admin tasks that are common to all store implementations. This module knows nothing about how the data is actually stored - that knowledge is entirely encapsulated in the handlers. The general contract for methods in the class requires that errors are signalled using exceptions. TWiki::AccessControlException is used for access control exceptions, and Error::Simple for all other types of error.On this page:
ClassMethod new ()Construct a Store module, linking in the chosen sub-implementation.ObjectMethod *finish | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
Complete processing after the client's HTTP request has been responded
to.
ObjectMethod readTopic ($user,$web,$topic,$version) -> ($metaObject,$text)Reads the given version of a topic and it's meta-data. If the version is undef, then read the most recent version. The version number must be an integer, or undef for the latest version. if $user is defined, view permission will be required for the topic read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user name passed in. If the topic contains a web specification (is of the form Web.Topic) the web specification will override whatever is passed in $web. The metadata and topic text are returned separately, with the metadata in a TWiki::Meta object. (The topic text is, as usual, just a string.)ObjectMethod readTopicRaw ($user,$web,$topic,$version) -> $topicTextReads the given version of a topic, without separating out any embedded meta-data. If the version is undef, then read the most recent version. The version number must be an integer or undef. If $user is defined, view permission will be required for the topic read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user name passed in. If the topic contains a web specification (is of the form Web.Topic) the web specification will override whatever is passed in $web. SMELL: DO NOT CALL THIS METHOD UNLESS YOU HAVE NO CHOICE. This method breaks encapsulation of the store, as it assumes meta is stored embedded in the text. Other implementors of store will be forced to insert meta-data to ensure correct operation of View raw=debug and the 'repRev' mode of Edit. $web and $topic must be untainted.ObjectMethod moveAttachment ($oldWeb,$oldTopic,$oldAttachment,$newWeb,$newTopic,$newAttachment,$user)Move an attachment from one topic to another. The caller to this routine should check that all topics are valid. All parameters must be defined, and must be untainted.ObjectMethod *getAttachmentStream ($user,$web,$topic,$attName) -> \*STREAM | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
ObjectMethod *getAttachmentList ($web,$topic)returns @($attachmentName => [stat]) for any given web, topicObjectMethod *attachmentExists ($web,$topic,$att) -> $booleanDetermine if the attachment already exists on the given topic | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
ObjectMethod *_removeAutoAttachmentsFromMeta | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
This is where we are going to remove from meta any entry that is marked as an automatic attachment. | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
ObjectMethod moveTopic ($oldWeb,$oldTopic,$newWeb,$newTopic,$user)All parameters must be defined and must be untainted.ObjectMethod moveWeb ($oldWeb,$newWeb,$user)Move a web. All parrameters must be defined and must be untainted.ObjectMethod readAttachment ($user,$web,$topic,$attachment,$theRev) -> $textRead the given version of an attachment, returning the content. View permission on the topic is required for the read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user passed in. If $theRev is not given, the most recent rev is assumed.ObjectMethod *getRevisionNumber ($web,$topic,$attachment) -> $integerGet the revision number of the most recent revision. Returns the integer revision number or '' if the topic doesn't exist. WORKS FOR ATTACHMENTS AS WELL AS TOPICSObjectMethod getWorkArea ($key) -> $directorypathGets a private directory uniquely identified by $key. The directory is intended as a work area for plugins. The directory will exist.ObjectMethod *getRevisionDiff ($user,$web,$topic,$rev1,$rev2,$contextLines) -> \@diffArrayReturn reference to an array of [ diffType, $right, $left ]
ObjectMethod *getRevisionInfo ($web,$topic,$rev,$attachment) -> ($date,$user,$rev,$comment) | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
Get revision info of a topic.
StaticMethod dataEncode ($uncoded) -> $coded | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
Encode meta-data fields, escaping out selected characters. The encoding
is chosen to avoid problems with parsing the attribute values, while
minimising the number of characters encoded so searches can still work
(fairly) sensibly.
The encoding has to be exported because TWiki (and plugins) use
encoded field data in other places e.g. RDiff, mainly as a shorthand
for the properly parsed meta object. Some day we may be able to
eliminate that....
StaticMethod dataDecode ($encoded) -> $decoded | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
Decode escapes in a string that was encoded using dataEncode
The encoding has to be exported because TWiki (and plugins) use
encoded field data in other places e.g. RDiff, mainly as a shorthand
for the properly parsed meta object. Some day we may be able to
eliminate that....
ObjectMethod saveTopic ($user,$web,$topic,$text,$meta,$options) | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
$options may include:
ObjectMethod saveAttachment ($web,$topic,$attachment,$user,$opts) | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
$opts may include:
ObjectMethod repRev ($user,$web,$topic,$text,$meta,$options) | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
Replace last (top) revision with different text.
Parameters and return value as saveTopic, except
| |||||||||||||||||
Added: | |||||||||||||||||
> > |
| ||||||||||||||||
Used to try to avoid the deposition of 'unecessary' revisions, for example
where a user quickly goes back and fixes a spelling error.
Also provided as a means for administrators to rewrite history (timetravel).
It is up to the store implementation if this is different
to a normal save or not.
ObjectMethod delRev ($user,$web,$topic,$text,$meta,$options)Parameters and return value as saveTopic. Provided as a means for administrators to rewrite history. Delete last entry in repository, restoring the previous revision. It is up to the store implementation whether this actually does delete a revision or not; some implementations will simply promote the previous revision up to the head.ObjectMethod lockTopic ($web,$topic)Grab a topic lock on the given topic. A topic lock will cause other processes that also try to claim a lock to block. A lock has a maximum lifetime of 2 minutes, so operations on a locked topic must be completed within that time. You cannot rely on the lock timeout clearing the lock, though; that should always be done by calling unlockTopic. The best thing to do is to guard the locked section with a try..finally clause. See man Error for more info. Topic locks are used to make store operations atomic. They are note the locks used when a topic is edited; those are Leases (seegetLease )
ObjectMethod unlockTopic ($user,$web,$topic) | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
Release the topic lock on the given topic. A topic lock will cause other
processes that also try to claim a lock to block. It is important to
release a topic lock after a guard section is complete. This should
normally be done in a 'finally' block. See man Error for more info.
Topic locks are used to make store operations atomic. They are
note the locks used when a topic is edited; those are Leases
(see getLease )
ObjectMethod webExists ($web) -> $booleanTest if web exists
ObjectMethod topicExists ($web,$topic) -> $booleanTest if topic exists
ObjectMethod getTopicParent ($web,$topic) -> $stringGet the name of the topic parent. Needs to be fast because of use by Render.pm.ObjectMethod *getTopicLatestRevTime ($web,$topic) -> $epochSecsGet an approximate rev time for the latest rev of the topic. This method is used to optimise searching. Needs to be as fast as possible.ObjectMethod readMetaData ($web,$name) -> $textRead a named meta-data string. If web is given the meta-data is stored alongside a web.ObjectMethod saveMetaData ($web,$name) -> $textWrite a named meta-data string. If web is given the meta-data is stored alongside a web.ObjectMethod getTopicNames ($web) -> @topicsGet list of all topics in a web
( 'WebChanges', 'WebHome', 'WebIndex', 'WebNotify' )
ObjectMethod getListOfWebs ($filter) -> @webNamesGets a list of webs, filtered according to the spec in the $filter, which may include one of:
ObjectMethod createWeb ($user,$newWeb,$baseWeb,$opts)$newWeb is the name of the new web. $baseWeb is the name of an existing web (a template web). If the base web is a system web, all topics in it will be copied into the new web. If it is a normal web, only topics starting with 'Web' will be copied. If no base web is specified, an empty web (with no topics) will be created. If it is specified but does not exist, an error will be thrown. $opts is a ref to a hash that contains settings to be modified in the web preferences topic in the new web.ObjectMethod removeWeb ($user,$web) | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
ObjectMethod getDebugText ($meta,$text) -> $textGenerate a debug text form of the text/meta, for use in debug displays, by annotating the text with meta informtion.ObjectMethod cleanUpRevID ($rev) -> $integerCleans up (maps) a user-supplied revision ID and converts it to an integer number that can be incremented to create a new revision number. This method should be used to sanitise user-provided revision IDs.ObjectMethod copyTopic ($user,$fromweb,$fromtopic,$toweb,$totopic) | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
Copy a topic and all it's attendant data from one web to another.
SMELL: Does not fix up meta-data!
ObjectMethod searchMetaData ($params) -> $textSearch meta-data associated with topics. Parameters are passed in the $params hash, which may contain:
ObjectMethod *searchInWebContent ($searchString,$web,\@topics,\%options) -> \%mapSearch for a string in the content of a web. The search must be over all content and all formatted meta-data, though the latter search type is deprecated (use searchMetaData instead).
\%options hash may contain the following options:
files_without_match is specified, it will
return on the first match in each topic (i.e. it will return only one
match per topic, and will not return matching lines).
ObjectMethod *getRevisionAtTime ($web,$topic,$time) -> $rev | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
ObjectMethod getLease ($web,$topic) -> $lease | |||||||||||||||||
Added: | |||||||||||||||||
> > | |||||||||||||||||
user , taken and expires ).
Leases are taken out when a topic is edited. Only one lease
can be active on a topic at a time. Leases are used to warn if
another user is already editing a topic.
ObjectMethod setLease ($web,$topic,$user,$length)Take out an lease on the given topic for this user for $length seconds. SeegetLease for more details about Leases.
ObjectMethod clearLease ($web,$topic)Cancel the current lease. SeegetLease for more details about Leases. | |||||||||||||||||
Added: | |||||||||||||||||
> > |
ObjectMethod *removeSpuriousLeases ($web)Remove leases that are not related to a topic. These can get left behind in some store implementations when a topic is created, but never saved. | ||||||||||||||||
Package =TWiki::StoreThis module hosts the generic storage backend. This module provides the interface layer between the "real" store provider - which is hidden behind a handler - and the rest of the system. it is responsible for checking for topic existance, access permissions, and all the other general admin tasks that are common to all store implementations. This module knows nothing about how the data is actually stored - that knowledge is entirely encapsulated in the handlers. The general contract for methods in the class requires that errors are signalled using exceptions. TWiki::AccessControlException is used for access control exceptions, and Error::Simple for all other types of error.On this page:
ClassMethod new ()Construct a Store module, linking in the chosen sub-implementation. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | ObjectMethod *finishComplete processing after the client's HTTP request has been responded to.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
ObjectMethod readTopic ($user,$web,$topic,$version) -> ($metaObject,$text)Reads the given version of a topic and it's meta-data. If the version is undef, then read the most recent version. The version number must be an integer, or undef for the latest version. if $user is defined, view permission will be required for the topic read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user name passed in. If the topic contains a web specification (is of the form Web.Topic) the web specification will override whatever is passed in $web. The metadata and topic text are returned separately, with the metadata in a TWiki::Meta object. (The topic text is, as usual, just a string.)ObjectMethod readTopicRaw ($user,$web,$topic,$version) -> $topicTextReads the given version of a topic, without separating out any embedded meta-data. If the version is undef, then read the most recent version. The version number must be an integer or undef. If $user is defined, view permission will be required for the topic read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user name passed in. If the topic contains a web specification (is of the form Web.Topic) the web specification will override whatever is passed in $web. SMELL: DO NOT CALL THIS METHOD UNLESS YOU HAVE NO CHOICE. This method breaks encapsulation of the store, as it assumes meta is stored embedded in the text. Other implementors of store will be forced to insert meta-data to ensure correct operation of View raw=debug and the 'repRev' mode of Edit. $web and $topic must be untainted.ObjectMethod moveAttachment ($oldWeb,$oldTopic,$oldAttachment,$newWeb,$newTopic,$newAttachment,$user)Move an attachment from one topic to another. The caller to this routine should check that all topics are valid. All parameters must be defined, and must be untainted.ObjectMethod *getAttachmentStream ($user,$web,$topic,$attName) -> \*STREAM
ObjectMethod *getAttachmentList ($web,$topic)returns @($attachmentName => [stat]) for any given web, topicObjectMethod *attachmentExists ($web,$topic,$att) -> $booleanDetermine if the attachment already exists on the given topicObjectMethod *_removeAutoAttachmentsFromMetaThis is where we are going to remove from meta any entry that is marked as an automatic attachment.ObjectMethod moveTopic ($oldWeb,$oldTopic,$newWeb,$newTopic,$user)All parameters must be defined and must be untainted.ObjectMethod moveWeb ($oldWeb,$newWeb,$user)Move a web. All parrameters must be defined and must be untainted.ObjectMethod readAttachment ($user,$web,$topic,$attachment,$theRev) -> $textRead the given version of an attachment, returning the content. View permission on the topic is required for the read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user passed in. If $theRev is not given, the most recent rev is assumed.ObjectMethod *getRevisionNumber ($web,$topic,$attachment) -> $integerGet the revision number of the most recent revision. Returns the integer revision number or '' if the topic doesn't exist. WORKS FOR ATTACHMENTS AS WELL AS TOPICSObjectMethod getWorkArea ($key) -> $directorypathGets a private directory uniquely identified by $key. The directory is intended as a work area for plugins. The directory will exist.ObjectMethod *getRevisionDiff ($user,$web,$topic,$rev1,$rev2,$contextLines) -> \@diffArrayReturn reference to an array of [ diffType, $right, $left ]
ObjectMethod *getRevisionInfo ($web,$topic,$rev,$attachment) -> ($date,$user,$rev,$comment)Get revision info of a topic.
StaticMethod dataEncode ($uncoded) -> $codedEncode meta-data fields, escaping out selected characters. The encoding is chosen to avoid problems with parsing the attribute values, while minimising the number of characters encoded so searches can still work (fairly) sensibly. The encoding has to be exported because TWiki (and plugins) use encoded field data in other places e.g. RDiff, mainly as a shorthand for the properly parsed meta object. Some day we may be able to eliminate that....StaticMethod dataDecode ($encoded) -> $decodedDecode escapes in a string that was encoded using dataEncode The encoding has to be exported because TWiki (and plugins) use encoded field data in other places e.g. RDiff, mainly as a shorthand for the properly parsed meta object. Some day we may be able to eliminate that....ObjectMethod saveTopic ($user,$web,$topic,$text,$meta,$options)
$options may include:
ObjectMethod saveAttachment ($web,$topic,$attachment,$user,$opts)
$opts may include:
ObjectMethod repRev ($user,$web,$topic,$text,$meta,$options)Replace last (top) revision with different text. Parameters and return value as saveTopic, except
ObjectMethod delRev ($user,$web,$topic,$text,$meta,$options)Parameters and return value as saveTopic. Provided as a means for administrators to rewrite history. Delete last entry in repository, restoring the previous revision. It is up to the store implementation whether this actually does delete a revision or not; some implementations will simply promote the previous revision up to the head.ObjectMethod lockTopic ($web,$topic)Grab a topic lock on the given topic. A topic lock will cause other processes that also try to claim a lock to block. A lock has a maximum lifetime of 2 minutes, so operations on a locked topic must be completed within that time. You cannot rely on the lock timeout clearing the lock, though; that should always be done by calling unlockTopic. The best thing to do is to guard the locked section with a try..finally clause. See man Error for more info. Topic locks are used to make store operations atomic. They are note the locks used when a topic is edited; those are Leases (seegetLease )
ObjectMethod unlockTopic ($user,$web,$topic)Release the topic lock on the given topic. A topic lock will cause other processes that also try to claim a lock to block. It is important to release a topic lock after a guard section is complete. This should normally be done in a 'finally' block. See man Error for more info. Topic locks are used to make store operations atomic. They are note the locks used when a topic is edited; those are Leases (seegetLease )
ObjectMethod webExists ($web) -> $booleanTest if web exists
ObjectMethod topicExists ($web,$topic) -> $booleanTest if topic exists
ObjectMethod getTopicParent ($web,$topic) -> $stringGet the name of the topic parent. Needs to be fast because of use by Render.pm.ObjectMethod *getTopicLatestRevTime ($web,$topic) -> $epochSecsGet an approximate rev time for the latest rev of the topic. This method is used to optimise searching. Needs to be as fast as possible.ObjectMethod readMetaData ($web,$name) -> $textRead a named meta-data string. If web is given the meta-data is stored alongside a web.ObjectMethod saveMetaData ($web,$name) -> $textWrite a named meta-data string. If web is given the meta-data is stored alongside a web.ObjectMethod getTopicNames ($web) -> @topicsGet list of all topics in a web
( 'WebChanges', 'WebHome', 'WebIndex', 'WebNotify' )
ObjectMethod getListOfWebs ($filter) -> @webNamesGets a list of webs, filtered according to the spec in the $filter, which may include one of:
ObjectMethod createWeb ($user,$newWeb,$baseWeb,$opts)$newWeb is the name of the new web. $baseWeb is the name of an existing web (a template web). If the base web is a system web, all topics in it will be copied into the new web. If it is a normal web, only topics starting with 'Web' will be copied. If no base web is specified, an empty web (with no topics) will be created. If it is specified but does not exist, an error will be thrown. $opts is a ref to a hash that contains settings to be modified in the web preferences topic in the new web.ObjectMethod removeWeb ($user,$web)
ObjectMethod getDebugText ($meta,$text) -> $textGenerate a debug text form of the text/meta, for use in debug displays, by annotating the text with meta informtion.ObjectMethod cleanUpRevID ($rev) -> $integerCleans up (maps) a user-supplied revision ID and converts it to an integer number that can be incremented to create a new revision number. This method should be used to sanitise user-provided revision IDs.ObjectMethod copyTopic ($user,$fromweb,$fromtopic,$toweb,$totopic)Copy a topic and all it's attendant data from one web to another. SMELL: Does not fix up meta-data!ObjectMethod searchMetaData ($params) -> $textSearch meta-data associated with topics. Parameters are passed in the $params hash, which may contain:
ObjectMethod *searchInWebContent ($searchString,$web,\@topics,\%options) -> \%mapSearch for a string in the content of a web. The search must be over all content and all formatted meta-data, though the latter search type is deprecated (use searchMetaData instead).
\%options hash may contain the following options:
files_without_match is specified, it will
return on the first match in each topic (i.e. it will return only one
match per topic, and will not return matching lines).
ObjectMethod *getRevisionAtTime ($web,$topic,$time) -> $rev
ObjectMethod getLease ($web,$topic) -> $lease
user , taken and expires ).
Leases are taken out when a topic is edited. Only one lease
can be active on a topic at a time. Leases are used to warn if
another user is already editing a topic.
ObjectMethod setLease ($web,$topic,$user,$length)Take out an lease on the given topic for this user for $length seconds. SeegetLease for more details about Leases.
ObjectMethod clearLease ($web,$topic)Cancel the current lease. SeegetLease for more details about Leases.
|
Package =TWiki::StoreThis module hosts the generic storage backend. This module provides the interface layer between the "real" store provider - which is hidden behind a handler - and the rest of the system. it is responsible for checking for topic existance, access permissions, and all the other general admin tasks that are common to all store implementations. This module knows nothing about how the data is actually stored - that knowledge is entirely encapsulated in the handlers. The general contract for methods in the class requires that errors are signalled using exceptions. TWiki::AccessControlException is used for access control exceptions, and Error::Simple for all other types of error.On this page:
ClassMethod new ()Construct a Store module, linking in the chosen sub-implementation.ObjectMethod readTopic ($user,$web,$topic,$version) -> ($metaObject,$text)Reads the given version of a topic and it's meta-data. If the version is undef, then read the most recent version. The version number must be an integer, or undef for the latest version. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | If $user is defined, view permission will be required for the topic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | if $user is defined, view permission will be required for the topic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
read to be successful. Access control violations are flagged by a
TWiki::AccessControlException. Permissions are checked for the user
name passed in.
If the topic contains a web specification (is of the form Web.Topic) the
web specification will override whatever is passed in $web.
The metadata and topic text are returned separately, with the metadata in a
TWiki::Meta object. (The topic text is, as usual, just a string.)
ObjectMethod readTopicRaw ($user,$web,$topic,$version) -> $topicTextReads the given version of a topic, without separating out any embedded meta-data. If the version is undef, then read the most recent version. The version number must be an integer or undef. If $user is defined, view permission will be required for the topic read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user name passed in. If the topic contains a web specification (is of the form Web.Topic) the web specification will override whatever is passed in $web. SMELL: DO NOT CALL THIS METHOD UNLESS YOU HAVE NO CHOICE. This method breaks encapsulation of the store, as it assumes meta is stored embedded in the text. Other implementors of store will be forced to insert meta-data to ensure correct operation of View raw=debug and the 'repRev' mode of Edit. $web and $topic must be untainted.ObjectMethod moveAttachment ($oldWeb,$oldTopic,$oldAttachment,$newWeb,$newTopic,$newAttachment,$user)Move an attachment from one topic to another. The caller to this routine should check that all topics are valid. All parameters must be defined, and must be untainted.ObjectMethod *getAttachmentStream ($user,$web,$topic,$attName) -> \*STREAM
ObjectMethod *getAttachmentList ($web,$topic)returns @($attachmentName => [stat]) for any given web, topicObjectMethod *attachmentExists ($web,$topic,$att) -> $booleanDetermine if the attachment already exists on the given topicObjectMethod *_removeAutoAttachmentsFromMetaThis is where we are going to remove from meta any entry that is marked as an automatic attachment.ObjectMethod moveTopic ($oldWeb,$oldTopic,$newWeb,$newTopic,$user)All parameters must be defined and must be untainted.ObjectMethod moveWeb ($oldWeb,$newWeb,$user)Move a web. All parrameters must be defined and must be untainted.ObjectMethod readAttachment ($user,$web,$topic,$attachment,$theRev) -> $textRead the given version of an attachment, returning the content. View permission on the topic is required for the read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user passed in. If $theRev is not given, the most recent rev is assumed.ObjectMethod *getRevisionNumber ($web,$topic,$attachment) -> $integerGet the revision number of the most recent revision. Returns the integer revision number or '' if the topic doesn't exist. WORKS FOR ATTACHMENTS AS WELL AS TOPICSObjectMethod getWorkArea ($key) -> $directorypathGets a private directory uniquely identified by $key. The directory is intended as a work area for plugins. The directory will exist. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | ObjectMethod *getRevisionDiff ($web,$topic,$rev1,$rev2,$contextLines) -> \@diffArray | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | ObjectMethod *getRevisionDiff ($user,$web,$topic,$rev1,$rev2,$contextLines) -> \@diffArray | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Return reference to an array of [ diffType, $right, $left ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
ObjectMethod *getRevisionInfo ($web,$topic,$rev,$attachment) -> ($date,$user,$rev,$comment)Get revision info of a topic.
StaticMethod dataEncode ($uncoded) -> $codedEncode meta-data fields, escaping out selected characters. The encoding is chosen to avoid problems with parsing the attribute values, while minimising the number of characters encoded so searches can still work (fairly) sensibly. The encoding has to be exported because TWiki (and plugins) use encoded field data in other places e.g. RDiff, mainly as a shorthand for the properly parsed meta object. Some day we may be able to eliminate that....StaticMethod dataDecode ($encoded) -> $decodedDecode escapes in a string that was encoded using dataEncode The encoding has to be exported because TWiki (and plugins) use encoded field data in other places e.g. RDiff, mainly as a shorthand for the properly parsed meta object. Some day we may be able to eliminate that....ObjectMethod saveTopic ($user,$web,$topic,$text,$meta,$options)
$options may include:
ObjectMethod saveAttachment ($web,$topic,$attachment,$user,$opts)
$opts may include:
ObjectMethod repRev ($user,$web,$topic,$text,$meta,$options)Replace last (top) revision with different text. Parameters and return value as saveTopic, except
ObjectMethod delRev ($user,$web,$topic,$text,$meta,$options)Parameters and return value as saveTopic. Provided as a means for administrators to rewrite history. Delete last entry in repository, restoring the previous revision. It is up to the store implementation whether this actually does delete a revision or not; some implementations will simply promote the previous revision up to the head.ObjectMethod lockTopic ($web,$topic)Grab a topic lock on the given topic. A topic lock will cause other processes that also try to claim a lock to block. A lock has a maximum lifetime of 2 minutes, so operations on a locked topic must be completed within that time. You cannot rely on the lock timeout clearing the lock, though; that should always be done by calling unlockTopic. The best thing to do is to guard the locked section with a try..finally clause. See man Error for more info. Topic locks are used to make store operations atomic. They are note the locks used when a topic is edited; those are Leases (seegetLease )
ObjectMethod unlockTopic ($user,$web,$topic)Release the topic lock on the given topic. A topic lock will cause other processes that also try to claim a lock to block. It is important to release a topic lock after a guard section is complete. This should normally be done in a 'finally' block. See man Error for more info. Topic locks are used to make store operations atomic. They are note the locks used when a topic is edited; those are Leases (seegetLease )
ObjectMethod webExists ($web) -> $booleanTest if web exists
ObjectMethod topicExists ($web,$topic) -> $booleanTest if topic exists
ObjectMethod getTopicParent ($web,$topic) -> $stringGet the name of the topic parent. Needs to be fast because of use by Render.pm.ObjectMethod *getTopicLatestRevTime ($web,$topic) -> $epochSecsGet an approximate rev time for the latest rev of the topic. This method is used to optimise searching. Needs to be as fast as possible.ObjectMethod readMetaData ($web,$name) -> $textRead a named meta-data string. If web is given the meta-data is stored alongside a web.ObjectMethod saveMetaData ($web,$name) -> $textWrite a named meta-data string. If web is given the meta-data is stored alongside a web.ObjectMethod getTopicNames ($web) -> @topicsGet list of all topics in a web
( 'WebChanges', 'WebHome', 'WebIndex', 'WebNotify' )
ObjectMethod getListOfWebs ($filter) -> @webNamesGets a list of webs, filtered according to the spec in the $filter, which may include one of:
ObjectMethod createWeb ($user,$newWeb,$baseWeb,$opts)$newWeb is the name of the new web. $baseWeb is the name of an existing web (a template web). If the base web is a system web, all topics in it will be copied into the new web. If it is a normal web, only topics starting with 'Web' will be copied. If no base web is specified, an empty web (with no topics) will be created. If it is specified but does not exist, an error will be thrown. $opts is a ref to a hash that contains settings to be modified in the web preferences topic in the new web.ObjectMethod removeWeb ($user,$web)
ObjectMethod getDebugText ($meta,$text) -> $textGenerate a debug text form of the text/meta, for use in debug displays, by annotating the text with meta informtion.ObjectMethod cleanUpRevID ($rev) -> $integerCleans up (maps) a user-supplied revision ID and converts it to an integer number that can be incremented to create a new revision number. This method should be used to sanitise user-provided revision IDs.ObjectMethod copyTopic ($user,$fromweb,$fromtopic,$toweb,$totopic)Copy a topic and all it's attendant data from one web to another. SMELL: Does not fix up meta-data!ObjectMethod searchMetaData ($params) -> $textSearch meta-data associated with topics. Parameters are passed in the $params hash, which may contain:
ObjectMethod *searchInWebContent ($searchString,$web,\@topics,\%options) -> \%mapSearch for a string in the content of a web. The search must be over all content and all formatted meta-data, though the latter search type is deprecated (use searchMetaData instead).
\%options hash may contain the following options:
files_without_match is specified, it will
return on the first match in each topic (i.e. it will return only one
match per topic, and will not return matching lines).
ObjectMethod *getRevisionAtTime ($web,$topic,$time) -> $rev
ObjectMethod getLease ($web,$topic) -> $lease
user , taken and expires ).
Leases are taken out when a topic is edited. Only one lease
can be active on a topic at a time. Leases are used to warn if
another user is already editing a topic.
ObjectMethod setLease ($web,$topic,$user,$length)Take out an lease on the given topic for this user for $length seconds. SeegetLease for more details about Leases.
ObjectMethod clearLease ($web,$topic)Cancel the current lease. SeegetLease for more details about Leases.
|
Package =TWiki::StoreThis module hosts the generic storage backend. This module provides the interface layer between the "real" store provider - which is hidden behind a handler - and the rest of the system. it is responsible for checking for topic existance, access permissions, and all the other general admin tasks that are common to all store implementations. This module knows nothing about how the data is actually stored - that knowledge is entirely encapsulated in the handlers. The general contract for methods in the class requires that errors are signalled using exceptions. TWiki::AccessControlException is used for access control exceptions, and Error::Simple for all other types of error.On this page:
ClassMethod new ()Construct a Store module, linking in the chosen sub-implementation.ObjectMethod readTopic ($user,$web,$topic,$version) -> ($metaObject,$text)Reads the given version of a topic and it's meta-data. If the version is undef, then read the most recent version. The version number must be an integer, or undef for the latest version. If $user is defined, view permission will be required for the topic read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user name passed in. If the topic contains a web specification (is of the form Web.Topic) the web specification will override whatever is passed in $web. The metadata and topic text are returned separately, with the metadata in a TWiki::Meta object. (The topic text is, as usual, just a string.)ObjectMethod readTopicRaw ($user,$web,$topic,$version) -> $topicTextReads the given version of a topic, without separating out any embedded meta-data. If the version is undef, then read the most recent version. The version number must be an integer or undef. If $user is defined, view permission will be required for the topic read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user name passed in. If the topic contains a web specification (is of the form Web.Topic) the web specification will override whatever is passed in $web. SMELL: DO NOT CALL THIS METHOD UNLESS YOU HAVE NO CHOICE. This method breaks encapsulation of the store, as it assumes meta is stored embedded in the text. Other implementors of store will be forced to insert meta-data to ensure correct operation of View raw=debug and the 'repRev' mode of Edit. $web and $topic must be untainted.ObjectMethod moveAttachment ($oldWeb,$oldTopic,$oldAttachment,$newWeb,$newTopic,$newAttachment,$user)Move an attachment from one topic to another. The caller to this routine should check that all topics are valid. All parameters must be defined, and must be untainted.ObjectMethod *getAttachmentStream ($user,$web,$topic,$attName) -> \*STREAM
ObjectMethod *getAttachmentList ($web,$topic)returns @($attachmentName => [stat]) for any given web, topicObjectMethod *attachmentExists ($web,$topic,$att) -> $booleanDetermine if the attachment already exists on the given topicObjectMethod *_removeAutoAttachmentsFromMetaThis is where we are going to remove from meta any entry that is marked as an automatic attachment.ObjectMethod moveTopic ($oldWeb,$oldTopic,$newWeb,$newTopic,$user)All parameters must be defined and must be untainted.ObjectMethod moveWeb ($oldWeb,$newWeb,$user)Move a web. All parrameters must be defined and must be untainted.ObjectMethod readAttachment ($user,$web,$topic,$attachment,$theRev) -> $textRead the given version of an attachment, returning the content. View permission on the topic is required for the read to be successful. Access control violations are flagged by a TWiki::AccessControlException. Permissions are checked for the user passed in. If $theRev is not given, the most recent rev is assumed.ObjectMethod *getRevisionNumber ($web,$topic,$attachment) -> $integerGet the revision number of the most recent revision. Returns the integer revision number or '' if the topic doesn't exist. WORKS FOR ATTACHMENTS AS WELL AS TOPICSObjectMethod getWorkArea ($key) -> $directorypathGets a private directory uniquely identified by $key. The directory is intended as a work area for plugins. The directory will exist.ObjectMethod *getRevisionDiff ($web,$topic,$rev1,$rev2,$contextLines) -> \@diffArrayReturn reference to an array of [ diffType, $right, $left ]
ObjectMethod *getRevisionInfo ($web,$topic,$rev,$attachment) -> ($date,$user,$rev,$comment)Get revision info of a topic.
StaticMethod dataEncode ($uncoded) -> $codedEncode meta-data fields, escaping out selected characters. The encoding is chosen to avoid problems with parsing the attribute values, while minimising the number of characters encoded so searches can still work (fairly) sensibly. The encoding has to be exported because TWiki (and plugins) use encoded field data in other places e.g. RDiff, mainly as a shorthand for the properly parsed meta object. Some day we may be able to eliminate that....StaticMethod dataDecode ($encoded) -> $decodedDecode escapes in a string that was encoded using dataEncode The encoding has to be exported because TWiki (and plugins) use encoded field data in other places e.g. RDiff, mainly as a shorthand for the properly parsed meta object. Some day we may be able to eliminate that....ObjectMethod saveTopic ($user,$web,$topic,$text,$meta,$options)
$options may include:
ObjectMethod saveAttachment ($web,$topic,$attachment,$user,$opts)
$opts may include:
ObjectMethod repRev ($user,$web,$topic,$text,$meta,$options)Replace last (top) revision with different text. Parameters and return value as saveTopic, except
ObjectMethod delRev ($user,$web,$topic,$text,$meta,$options)Parameters and return value as saveTopic. Provided as a means for administrators to rewrite history. Delete last entry in repository, restoring the previous revision. It is up to the store implementation whether this actually does delete a revision or not; some implementations will simply promote the previous revision up to the head.ObjectMethod lockTopic ($web,$topic)Grab a topic lock on the given topic. A topic lock will cause other processes that also try to claim a lock to block. A lock has a maximum lifetime of 2 minutes, so operations on a locked topic must be completed within that time. You cannot rely on the lock timeout clearing the lock, though; that should always be done by calling unlockTopic. The best thing to do is to guard the locked section with a try..finally clause. See man Error for more info. Topic locks are used to make store operations atomic. They are note the locks used when a topic is edited; those are Leases (seegetLease )
ObjectMethod unlockTopic ($user,$web,$topic)Release the topic lock on the given topic. A topic lock will cause other processes that also try to claim a lock to block. It is important to release a topic lock after a guard section is complete. This should normally be done in a 'finally' block. See man Error for more info. Topic locks are used to make store operations atomic. They are note the locks used when a topic is edited; those are Leases (seegetLease )
ObjectMethod webExists ($web) -> $booleanTest if web exists
ObjectMethod topicExists ($web,$topic) -> $booleanTest if topic exists
ObjectMethod getTopicParent ($web,$topic) -> $stringGet the name of the topic parent. Needs to be fast because of use by Render.pm.ObjectMethod *getTopicLatestRevTime ($web,$topic) -> $epochSecsGet an approximate rev time for the latest rev of the topic. This method is used to optimise searching. Needs to be as fast as possible.ObjectMethod readMetaData ($web,$name) -> $textRead a named meta-data string. If web is given the meta-data is stored alongside a web.ObjectMethod saveMetaData ($web,$name) -> $textWrite a named meta-data string. If web is given the meta-data is stored alongside a web.ObjectMethod getTopicNames ($web) -> @topicsGet list of all topics in a web
( 'WebChanges', 'WebHome', 'WebIndex', 'WebNotify' )
ObjectMethod getListOfWebs ($filter) -> @webNamesGets a list of webs, filtered according to the spec in the $filter, which may include one of:
ObjectMethod createWeb ($user,$newWeb,$baseWeb,$opts)$newWeb is the name of the new web. $baseWeb is the name of an existing web (a template web). If the base web is a system web, all topics in it will be copied into the new web. If it is a normal web, only topics starting with 'Web' will be copied. If no base web is specified, an empty web (with no topics) will be created. If it is specified but does not exist, an error will be thrown. $opts is a ref to a hash that contains settings to be modified in the web preferences topic in the new web.ObjectMethod removeWeb ($user,$web)
ObjectMethod getDebugText ($meta,$text) -> $textGenerate a debug text form of the text/meta, for use in debug displays, by annotating the text with meta informtion.ObjectMethod cleanUpRevID ($rev) -> $integerCleans up (maps) a user-supplied revision ID and converts it to an integer number that can be incremented to create a new revision number. This method should be used to sanitise user-provided revision IDs.ObjectMethod copyTopic ($user,$fromweb,$fromtopic,$toweb,$totopic)Copy a topic and all it's attendant data from one web to another. SMELL: Does not fix up meta-data!ObjectMethod searchMetaData ($params) -> $textSearch meta-data associated with topics. Parameters are passed in the $params hash, which may contain:
ObjectMethod *searchInWebContent ($searchString,$web,\@topics,\%options) -> \%mapSearch for a string in the content of a web. The search must be over all content and all formatted meta-data, though the latter search type is deprecated (use searchMetaData instead).
\%options hash may contain the following options:
files_without_match is specified, it will
return on the first match in each topic (i.e. it will return only one
match per topic, and will not return matching lines).
ObjectMethod *getRevisionAtTime ($web,$topic,$time) -> $rev
ObjectMethod getLease ($web,$topic) -> $lease
user , taken and expires ).
Leases are taken out when a topic is edited. Only one lease
can be active on a topic at a time. Leases are used to warn if
another user is already editing a topic.
ObjectMethod setLease ($web,$topic,$user,$length)Take out an lease on the given topic for this user for $length seconds. SeegetLease for more details about Leases.
ObjectMethod clearLease ($web,$topic)Cancel the current lease. SeegetLease for more details about Leases.
|