File: contents.html

package info (click to toggle)
sqlkit 0.9.5-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 8,184 kB
  • sloc: python: 17,477; sql: 166; makefile: 95; xml: 23; sh: 11
file content (730 lines) | stat: -rw-r--r-- 34,343 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      
      <title>
    Printing
 &mdash; sqlkit v0.9.5 documentation</title>
      
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../_static/sqlkit.css" type="text/css" />
    <link rel="stylesheet" href="../_static/print.css" type="text/css" media="print" />

    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="top" title="sqlkit v0.9.5 documentation" href="../index.html" />
        <link rel="up" title="SQLKit" href="../sqlkit/contents.html" />
        <link rel="next" title="Sqlkit &amp; Sqledit" href="../misc/tour.html" />
        <link rel="prev" title="Field Widgets" href="../sqlkit/advanced/field_widgets.html" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
          URL_ROOT:    '../',
          VERSION:     '0.9.5',
          COLLAPSE_MODINDEX: false,
          FILE_SUFFIX: '.html'
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>


<!-- <link rel="stylesheet" href="http://www.myjqueryplugins.com/plugins/jmenu/demo/jquery/jMenu.jquery.css" type="text/css" /> -->
      <link rel="stylesheet" href="../_static/jMenu.jquery.css" type="text/css" />
      <script type="text/javascript" src="http://www.myjqueryplugins.com/plugins/jmenu/demo/jquery/jquery.js"></script>
      <script type="text/javascript" src="http://www.myjqueryplugins.com/plugins/jmenu/demo/jquery/jquery-ui.js"></script>

      <!-- <script type="text/javascript" src="http://www.myjqueryplugins.com/plugins/jmenu/demo/jquery/jMenu.jquery.js"></script> -->

      <script type="text/javascript">

	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', 'UA-18221996-2']);
	_gaq.push(['_trackPageview']);

	(function() {
	  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	})();

      </script>
      <script type="text/javascript" src="../_static/jMenu.jquery.js"></script>
      <script type="text/javascript">
	      $(document).ready(function(){
		      $("#jMenu").jMenu({
			      ulWidth : '150',
			      effects : {
				      effectSpeedOpen : 300,
				      effectSpeedClose : 300,
				      effectTypeOpen : 'slide',
				      effectTypeClose : 'slide',
				      effectOpen : 'linear',
				      effectClose : 'linear'
			      },
			      TimeBeforeOpening : 100,
			      TimeBeforeClosing : 400,
			      animatedText : false,
			      paddingLeft: 1		});
	      })
      </script>
<!-- Preview -->
     <script type="text/javascript" src="../_static/imgpreview.js"></script>
     <script type="text/javascript">
       $(document).ready(function(){
           $('.preview').imgPreview();
       });
     </script>
     
     <!--[if !IE 7]>
	     <style type="text/css">
		     #wrap {display:table;height:100%}
	     </style>
     <![endif]-->
    </head>
    <body>
        




<div id="wrap">
    
<div id="header">

	<div class="logo"><a href="../misc/tour.html">
       <img src="../_static/sqlkit.png" align="left"  alt="Logo" border="0"/></a>
        </div>
	<div id="description">Acces to db made easy</div>
</div>


   <div style="clear:left;"></div>


<div >
	<ul id="jMenu">
            <li><a class="fNiv" href="../index.html" title="Home" 
                  >Home</a></li>

            <li><a li class="fNiv" href="../sqlkit/contents.html"
                  title="Sqlkit - the python package" 
                  >Sqlkit</a>

	       <ul>
		 <li ><a href="../sqlkit/contents.html"
		       title="Sqlkit - the python package" 
		       >Sqlkit</a></li>

		 <li ><a href="../sqlkit/sqlwidget.html" title="Widgets" 
		       >Widgets</a>
		       <ul> 
			 <li ><a href="../sqlkit/mask.html" title="Mask" 
			       >Mask view</a></li>
			 <li ><a href="../sqlkit/table.html" title="Table" 
			       >Table view</a></li>
		       </ul>
                 </li>
		 <li ><a href="../sqlkit/browsing.html" title="Browsing Data" 
		       >Browsing data</a>
		    <ul> 
		      <li ><a href="../sqlkit/constraints.html" title="Constraints" 
			    >Constraints</a></li>
		      <li ><a href="../sqlkit/filters.html" title="Filters" 
			    >Filters</a></li>
		      <li ><a href="../sqlkit/totals.html" title="Totals" 
			    >Totals</a></li>
		    </ul>
                 </li>
		 <li ><a href="../sqlkit/editing.html" title="Editing Data" 
		       >Editing data</a>
			 <ul> 
			   <li ><a href="../sqlkit/completion.html" title="Completion" 
				 >Completion</a></li>
			   <li ><a href="../sqlkit/validation.html" title="Validation" 
				 >Validation</a></li>
			   <li ><a href="../sqlkit/relationship.html" title="Relationships" 
				 >Relationships</a></li>
			 </ul>
		       </li>
		 <li ><a href="../sqlkit/printing.html" title="Printing" 
		       ><span>Printing</span></a></li>
		 <li ><a href="../sqlkit/advanced/contents.html" title="Advanced configuration" 
		       >Advanced configuration</a>
			 <ul> 
			   <li ><a href="../sqlkit/advanced/fields.html" title="Fields" 
				 >Fields</a></li>
			   <li ><a href="../sqlkit/advanced/views.html" title="Views" 
				 >Views</a></li>
			 </ul>
		       </li>

	       </ul>
            </li>

            <li><a class="fNiv" href="../misc/sqledit.html"
                  title="Sqledit GUI" 
                  >Sqledit GUI</a></li>

            <li><a class="fNiv" href="../misc/tutorials.html"
                  title="Support & tutorials" 
                  >Support & Tutorials</a>
	       <ul>
		 <li ><a href="../misc/sqledit.html"
		       title="Sqledit - the application" 
		       >Sqledit - the application</a></li>
		 <li ><a href="../misc/tour.html"
		       title="Sqlkit - the features'tour"
		       >Sqlkit - features' tour</a></li>
		 <li ><a href="../misc/sqledit.html"
		       title="Sqledit - the application" 
		       >Installing instructions</a></li>
		</ul> 
            </li>

            <li><a class="fNiv" href="../layout/contents.html" title="Layout"
                  >Layout</a></li>

            <li><a  class="fNiv"href="../misc/contents.html" title="Download" 
                  >Download</a>

	       <ul>
		 <li ><a href="../misc/contents.html"
		       title="Download"
		       >Download</a></li>
		 <li ><a href="http://sqlkit.argolinux.org/download/Changelog"  title="Changelog"
		       title="Changelog"
		       >Changelog</a></li>
		 <li ><a href="../misc/backward_incompatibilities.html"
		       title="Backward incompatibilities"
		       >Backward incompatibilities</a></li>
	       </ul>
            </li>



        </ul>
</div>
   <div style="clear:left;"></div>

    
    <div class="related">
      <ul>
	
<!-- <div class="prevnext"> -->
<!--    <li class="right"  style="margin-right: 10px">Indice -->
<!--      <a href="../genindex.html" title="Indice generale" -->
<!--                accesskey="I">indice</a></li> -->

        <li class="right">Prev:
        <a href="../sqlkit/advanced/field_widgets.html" title="previous chapter">Field Widgets</a></li>
        <li class="right">Next:
        <a href="../misc/tour.html" title="next chapter">Sqlkit &amp; Sqledit</a></li>
<!-- </div> -->


      </ul>

    </div>

    
  <div class="sphinxsidebar">
     <div class="sphinxsidebarwrapper">


	    <div class="topnav">
    <h3>Table of contents</h3>
		    <ul>
<li><a class="reference external" href="#">Printing</a><ul>
<li><a class="reference external" href="#openoffice-org-template">OpenOffice.org template</a><ul>
<li><a class="reference external" href="#the-template">The template</a><ul>
<li><a class="reference external" href="#scenario">scenario</a></li>
<li><a class="reference external" href="#implementation">implementation</a></li>
<li><a class="reference external" href="#context">context</a><ul>
<li><a class="reference external" href="#name-mapping">name mapping</a></li>
</ul>
</li>
<li><a class="reference external" href="#output">output</a></li>
<li><a class="reference external" href="#example">example</a></li>
</ul>
</li>
<li><a class="reference external" href="#api">API</a><ul>
<li><a class="reference external" href="#id2">Context</a></li>
<li><a class="reference external" href="#template">Template</a></li>
<li><a class="reference external" href="#table">Table</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>

		<div class="clearboth"></div>
	    </div>



    <h3>Questions?</h3>

    <p>Subscribe to out mailing list <a href="http://groups.google.com/group/sqlkit">
       Google group</a>:</p>

    <form action="http://groups.google.com/group/sqlkit/boxsubscribe" style="padding-left: 1em">
      <input type="text" name="email" value="your@email"/>
      <input type="submit" name="sub" value="Subscribe" />
    </form>
    <div id="searchbox" style="display: none">

    <h3>Quick search</h3>
	<form class="search" action="../search.html" method="get">
	  <input type="text" name="q" size="18" />
	  <input type="submit" value="Search" />
	  <input type="hidden" name="check_keywords" value="yes" />

	  <input type="hidden" name="area" value="default" />
	</form>
	<p class="searchtip" style="font-size: 90%">
        Enter search terms or a module, class or function name.
	</p>
    <h3>License</h3>
	<img src="../_static/gplv3.png" alt="logo GPLv3">

    </div>
    <script type="text/javascript">$('#searchbox').show(0);</script>

     </div>
  </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">

            <div class="body">
                
<div class="section" id="module-sqlkit.misc.oootemplate">
<h1>Printing<a class="headerlink" href="#module-sqlkit.misc.oootemplate" title="Permalink to this headline">¶</a></h1>
<p>Printing in sqlkit uses the <tt class="docutils literal"><span class="pre">oootemplate</span></tt> module that is distributed along
with sqlkit but could be used in a totally independent way and does not
depend in any way on other parts of sqlkit.</p>
<div class="section" id="openoffice-org-template">
<span id="oootemplate"></span><h2>OpenOffice.org template<a class="headerlink" href="#openoffice-org-template" title="Permalink to this headline">¶</a></h2>
<p>This module makes it possible to use an oasis <tt class="docutils literal"><span class="pre">.odt</span></tt> document as a template to produce
documents via the use of an openoffice server (i.e. an istance of openoffice that
listens for connections by clients).</p>
<p>It uses the uno module that comes with openoffice. In the following image you can see
how the template looks before rendering and how the <tt class="docutils literal"><span class="pre">pdf</span></tt> produced looks.
The red circle stresses the marker that makes the template produce many lines for each
input line: one for each object in context.</p>
<img alt="../_images/ootemplate-colors.png" src="../_images/ootemplate-colors.png" />
<p>This rendering can be obtained by code very similar to this <a class="reference internal" href="#example"><em>example</em></a></p>
<div class="section" id="the-template">
<h3>The template<a class="headerlink" href="#the-template" title="Permalink to this headline">¶</a></h3>
<p>An openoffice writer document (<tt class="docutils literal"><span class="pre">.odt</span></tt> extension) can be used as template.  No
particular templating skills are required by the template designer, just
ability to create an openoffice document and a list of variable&#8217;s names that
must be used. Clearly this list must be provided by the programmer to the
designer.</p>
<div class="section" id="scenario">
<h4>scenario<a class="headerlink" href="#scenario" title="Permalink to this headline">¶</a></h4>
<p>oootemplate will substitute variables values where needed.</p>
<div class="highlight-python"><pre>Dear Mr. $user.name $user.last_name,

Today $date we  received an order for $n books:

+-----------------------------+----------------+----------+----------+
|Title                        |Author          |N. pieces |$currency |
+-----------------------------+----------------+----------+----------+
| ++$title                    |$author         |$qty      |$price    |
+-----------------------------+----------------+----------+----------+</pre>
</div>
<p>This is an example of a template rendered as possible with ascii art.</p>
<p>There are 2 different substitutions that can be done:</p>
<blockquote>
<ol class="loweralpha simple">
<li>simple substitutions ($user, $date, $currency, above - yellow in the image)</li>
<li>multiline substitutions (the book entries above, starting with ++ - green
in the image)</li>
</ol>
</blockquote>
<p>the first refers to substitution of a single value that is already present in
the document,  the second refers to the insertion of several
rows according to a list of fields that are probably in a table.</p>
<p>The variables defined in the table should be repeted in loop for each book
provided in the <tt class="docutils literal"><span class="pre">context</span></tt>, that implies an increment of the number of
rows of the table. The expected output resembles what follows:</p>
<div class="highlight-python"><pre>Dear Mr. Alessandro Dentella,

today June, 2 2008, we received an order of 2 books:

+-----------------------------+----------------+----------+----------+
|Title                        |Author          |Copies    |Euro      |
+-----------------------------+----------------+----------+----------+
| Q                           |Luther Blisset  |1         |10        |
+-----------------------------+----------------+----------+----------+
| Il sistema periodico        |Primo Levi      |2         |8         |
+-----------------------------+----------------+----------+----------+</pre>
</div>
<p>As for any template system a special syntax is needed to allow people to
create loops. We are constrained to what can be done by a simple user of
openoffice (no programming at all) so we choose to use a MULTI_LINE_MARKER
in the default form of a &#8216;++&#8217; (red circle in the image) .</p>
<p>To make things more complicated it&#8217;s clear that the person that created the
template (the .odt document), may have used a table just for formatting
reason so that substitution of type a. can be in an openoffice table or not.</p>
</div>
<div class="section" id="implementation">
<h4>implementation<a class="headerlink" href="#implementation" title="Permalink to this headline">¶</a></h4>
<p>Substitution of type <tt class="docutils literal"><span class="pre">a.</span></tt> above are done using search and replace
functionality of openoffice API, while substitution of type <tt class="docutils literal"><span class="pre">b.</span></tt> are
implemented as a loop on table&#8217;s rows and cell in 2 different ways: one that
preserves the style of each word of the cells and one that doesn&#8217;t.
The former uses getTrasferable() method on each cell and is slower.</p>
<p>You can switch from one to the other setting Template&#8217;s attrribute
<a title="sqlkit.misc.oootemplate.Template.preserve_styles" class="reference internal" href="#sqlkit.misc.oootemplate.Template.preserve_styles"><tt class="xref docutils literal"><span class="pre">Template.preserve_styles</span></tt></a></p>
<p>The pattern used to detect what is a table can be customized. While the default
is &#8216;$&#8217; as in the shell or in python template system (and perl and php...) since
you may have the &#8216;$&#8217; symbol in your document you may want to customize it. See
Template&#8217;s method <tt class="docutils literal"><span class="pre">set_pattern</span></tt>.</p>
</div>
<div class="section" id="context">
<h4>context<a class="headerlink" href="#context" title="Permalink to this headline">¶</a></h4>
<p>The context is the object that contains the mapping variable/value to be used.
It needs an argument -a dict- that holds the values.</p>
<p>oootemplate allows you to have more that one tables in your document. That means
you can implement easily things as:</p>
<div class="highlight-python"><pre>Dear Mr. $user.name $user.last_name,

you can order these books at 20% discount

+-----------------------------+----------------+----------+----------+
|Title                        |Author          |N. pieces |$currency |
+-----------------------------+----------------+----------+----------+
| ++$title                    |$author         |$qty      |$price    |
+-----------------------------+----------------+----------+----------+

or these books at 50% discount

+-----------------------------+-----------------+----------+----------+
|Title                        |Author           |N. pieces |$currency |
+-----------------------------+-----------------+----------+----------+
| ++$title                    |$author          |$qty      |$price    |
+-----------------------------+----------+------+----------+----------+
|Title                        |Author    | Extra|N. pieces |$currency |
+-----------------------------+----------+------+----------+----------+
| ++$title                    |$author   | $x   |$qty      |$price    |
+-----------------------------+----------+------+----------+----------+</pre>
</div>
<p>In this example we have 3 lines that start with ++, that means that will be
conseidered prototipes for new lines. For each of these 3 rows there need
to be a list of objects (books in the example) in the context.</p>
<p>Since Openoffice-org tables have names, we wil use that name as a key in the
context for the value. That&#8217;s enought for the first table (20% discount) not
for the second where we have 2 lists in a table. To cope with this case, we
can put as value a dict with entry an integer that indicates the position
starting from 1 (see example below)</p>
<div class="section" id="name-mapping">
<h5>name mapping<a class="headerlink" href="#name-mapping" title="Permalink to this headline">¶</a></h5>
<p>Occasionally the name of the variable will be too long to fit in the space
that you want to allocate. You can translate a shorter name to the real
name in the dict context.translate (see example in the demo), blue circle
in the image.</p>
<p>This way you can hide the complexity of some variable name. Note that you
can translate both <tt class="docutils literal"><span class="pre">$rs.manager.address</span></tt> in <tt class="docutils literal"><span class="pre">$addr</span></tt> or
<tt class="docutils literal"><span class="pre">$director.last_name</span></tt> in <tt class="docutils literal"><span class="pre">$d.last_name</span></tt>.</p>
</div>
</div>
<div class="section" id="output">
<h4>output<a class="headerlink" href="#output" title="Permalink to this headline">¶</a></h4>
<p>All output accepted by openoffice filters, you&#8217;re probably using <tt class="docutils literal"><span class="pre">.odt</span></tt> or <tt class="docutils literal"><span class="pre">.pdf</span></tt></p>
</div>
<div class="section" id="example">
<span id="id1"></span><h4>example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h4>
<p>A tipical sample code is:</p>
<div class="highlight-python"><pre>import ooootemplate as oo

tmpl = oo.Template('/tmp/mytemplate.odt', server='127.0.0.1', port=2002)
context = oo.Context({
    'user' : user,
    'date' : date(2008, 6, 2),
    'currency' : 'Euro',
    'Table1' : (book1, book2, ...)  # lazy assignement (simple tuple)
    'Table2' : (
         (book21, book22, ...),     # correct assignement (list of tuples)
         (book31, book32, ...),
         )
    })

tmpl.render(context)
tmpl.save_as('/tmp/new_document.pdf')</pre>
</div>
</div>
</div>
<div class="section" id="api">
<h3>API<a class="headerlink" href="#api" title="Permalink to this headline">¶</a></h3>
<div class="section" id="id2">
<h4>Context<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h4>
<dl class="class">
<dt id="sqlkit.misc.oootemplate.Context">
<em class="property">class </em><tt class="descclassname">sqlkit.misc.oootemplate.</tt><tt class="descname">Context</tt><big>(</big><em>content</em>, <em>lazy=True</em><big>)</big><a class="headerlink" href="#sqlkit.misc.oootemplate.Context" title="Permalink to this definition">¶</a></dt>
<dd><p>A context used to render a template. It contains both the data and the way to
substitute variable with the data.</p>
<dl class="method">
<dt id="sqlkit.misc.oootemplate.Context.__init__">
<tt class="descname">__init__</tt><big>(</big><em>content</em>, <em>lazy=True</em><big>)</big><a class="headerlink" href="#sqlkit.misc.oootemplate.Context.__init__" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>content</em> &#8211; a dict with keys the variable names</li>
<li><em>lazy</em> &#8211; <p>boolean. If True (default) invokes
_implement_lazy_tables to allow the list of objects for a
table rendered to be directly set as value of the table_name
entry (rather than a list of lists). See
<a class="reference internal" href="#example"><em>example</em></a> <tt class="docutils literal"><span class="pre">Table1</span></tt> is lazy <tt class="docutils literal"><span class="pre">Table2</span></tt> is not.</p>
<p>The goal is to prevent common errors rather than promoting
lazy writing. When you only have a single list of objects you
may easily forget that you may have more than one.</p>
<p>The assumption is that you don&#8217;t normally have lists as values
of context (other that for tables). While probably true, should
you need lists as contetxt values, you can just set lazy=False.</p>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="template">
<h4>Template<a class="headerlink" href="#template" title="Permalink to this headline">¶</a></h4>
<dl class="class">
<dt id="sqlkit.misc.oootemplate.Template">
<em class="property">class </em><tt class="descclassname">sqlkit.misc.oootemplate.</tt><tt class="descname">Template</tt><big>(</big><em>filename</em>, <em>server='127.0.0.1'</em>, <em>port=8100</em>, <em>headless=False</em>, <em>oo_context=None</em>, <em>preserve_styles=False</em><big>)</big><a class="headerlink" href="#sqlkit.misc.oootemplate.Template" title="Permalink to this definition">¶</a></dt>
<dd><p>The class template that connects to a server (or starts a local one), read a
document, parses the document to find tables</p>
<dl class="method">
<dt id="sqlkit.misc.oootemplate.Template.__init__">
<tt class="descname">__init__</tt><big>(</big><em>filename</em>, <em>server='127.0.0.1'</em>, <em>port=8100</em>, <em>headless=False</em>, <em>oo_context=None</em>, <em>preserve_styles=False</em><big>)</big><a class="headerlink" href="#sqlkit.misc.oootemplate.Template.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>only the <tt class="docutils literal"><span class="pre">filename</span></tt> is needed if the server is local. If we already
have a template on the same server we can reuse the <tt class="docutils literal"><span class="pre">oo_context</span></tt></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name" colspan="2">Params filename:</th></tr>
<tr><td>&nbsp;</td><td class="field-body"><p class="first">the template filename in the server&#8217;s filesystem</p>
</td>
</tr>
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>server</em> &#8211; a server name</li>
<li><em>port</em> &#8211; the port to connect to</li>
<li><em>headless</em> &#8211; if False, disables the headless mode.</li>
<li><em>oo_context</em> &#8211; the openoffice context (not to be confused with
<tt class="docutils literal"><span class="pre">oootemplate.Context</span></tt>). The <cite>oo_context`</cite> plays the role of the
connection to the server</li>
<li><em>preserve_styles</em> &#8211; use <tt class="xref docutils literal"><span class="pre">TemplateWithStyles</span></tt> to enforce preservation of
styles in each word of the cell when duplicating rows</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="sqlkit.misc.oootemplate.Template.render">
<tt class="descname">render</tt><big>(</big><em>context</em><big>)</big><a class="headerlink" href="#sqlkit.misc.oootemplate.Template.render" title="Permalink to this definition">¶</a></dt>
<dd><p>substitute all the variables with values from context</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>context</em> &#8211; the Contex instance to be used</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="sqlkit.misc.oootemplate.Template.save_as">
<tt class="descname">save_as</tt><big>(</big><em>filename</em>, <em>local=None</em><big>)</big><a class="headerlink" href="#sqlkit.misc.oootemplate.Template.save_as" title="Permalink to this definition">¶</a></dt>
<dd><p>save the template using save_as capability of openoffice.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>filename</em> &#8211; filename in the <cite>server</cite>&#8216;s filesystem. The extension is used to
detect the file type as in regular openoffice use.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="sqlkit.misc.oootemplate.Template.set_pattern">
<tt class="descname">set_pattern</tt><big>(</big><em>pattern</em>, <em>oo_pattern</em><big>)</big><a class="headerlink" href="#sqlkit.misc.oootemplate.Template.set_pattern" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the pattern to detect what is a variable to be substituted</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>pattern</em> &#8211; the pattern with syntax suitable for module <tt class="docutils literal"><span class="pre">re</span></tt> module.
It must define at least 2 groups: <tt class="docutils literal"><span class="pre">var_name</span></tt> and <tt class="docutils literal"><span class="pre">match</span></tt> pointing
respectively to the name of the  variable and the whole match.
Default is <tt class="docutils literal"><span class="pre">(?P&lt;match&gt;\$(?P&lt;var_name&gt;[^</span> <span class="pre">]+))</span></tt></li>
<li><em>oo_pattern</em> &#8211; the pattern with syntax suitable for openoffice regexp search.
It can only use the openoffice syntax. Default is <tt class="docutils literal"><span class="pre">$[^</span> <span class="pre">]+</span></tt></li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="sqlkit.misc.oootemplate.Template.VARIABLE_PATTERN">
<tt class="descname">VARIABLE_PATTERN</tt><a class="headerlink" href="#sqlkit.misc.oootemplate.Template.VARIABLE_PATTERN" title="Permalink to this definition">¶</a></dt>
<dd>the pattern for python variable detection. it&#8217;s a regular expression read
<a title="sqlkit.misc.oootemplate.Template.set_pattern" class="reference internal" href="#sqlkit.misc.oootemplate.Template.set_pattern"><tt class="xref docutils literal"><span class="pre">set_pattern</span></tt></a> for details</dd></dl>

<dl class="attribute">
<dt id="sqlkit.misc.oootemplate.Template.VARIABLE_PATTERN_OO">
<tt class="descname">VARIABLE_PATTERN_OO</tt><a class="headerlink" href="#sqlkit.misc.oootemplate.Template.VARIABLE_PATTERN_OO" title="Permalink to this definition">¶</a></dt>
<dd>the pattern for openoffice variable detection. read <a title="sqlkit.misc.oootemplate.Template.set_pattern" class="reference internal" href="#sqlkit.misc.oootemplate.Template.set_pattern"><tt class="xref docutils literal"><span class="pre">set_pattern</span></tt></a> for details</dd></dl>

<dl class="attribute">
<dt id="sqlkit.misc.oootemplate.Template.MULTI_LINE_MARKER">
<tt class="descname">MULTI_LINE_MARKER</tt><a class="headerlink" href="#sqlkit.misc.oootemplate.Template.MULTI_LINE_MARKER" title="Permalink to this definition">¶</a></dt>
<dd>the pattern used to tel when a multiline line starts. Defaults to ++</dd></dl>

<dl class="attribute">
<dt id="sqlkit.misc.oootemplate.Template.document">
<tt class="descname">document</tt><a class="headerlink" href="#sqlkit.misc.oootemplate.Template.document" title="Permalink to this definition">¶</a></dt>
<dd>the openoffice document from the server</dd></dl>

<dl class="attribute">
<dt id="sqlkit.misc.oootemplate.Template.oo_context">
<tt class="descname">oo_context</tt><a class="headerlink" href="#sqlkit.misc.oootemplate.Template.oo_context" title="Permalink to this definition">¶</a></dt>
<dd>the connection with the server. This can be reused between templates</dd></dl>

<dl class="attribute">
<dt id="sqlkit.misc.oootemplate.Template.search">
<tt class="descname">search</tt><a class="headerlink" href="#sqlkit.misc.oootemplate.Template.search" title="Permalink to this definition">¶</a></dt>
<dd>the openoffice SearchDescriptor</dd></dl>

<dl class="attribute">
<dt id="sqlkit.misc.oootemplate.Template.preserve_styles">
<tt class="descname">preserve_styles</tt><a class="headerlink" href="#sqlkit.misc.oootemplate.Template.preserve_styles" title="Permalink to this definition">¶</a></dt>
<dd>Preserve style of each word in the cell when cloning rows.
This will slow down the process so it&#8217;s disabled by default</dd></dl>

</dd></dl>

</div>
<div class="section" id="table">
<h4>Table<a class="headerlink" href="#table" title="Permalink to this headline">¶</a></h4>
<dl class="class">
<dt id="sqlkit.misc.oootemplate.Table">
<em class="property">class </em><tt class="descclassname">sqlkit.misc.oootemplate.</tt><tt class="descname">Table</tt><big>(</big><em>oo_table</em>, <em>template</em><big>)</big><a class="headerlink" href="#sqlkit.misc.oootemplate.Table" title="Permalink to this definition">¶</a></dt>
<dd><p>table object
detail on the API exposed by uno:
<a class="reference external" href="http://api.openoffice.org/docs/common/ref/com/sun/star/table/module-ix.html">http://api.openoffice.org/docs/common/ref/com/sun/star/table/module-ix.html</a></p>
<dl class="method">
<dt id="sqlkit.misc.oootemplate.Table.__init__">
<tt class="descname">__init__</tt><big>(</big><em>oo_table</em>, <em>template</em><big>)</big><a class="headerlink" href="#sqlkit.misc.oootemplate.Table.__init__" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>oo_table</em> &#8211; the openoffice table object</li>
<li><em>template</em> &#8211; the <tt class="docutils literal"><span class="pre">oootemplate.template</span></tt> object in which this table is</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlkit.misc.oootemplate.TableWithStyles">
<em class="property">class </em><tt class="descclassname">sqlkit.misc.oootemplate.</tt><tt class="descname">TableWithStyles</tt><big>(</big><em>oo_table</em>, <em>template</em><big>)</big><a class="headerlink" href="#sqlkit.misc.oootemplate.TableWithStyles" title="Permalink to this definition">¶</a></dt>
<dd><p>A Table that clones rows preserving style info even if several different styles
are used within the same cell. This process is slower so it&#8217;s not active by default:
set Template&#8217;s arg <tt class="docutils literal"><span class="pre">preserve_styles</span></tt> to True to enable it (see ex. N. 5).</p>
<dl class="method">
<dt id="sqlkit.misc.oootemplate.TableWithStyles.__init__">
<tt class="descname">__init__</tt><big>(</big><em>oo_table</em>, <em>template</em><big>)</big><a class="headerlink" href="#sqlkit.misc.oootemplate.TableWithStyles.__init__" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>oo_table</em> &#8211; the openoffice table object</li>
<li><em>template</em> &#8211; the <tt class="docutils literal"><span class="pre">oootemplate.template</span></tt> object in which this table is</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

</div>
</div>
</div>
</div>


            </div>
        </div>
     </div>
   </div>

        
</div> <!-- wrap -->

            <div class="bottomnav footer">
                <div class="doc_copyright">
                Alessandro Dentella -- Copyright 2006-2007-2008-2009-2010
		  Sqlkit release 0.9.5
<!--                 % if hasdoc('copyright'): -->
<!--                     &copy; <a href="../copyright.html">Copyright</a> 2008, Sandro Dentella. -->
<!--                 % else: -->
<!--                     &copy; Copyright 2008, Sandro Dentella. -->
<!--                 % endif -->
                    creato usando  <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.4.
                </div>
            </div>
        












<br style="clear: left" />

    </body>
</html>