Item9431: Support " formatting token

pencil
Priority: Enhancement
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: DBCachePlugin
Branches:
Reported By: AntonioTerceiro
Waiting For:
Last Change By: AntonioTerceiro
In the quest for providing an interface almost compatible with %SEARCH, we also need a $quot formatting token. It's trivial do add it.

-- AntonioTerceiro - 03 Aug 2010

I think MichaelDaum prefers \" - but I agree, it would be nice. Set as enhancement

-- PaulHarvey - 04 Aug 2010

Proposed change:

Index: lib/Foswiki/Plugins/DBCachePlugin/Core.pm
===================================================================
--- lib/Foswiki/Plugins/DBCachePlugin/Core.pm (revision 9120)
+++ lib/Foswiki/Plugins/DBCachePlugin/Core.pm (working copy)
@@ -1373,6 +1373,8 @@
   $theFormat =~ s/\$trunc\((.*?),\s*(\d+)\)/substr($1,0,$2)/ges;
   $theFormat =~ s/\$t\b/\t/go;
   $theFormat =~ s/\$dollar/\$/go;
+  $theFormat =~ s/\$quot/"/go;
+  $theFormat =~ s/\\"/"/go;
   $theFormat =~ s/${TranslationToken2}//go;

   return $theFormat;
Index: data/System/DBCachePlugin.txt
===================================================================
--- data/System/DBCachePlugin.txt (revision 9120)
+++ data/System/DBCachePlugin.txt (working copy)
@@ -136,6 +136,7 @@
    * $dollar: $ sign
    * $n: newline
    * $percnt: % sign
+   * $quot (or <code>\"</code>): " sign
 Example:
 <verbatim>%ATTACHMENTS{format="| $name: | $type |"}%</verbatim>
 generates:
@@ -199,6 +200,7 @@
 Following variables are expanded in format strings:
    * $percnt: % sign
    * $dollar: $ sign
+   * $quot (or <code>\"</code>): " sign
    * $n: newline
    * $nop: "empty string"
    * $count: the number of hits
@@ -280,6 +282,7 @@

 All format strings may contain the following variables:
    * $dollar: $ sign
+   * $quot (or <code>\"</code>): " sign
    * $n: newline
    * $percnt: % sign

-- AntonioTerceiro - 16 Sep 2010

My problem is:

I have one topic, which I want to reuse, that contains %DBQUERY{ ... format="" ...}%. I use it by doing %INCLUDE{"ReusableTopic" FORMAT="..."}%

When FORMAT needs to include quotes, as in FORMAT="$percntINCLUDE{\"OtherTopic\" ARG=\"\"}$percnt", then I have a problem. Those escaped quotes are unescaped during the processing of INCLUDE, and that breaks my DBQUERY call. The only way I could make it work was by hacking DBCachePlugin to also support $quot.

-- AntonioTerceiro - 16 Sep 2010

I do not use this extension so I personally do not care but I can say that there are indeed cases where you nest more than once where I have not been able to use \" in SEARCH

And also it seems silly not to support exact same tokens as SEARCH when the extensions has the purpose of being a replacement of search . I cannot understand the religious cruft argument

-- KennethLavrsen - 16 Sep 2010

ok, expliciting handling \" there was a misunderstanding (just striked in the proposed patch above). But supporting $qout would really be useful and help everyone that want to migrate heavy SEARCH'es to DBQUERY.

-- AntonioTerceiro - 16 Sep 2010

Gosh, Kenneth, back off. Another subterranean utterance.

Antonio, I see your use case now. Feel free to checkin. Thanks.

-- MichaelDaum - 17 Sep 2010

Might it be better to simply apply Foswiki::Func::decodeFormatTokens() ?

-- PaulHarvey - 17 Sep 2010

Checked in the patch as above.

Paul, I didn't apply Foswiki::Func::decodeFormatTokens() because that would add a lot more formatting tokens that we did not discuss here.

-- AntonioTerceiro - 06 Oct 2010
 

ItemTemplate edit

Summary Support $quot formatting token
ReportedBy AntonioTerceiro
Codebase
SVN Range
AppliesTo Extension
Component DBCachePlugin
Priority Enhancement
CurrentState Closed
WaitingFor
Checkins DBCachePlugin:1e9d01573deb
TargetRelease n/a
ReleasedIn n/a
Topic revision: r8 - 06 Oct 2010, AntonioTerceiro
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy