Jay Yu avatar Jay Yu committed 74055b8

Import from tarball: http://pypi.python.org/pypi/pisa/
pisa-3.0.33.tar.gz
MD5: e2040b12211303d065bc4ae2470d2700

Comments (0)

Files changed (176)

+ CHANGELOG
+=========
+
+********************************************************************************
+  "I would like to thank the people mentioned in brackets in this change log
+  very much for their help and support!" - Dirk
+********************************************************************************
+
+Version 3.0.33, 2010-06-16
+- NEW: Changed license to Apache License 2.0, now completely Open Source 
+       without any charging. Feel free to continue or for this project.
+- FIX: Empty cells now collapse
+
+Version 3.0.32, 2009-05-08
+
+- NEW: New command line option '--base' to specify base path if input comes
+       via STDIN
+- FIX: The 'keep in frame' feature for tables did not work inside of static 
+       frames (Arun Shanker Prasad)
+- FIX: Small typos 
+
+Version 3.0.31, 2009-05-04
+
+- NEW: Support for Style "list-style-image", also supports "zoom"
+- NEW: Temporary files internally are written to disk if they exceed a certain size
+- NEW: Font names can now also read from external URL
+- UPD: Modified pdfjoiner.py demo
+- FIX: Custom font image problem still appeared
+- FIX: Single image in a block issue
+- FIX: Randomly used wrong images is fixed using a workaround for the bug
+       in Reportlab _digester routine
+- FIX: Empty tables error (Davide Moro)
+- FIX: Fallback to urllib2 if httpdlib fails
+
+Version 3.0.30, 2009-03-27
+
+- NEW: Default CSS now hides content of <noscript>
+- UPD: Better whitespace handling in RL Paragraph
+- FIX: Fixed RL Paragraph.split to work with autoleading and images
+- FIX: Small bug fix for show_error_as_pdf
+- FIX: Demos used os.startfile which is not supported on non Windows OSes
+- FIX: Table available height threw exceptions
+- FIX: Switched from urllib2 to httplib for loading external sources 
+- FIX: Correct homepage and download page in setup.py
+- FIX: Paragraphs in lists repeated the bullet
+- FIX: Tables now support -pdf-keep-with-next
+- FIX: TOC bug fixed
+- FIX: Add missing table columns to avoid error in Reportlab table
+- FIX: Fix for background images sizing
+- FIX: Empty documents now create one blank page
+- FIX: Imported fonts caused an error if used together with images
+
+Version 3.0.29, 2008-12-01
+
+- NEW: Warning if Reportlab 2.2 is not installed
+- UPD: Better support for named colors
+- UPD: Modifed frame handling to better support relative values
+- FIX: Splitting paragraph threw errors some times; also had problems with
+       line breaks on the second page, fix for RL 2.2 paragraph was needed
+- FIX: Added margins to <blockquote> default CSS
+- FIX: Inline images in static frames did not work
+- FIX: Link anchors and non internal fonts caused a strange error
+
+Version 3.0.28, 2008-11-21
+
+- NEW: Requires Reportlab 2.2 now!
+- NEW: Background colors for inline elements like <span>
+- NEW: Inline images and left and right aligned images implemented
+- NEW: Possibility to handle table cells that are to large via CSS option
+       -pdf-keep-in-frame-mode
+- NEW: Option "--system" for command line tool to dump system version infos
+- NEW: CSS attribute -pdf-line-spacing for fix space between lines
+- NEW: Creation and handling of data URI with base64 encoding (others to come)
+- NEW: New general file loader that is also able to load remote data and data URI
+- NEW: PDF Joiner to concatenate many PDF and pisa documents
+- NEW: Page backgrounds can now be images or PDF
+- NEW: Visual Unittests based on ImageMagick and TortoiseIDiff (for Windows)
+- NEW: Pisa raises execptions now if errors occure; with
+       pisaDocument(..., raise_execeptions=False) you can turn them off
+- UPD: Paragraphs now use the maximum leading to avoid overlapping text
+- UPD: Removed "Keep with next" from H1 to H6
+- FIX: Sizing of images is now handled better; should better work with PIL
+- FIX: Border handling of paragraphs optimized and fixed
+- FIX: Images that are higher than the page frame are scaled down to fit
+- FIX: Paragraphs only containing &nbsp; are rendered
+- FIX: Problem regarding the order of border style definitions
+- FIX: Single <br> between two blocks now creates a new line
+- FIX: Set table attribute "repeat" to "0"
+- FIX: Some <font> attributes did not work as expected
+- FIX: Font sizes reworked to behave like browser implmentations
+- FIX: Like in most HTML browser table cells now have "valign=middle" and
+       table headers have font weight bold
+- FIX: Little fix in CSS parsing
+- FIX: Default of <link media=""> was "screen", changed to "all"
+- FIX: Command line tools did not install with "easy_install"
+
+Version 3.0.27, 2008-10-04
+
+- INF: License changed from Qt to GPLv2
+- INF: Not yet completely combatible with Reportlab 2.2 (&nbsp; errors and borders)
+- NEW: Command line tool called "xhtml" ("pisa" still available but will
+       be deprecatedwith pisa 3.1)
+- NEW: EGG for Python 2.6
+- NEW: Basic support for Data URI
+- NEW: New style -pdf-keep-with-next (does not work with pdf:toc for now)
+- UPD: Setup now exclusively works with SetupTools
+
+Version 3.0.26, 2008-08-28
+
+- FIX: Python <2.5 didn't work because of a syntax error
+
+Version 3.0.25, 2008-08-15
+
+- UPD: Made imports more explicit to avoid import recursions
+- FIX: <pdf:pagenumber/> didn't work in tables (Roman Lisagor)
+- FIX: Images without suffixes have been ignored by pisa (Henning von Bargen)
+- INF: Preparations for support of HTML FORM using INPUT, TEXTAREA, SELECT
+
+Version 3.0.24, 2008-07-14
+
+- NEW: Support for separate borders on each side of a paragraph has
+       been added (Robin Dunn)
+- NEW: Support for font tag (color, face, size)
+- UPD: Handling of margin and padding in paragraphs is improved (Robin Dunn)
+- UPD: Updated documentation (CreatePDF, Images)
+- FIX: A typo in margin-left has been fixed (Robin Dunn)
+
+Version 3.0.23, 2008-06-26
+
+- UPD: getColor() now understands colors like rgb(255,0,0) (Darryl Dixon)
+- FIX: c.warning threw errors if no arguments where passed (Searle)
+- FIX: pisa now works with html5lib 0.11.1
+       http://code.google.com/p/html5lib/issues/detail?id=74
+
+Version 3.0.22, 2008-06-06
+
+- UPD: Updated documentation
+- UPD: Speed optimizations by removing copy.deepcopy (Darryl Dixon)
+- FIX: Small fix in CSS parser
+
+Version 3.0.21, 2008-06-05
+
+- FIX: Used a parameter for html5lib that was not supported by html5lib 0.10
+- FIX: Now tested against the latest third party packages:
+       ReportLab 2.1
+       html5lib 0.10
+       pyPdf 1.11
+
+Version 3.0.20, 2008-06-02
+
+- NEW: New parameter "encoding" to explicitly set an encoding for the source data
+- UPD: Added a programming example to documentation
+- FIX: If a Unicode string is passed it will automatically be converted to UTF8
+- FIX: Fixes for Google AppEngine support
+- FIX: If possible cStringIO will be used instead of StringIO
+- FIX: An exception in psaDocument was not handled the right way because
+       a context object was expected
+
+Version 3.0.19, 2008-05-31
+
+- NEW: Support for Google AppEngine
+- NEW: Support for page break before and after [not yet tested] (Luka Frelih)
+- UPD: Reworked parts of the documentation but not yet completed
+- UPD: Optimized the command line tool "pisa"
+- FIX: TOC bugs regarding entities and additional tags inside the TOC
+       entry definitions (Luka Frelih)
+- FIX: Default logging didn't work with Python<2.5 (Anders J. Munch)
+- FIX: StringIO is used instead of cStringIO to avoid encoding problems
+       like the ones we had with GoogleAppEngine
+
+Version 3.0.18, 2008-04-19
+
+- WIN: Updated the windows command line version
+- NEW: WSGI support and demo
+- NEW: Added simple ASPN Cookbook example
+- UPD: Unified setup.py and setup_egg.py (Andreas Gabriel)
+- UPD: Better handling of XML and HTML parsing
+- UPD: Cleanup of Django sample
+- UPD: Cleanup of command line tool options
+- UPD: Command line tool doesn't stop batch if error occurred any more
+- FIX: 'style' attribute was not evaluated!
+- FIX: If a string was passed to pisaDocument it had been converted to StringIO,
+       which was not necessary
+- FIX: c.addPara(force=True) works again e.g. for forcing empty pages
+- FIX: Better handling of CDATA and Comments
+- FIX: Better handling of &nbsp;
+- FIX: Removed rsplit() for backward compatibility with Python 2.3
+- FIX: Handling of inconsistent HTML anchors
+- FIX: TurboGears Demo
+
+Version 3.0.17, 2008-03-23
+
+- NEW: Added CSS support for TOC and updated documentation (Jean Baltus)
+- UPD: Added "render_to_pdf" to Django demo (Diego Firmenich)
+- UPD: Did some refactoring to make CSS parsing more flexible
+- UPD: Removed log.exception for warnings
+- FIX: Empty entries in TOC (Jean Baltus)
+- FIX: Use correct font for <li> now (reported by Gabor Farkas)
+
+Version 3.0.16, 2008-03-16
+
+- Did some researches about support for languages like Farsi, Arabic and Asian
+  languages. The dir='rtl' feature seems to be quite time intensive to be
+  implemented, maybe I will do it in a later version or on request
+- Switched back to HTML parsing by default, but use of XHTML is recommended. Use
+  the option "xhtml" in pisaDocument or "-x" in the command line tool
+- Added a decorator for use in Turbogears and CherryPy
+- Completely switched to Python logging system
+- Created a separate download for the fonts in the "test" directory to
+  reduce the size of the package
+- Just use multiBuild if needed e.g. using pdf:toc
+- Bugfix: @font-face threw always a warning about font-weight
+- Bugfix: List points have to be always in "Helvetica" (Gabor Farkas)
+- Bugfix: Obligatory attributes for tag had not been handle the right way
+- Bugfix: Marked some old tag based functionalities like pdf:font, pdf:frame and
+  pdf:template as deprecated
+
+Version 3.0.15, 2008-03-13
+
+- Added new package and namespace "ho". With pisa 3.1. we will move away form "sx"
+- Added version testing (2.1) for Reportlab Toolkit (Diego Firmenich)
+- Added new command <pdf:toc> for support of table of contents, stiling per CSS
+  has not been implemented yet (Jean Baltus)
+- Added simple barcode support via command <pdf:barcode> (Diego Firmenich)
+- Added Python logging. Name of logger "ho.pisa" and "ho.css". Set debugging
+  level in command line tool by using "-d" for debugging and "-w" for warnings
+- Added complete support for CSS "font"
+- Modified the version handling and setup system for pisa distributions (had to
+  do with the import errors that where not thrown, reported by Schmitte)
+- Updated documentation and added a CSS for HTML version
+- Bugfix: CSS "background" URL handling was broken (Luis Bruno)
+- Bugfix: CSS "border" now works more standard conform
+- Bugfix for compatibility problems with Python 2.3 because of reversed() function
+- Bugfix: No exception was thrown if a third party module was missing (Kai Schmitte)
+- Bugfix: Changed HTML5 parser from HTMLParser to XHTMLParser so that the
+  custom tags of the "pdf" namespace are handled like expected
+- Bugfix: Switched from urllib to urllib2 because status errors (like 404) where
+  not handled (Kees Hink)
+- A lot of smaller bugfixes and testings
+
+Version 3.0.14, 2008-02-13
+
+- Added a sample for Unicode support in exotic languages like "farsi" using
+  DejaSans font (Adam Hyde)
+- Command line tool generation integrated into setup.py (Andreas Gabriel)
+- Bugfix if no path had been set to pisaDocument()
+- Bugfix for calculating @frame dimensions
+- Bugfix: CSS comments like "//" where allowed (Andreas Gabriel)
+
+Version 3.0.13, 2008-01-22
+
+- Added a demo using cherrypy web server and kid
+- Added a demo using django framework
+- Modified test-background.html to work with CSS
+- Added suport for bold and italic TTF fonts to the @font-face
+  CSS section (Robert Klep)
+- Added suport for bold and italic Postscript fonts to the @font-face CSS section
+- The @-rules are not need a trailing space after ident any more (Robert Klep)
+- Fixed the Windows standalone version to work
+- Made the 'sx' folder more sharable by modifying __init__.py
+- Changed font-weight so that only values starting with '400'are
+  considered 'bold' (Robert Klep)
+- Added "text-indent" style (Robert Klep)
+- Added "-pdf-keep-with-next" style to avoid page break between
+  certain elements (Robert Klep)
+- Added "-pdf-outline", "-pdf-outline-level" and "-pdf-outline-open" styles to
+  create PDF bookmarks. Per default this is defined for
+  the tags H1 to H6 (Robert Klep)
+- New option to overwrite the default CSS definitions of pisa
+- New command line options --css
+- New command line options --css-dump to get the default CSS definitions.
+  A dump of the recent CSS default may also be found in test/default.css
+- Fixed setup.py
+- Added EGG installation file support
+
+Version 3.0.12, 2008-01-09
+
+- Moved SVN repository to Holtwick
+- Modified copyright notes and links to http://www.htmltopdf.org/
+- Added new table attributes "border", "bordercolor", "cellpadding"
+- Added support for &nbsp;
+
+Version 3.0.11, 2007-11-13
+
+- New example for loading a page form the web via Python
+- New example "test-invoice.html"
+- Added support for "align" attribute to <td> and <th>
+- Fixed that more than one static frame can use the same named element
+- Added -pdf-next-page to specify next page template
+- Added -pdf-frame-break: after, before
+- Fixed bug for @page without declarations
+- Added option for output of errors as PDF (e.g. useful in web applications)
+- Set "producer" to "pisa"
+- Set author, subject and keywords with <meta>
+
+Version 3.0.10, 2007-11-02
+
+- Fixed some problems with wrong @page and @frame definitions
+- New property -pdf-frame-box
+- Implemented a pre parser for CSS that cleans up the code with some
+  regular expression, like stripping illegal url(http://...)
+- Improved online demo
+- First release of binary Windows command line version or pisa
+- Fixed some issues with named anchors
+- Empty documents are now delivered correctly
+- Fixed error on list types
+- Fixed problem with debugging infos
+
+Version 3.0.9, 2007-10-31
+
+- Modified setup.py for Chesse Shop
+- Added bdist_wininst to setup
+- Moved w3c into sx package and added license text
+- Modified simple.py demo script
+- Clean up for first public release
+
+Version 3.0.8, 2007-10-31
+
+- Added <a name> and a bugfix for ReportLab anchors
+- Added <a href>
+- More documentation about fonts and new font aliases
+- Fixed some bugs in tables
+- <hr> now uses ReportLabs implementation
+- Margin collapse by using spaceBefore and spaceAfter
+- Renamed -pdf-page-size to size (CSS3)
+
+Version 3.0.7, 2007-10-30
+
+- Static frames in @frame
+- Wrote layout section in documentation
+- Updated the documentation CSS
+- Renamed @box to @frame
+- Added -pdf-page-size and -pdf-page-orientation
+- Added @page and @box
+- Fixed some problems with font definitions and Unicode
+- Font "Times" does not exist, changed default to "Times-Roman"
+- Margins, paddings and borders are only applied in display:block elements
+
+Version 3.0.6, 2007-10-29
+
+- Implemented @font-face
+- "font-family" can now handle comma separated font names
+- Implemented <pdf:font> for embedding TTF and PS fonts
+- <link> looks for rel="stylesheet"
+- Style "white-space" and support for PRE
+- Nested lists and ordered lists, Style "list-style-type"
+- Prepared parser for @page and @box
+
+Version 3.0.5, 2007-10-25
+
+- Initial implementation of @font-face
+- Warnings are only shown if flag -w is set
+- Relative @import implementations
+- Workaround for styles beginning with asterics like "*font: small"
+- Support for color=transparent (threw Exceptions before)
+- For @import with now media, is now set media=all
+- Fixed the .1 CSS parser problem
+- Removed cssutils again because of problems with @import
+- Ignore CDATA in style definitions
+- New method c.debug and command line option --debug
+- Better URL support
+- CSS attributes may now start with hyphen for vendor
+  specific styles e.g. "-pdf-page-break"
+- Implemented @import
+- Implemented @media
+- Images are now recalculated to 96DPI too
+- 1px = 1/96inch (96dpi) instead of 1px = 1pt = 1/72inch
+- Added some new tests like test-css-media.html
+
+Version 3.0.0
+
+- Initial versions of pisa rewrite
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+Metadata-Version: 1.1
+Name: pisa
+Version: 3.0.33
+Summary: PDF generator using HTML and CSS
+Home-page: http://www.xhtml2pdf.com
+Author: Dirk Holtwick
+Author-email: dirk.holtwick@gmail.com
+License: Apache License 2.0
+Download-URL: http://pypi.python.org/pypi/pisa/
+Description: pisa is a html2pdf converter using the ReportLab Toolkit,
+        the HTML5lib and pyPdf. It supports HTML 5 and CSS 2.1 (and some of CSS 3).
+        It is completely written in pure Python so it is platform independent.
+        The main benefit of this tool that a user with Web skills like HTML and CSS
+        is able to generate PDF templates very quickly without learning new
+        technologies. Easy integration into Python frameworks like CherryPy,
+        KID Templating, TurboGears, Django, Zope, Plone, Google AppEngine (GAE) etc.
+        (see 'demo' folder for examples)
+Keywords: PDF,HTML,XHTML,XML,CSS
+Platform: UNKNOWN
+Classifier: License :: Freeware
+Classifier: License :: OSI Approved
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Development Status :: 6 - Mature
+Classifier: Environment :: Console
+Classifier: Environment :: MacOS X
+Classifier: Environment :: Other Environment
+Classifier: Environment :: Web Environment
+Classifier: Environment :: Win32 (MS Windows)
+Classifier: Framework :: Django
+Classifier: Framework :: Plone
+Classifier: Framework :: Pylons
+Classifier: Framework :: TurboGears
+Classifier: Framework :: Zope2
+Classifier: Framework :: Zope3
+Classifier: Intended Audience :: Customer Service
+Classifier: Intended Audience :: Developers
+Classifier: Intended Audience :: Education
+Classifier: Intended Audience :: Financial and Insurance Industry
+Classifier: Intended Audience :: Healthcare Industry
+Classifier: Intended Audience :: Information Technology
+Classifier: Intended Audience :: Legal Industry
+Classifier: Intended Audience :: Manufacturing
+Classifier: Intended Audience :: Science/Research
+Classifier: Intended Audience :: System Administrators
+Classifier: Intended Audience :: Telecommunications Industry
+Classifier: Natural Language :: English
+Classifier: Natural Language :: German
+Classifier: Operating System :: MacOS
+Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Operating System :: Microsoft
+Classifier: Operating System :: Microsoft :: MS-DOS
+Classifier: Operating System :: Microsoft :: Windows
+Classifier: Operating System :: Other OS
+Classifier: Operating System :: POSIX
+Classifier: Operating System :: POSIX :: Linux
+Classifier: Operating System :: Unix
+Classifier: Topic :: Documentation
+Classifier: Topic :: Internet
+Classifier: Topic :: Multimedia
+Classifier: Topic :: Office/Business
+Classifier: Topic :: Office/Business :: Financial
+Classifier: Topic :: Office/Business :: Financial :: Accounting
+Classifier: Topic :: Printing
+Classifier: Topic :: Text Processing
+Classifier: Topic :: Text Processing :: Filters
+Classifier: Topic :: Text Processing :: Fonts
+Classifier: Topic :: Text Processing :: General
+Classifier: Topic :: Text Processing :: Indexing
+Classifier: Topic :: Text Processing :: Linguistic
+Classifier: Topic :: Text Processing :: Markup
+Classifier: Topic :: Text Processing :: Markup :: HTML
+Classifier: Topic :: Text Processing :: Markup :: XML
+Classifier: Topic :: Utilities
+Requires: html5lib
+Requires: pypdf
+Requires: pil
+HELP
+====
+
+> xhtml2pdf -h
+
+REQUIREMENTS
+============
+
+- Reportlab Toolkit 2.2+
+  <http://www.reportlab.org/>
+
+- html5lib 0.11.1+
+  <http://code.google.com/p/html5lib/>
+
+- pyPdf 1.11+ (optional)
+  <http://pybrary.net/pyPdf/>
+
+EXAMPLES
+========
+
+> xhtml2pdf -s test\test-loremipsum.html
+> xhtml2pdf -s http://www.python.org
+> xhtml2pdf test\test-*.html
+
+PYTHON INTEGRATION
+==================
+
+Some simple demos of how to integrate PISA into
+a Python program may be found here: test\simple.py
+
+CONTACT
+=======
+
+dirk.holtwick@gmail.com
+
+LICENSE
+=======
+
+Copyright 2010 Dirk Holtwick, holtwick.it
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+3.0.33

demo/cherrypy/demo-cherrypy.conf

+[global]
+server.socket_host = "localhost"
+server.socket_port = 8080
+server.thread_pool = 10

demo/cherrypy/demo-cherrypy.html

+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:py="http://purl.org/kid/ns#">
+  <head>
+    <title>PDF Demo</title>
+  </head>
+  <body>
+    <h1>PDF Demo</h1>
+    <p>Please enter some HTML (and KID) code:</p>
+    <form action="download" method="post" enctype="multipart/form-data">
+        <textarea name="data" style="width:100%; height: 200px;"><p py:for="x in range(3)">
+  Hello
+  <strong>World</strong>
+  #${x+1}
+</p></textarea>
+        <br />
+        <input type="submit" value="Convert HTML to PDF" />
+    </form>
+  </body>
+</html>

demo/cherrypy/demo-cherrypy.py

+#!/usr/local/bin/python
+# -*- coding: ISO-8859-1 -*-
+#############################################
+## (C)opyright by Dirk Holtwick, 2008      ##
+## All rights reserved                     ##
+#############################################
+
+import cherrypy as cp
+import sx.pisa3 as pisa
+import cStringIO as StringIO
+
+try:
+    import kid
+except:
+    kid = None
+
+class PDFDemo(object):
+
+    """
+    Simple demo showing a form where you can enter some HTML code.
+    After sending PISA is used to convert HTML to PDF and publish
+    it directly.
+    """
+
+    @cp.expose
+    def index(self):
+        if kid:
+            return file("demo-cherrypy.html","r").read()
+
+        return """
+        <html><body>
+            Please enter some HTML code:
+            <form action="download" method="post" enctype="multipart/form-data">
+            <textarea name="data">Hello <strong>World</strong></textarea>
+            <br />
+            <input type="submit" value="Convert HTML to PDF" />
+            </form>
+        </body></html>
+        """
+
+    @cp.expose
+    def download(self, data):
+
+        if kid:
+            data = """<?xml version="1.0" encoding="utf-8"?>
+                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+                  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+                <html xmlns="http://www.w3.org/1999/xhtml"
+                      xmlns:py="http://purl.org/kid/ns#">
+                  <head>
+                    <title>PDF Demo</title>
+                  </head>
+                  <body>%s</body>
+                </html>""" % data
+            test = kid.Template(source=data)
+            data = test.serialize(output='xhtml')
+
+        result = StringIO.StringIO()
+        pdf = pisa.CreatePDF(
+            StringIO.StringIO(data),
+            result
+            )
+        if pdf.err:
+            return "We had some errors in HTML"
+        else:
+            cp.response.headers["content-type"] = "application/pdf"
+            return result.getvalue()
+
+cp.tree.mount(PDFDemo())
+
+if __name__ == '__main__':
+    import os.path
+    cp.config.update(os.path.join(__file__.replace(".py", ".conf")))
+    cp.server.quickstart()
+    cp.engine.start()
Add a comment to this file

demo/djangoproject/__init__.py

Empty file added.

demo/djangoproject/django-admin.py

+#!/usr/bin/env python
+from django.core import management
+
+if __name__ == "__main__":
+    management.execute_from_command_line()

demo/djangoproject/ezpdf.py

+#! /usr/bin/python
+# -*- encoding: utf-8 -*-
+
+from django.template.loader import get_template
+from django.template import Context
+from django.http import HttpResponse
+import cStringIO as StringIO
+from sx.pisa3 import pisaDocument
+import cgi
+
+def render_to_pdf(template_src, context_dict):
+    '''
+    Renderiza el template con el contexto.
+    Envía al cliente la Respuesta HTTP del contenido PDF para
+    el template renderizado.
+    '''
+    template = get_template(template_src)
+    context = Context(context_dict)
+    html  = template.render(context)
+    result = StringIO.StringIO()
+    pdf = pisaDocument(StringIO.StringIO(html.encode("ISO-8859-1")), result)
+    if not pdf.err:
+        return HttpResponse(result.getvalue(), mimetype='application/pdf')
+    return HttpResponse('We had some errors<pre>%s</pre>' % cgi.escape(html))

demo/djangoproject/manage.py

+#!/usr/bin/env python
+from django.core.management import execute_manager
+
+# Patch for Python 2.5
+
+try:
+    import sitecustomize
+except:
+    pass
+
+# Set logging
+
+import logging
+
+try:
+    logging.basicConfig(
+        level=logging.WARN,
+        format="%(levelname)s [%(name)s] %(pathname)s line %(lineno)d in %(funcName)s: %(message)s")
+except:
+    logging.basicConfig()
+
+try:
+    import settings # Assumed to be in the same directory.
+except ImportError:
+    import sys
+    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+    sys.exit(1)
+
+if __name__ == "__main__":
+    execute_manager(settings)

demo/djangoproject/settings.py

+# Django settings for the example project.
+
+import os
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+ROOT_URLCONF = 'djangoproject.urls'
+TEMPLATE_DIRS = (
+    os.path.join(os.path.dirname(__file__), 'templates'),
+)
+

demo/djangoproject/templates/base.html

+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<title>
+{%block title%}	
+{%endblock%}
+</title>
+<style type="text/css">
+{% block style %}
+	@page {
+		size: {{pagesize}};
+		margin: 1cm;
+		@frame footer {
+    		-pdf-frame-content: footerContent;
+    		bottom: 1cm;
+    		margin-left: 1cm;
+    		margin-right: 1cm;
+    		height: 1cm;
+		}
+	}
+{%endblock%}	
+</style>
+</head>
+<body>
+<div>
+{%block page_header%}
+   <div>
+   		<h1>pisa html<span style="color: #FC0000;">to</span>pdf</h1>
+   		<h2>Python module for HTML/CSS to PDF conversion - Ezpdf example</h2>
+   </div>
+	<hr />
+{%endblock%}
+{%block content%}
+{%endblock%}
+</div>
+<div id="footerContent">
+{%block page_foot%}
+		<pdf:pagenumber>
+{%endblock%}
+</div>
+</body>
+</html>

demo/djangoproject/templates/entries.html

+{% extends "base.html" %}
+
+{% block title %}{{title}}{% endblock %}
+
+{% block content %}
+	{% for entry in blog_entries %}
+    	<h2>{{ entry.id }} {{ entry.title|upper }}</h2>
+    	<p style="margin-left:15px">{{ entry.body }}</p>
+	{% endfor %}
+{% endblock %}
+
+{%block page_foot%}
+	Sample page {{block.super}}
+{%endblock%}
+

demo/djangoproject/urls.py

+from django.conf.urls.defaults import *
+
+urlpatterns = patterns('',
+    (r'^$', 'djangoproject.views.index'),
+    (r'^download', 'djangoproject.views.download'),
+    (r'^ezpdf_sample', 'djangoproject.views.ezpdf_sample'),
+    
+)

demo/djangoproject/views.py

+#! /usr/bin/python
+# -*- encoding: utf-8 -*-
+
+from django import http
+from django.shortcuts import render_to_response
+from django.template.loader import get_template
+from django.template import Context
+import ho.pisa as pisa
+import cStringIO as StringIO
+import cgi
+
+def index(request):
+    return http.HttpResponse("""
+        <html><body>
+            <h1>Example 1</h1>
+            Please enter some HTML code:
+            <form action="/download/" method="post" enctype="multipart/form-data">
+            <textarea name="data">Hello <strong>World</strong></textarea>
+            <br />
+            <input type="submit" value="Convert HTML to PDF" />
+            </form>
+            <hr>
+            <h1>Example 2</h1>
+            <p><a href="ezpdf_sample">Example with template</a>
+        </body></html>
+        """)
+
+def download(request):
+    if request.POST:
+        result = StringIO.StringIO()
+        pdf = pisa.CreatePDF(
+            StringIO.StringIO(request.POST["data"]),
+            result
+            )
+
+        if not pdf.err:
+            return http.HttpResponse(
+                result.getvalue(),
+                mimetype='application/pdf')
+
+    return http.HttpResponse('We had some errors')
+
+def render_to_pdf(template_src, context_dict):
+    template = get_template(template_src)
+    context = Context(context_dict)
+    html  = template.render(context)
+    result = StringIO.StringIO()
+    pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("ISO-8859-1")), result)
+    if not pdf.err:
+        return http.HttpResponse(result.getvalue(), mimetype='application/pdf')
+    return http.HttpResponse('We had some errors<pre>%s</pre>' % cgi.escape(html))
+
+def ezpdf_sample(request):
+    blog_entries = []
+    for i in range(1,10):
+        blog_entries.append({
+            'id': i,
+            'title':'Playing with pisa 3.0.16 and dJango Template Engine',
+            'body':'This is a simple example..'
+            })
+    return render_to_pdf('entries.html',{
+        'pagesize':'A4',
+        'title':'My amazing blog',
+        'blog_entries':blog_entries})

demo/tgpisa/dev.cfg

+[global]
+# This is where all of your settings go for your development environment
+# Settings that are the same for both development and production
+# (such as template engine, encodings, etc.) all go in
+# tgpisa/config/app.cfg
+
+# DATABASE
+
+# pick the form for your database
+# sqlobject.dburi="postgres://username@hostname/databasename"
+# sqlobject.dburi="mysql://username:password@hostname:port/databasename"
+# sqlobject.dburi="sqlite:///file_name_and_path"
+
+# If you have sqlite, here's a simple default to get you started
+# in development
+sqlobject.dburi="sqlite://%(current_dir_uri)s/devdata.sqlite"
+
+
+# if you are using a database or table type without transactions
+# (MySQL default, for example), you should turn off transactions
+# by prepending notrans_ on the uri
+# sqlobject.dburi="notrans_mysql://username:password@hostname:port/databasename"
+
+# for Windows users, sqlite URIs look like:
+# sqlobject.dburi="sqlite:///drive_letter:/path/to/file"
+
+# SERVER
+
+# Some server parameters that you may want to tweak
+# server.socket_port=8080
+
+# Enable the debug output at the end on pages.
+# log_debug_info_filter.on = False
+
+server.environment="development"
+autoreload.package="tgpisa"
+
+# Auto-Reload after code modification
+# autoreload.on = True
+
+# Set to True if you'd like to abort execution if a controller gets an
+# unexpected parameter. False by default
+tg.strict_parameters = True
+
+# LOGGING
+# Logging configuration generally follows the style of the standard
+# Python logging module configuration. Note that when specifying
+# log format messages, you need to use *() for formatting variables.
+# Deployment independent log configuration is in tgpisa/config/log.cfg
+[logging]
+
+[[loggers]]
+[[[tgpisa]]]
+level='DEBUG'
+qualname='tgpisa'
+handlers=['debug_out']
+
+[[[allinfo]]]
+level='INFO'
+handlers=['debug_out']
+
+[[[access]]]
+level='INFO'
+qualname='turbogears.access'
+handlers=['access_out']
+propagate=0
+
+

demo/tgpisa/sample-prod.cfg

+[global]
+# This is where all of your settings go for your production environment.
+# You'll copy this file over to your production server and provide it
+# as a command-line option to your start script.
+# Settings that are the same for both development and production
+# (such as template engine, encodings, etc.) all go in 
+# tgpisa/config/app.cfg
+
+# DATABASE
+
+# pick the form for your database
+# sqlobject.dburi="postgres://username@hostname/databasename"
+# sqlobject.dburi="mysql://username:password@hostname:port/databasename"
+# sqlobject.dburi="sqlite:///file_name_and_path"
+
+# If you have sqlite, here's a simple default to get you started
+# in development
+sqlobject.dburi="sqlite://%(current_dir_uri)s/devdata.sqlite"
+
+
+# if you are using a database or table type without transactions
+# (MySQL default, for example), you should turn off transactions
+# by prepending notrans_ on the uri
+# sqlobject.dburi="notrans_mysql://username:password@hostname:port/databasename"
+
+# for Windows users, sqlite URIs look like:
+# sqlobject.dburi="sqlite:///drive_letter:/path/to/file"
+
+
+# SERVER
+
+server.environment="production"
+
+# Sets the number of threads the server uses
+# server.thread_pool = 1
+
+# if this is part of a larger site, you can set the path
+# to the TurboGears instance here
+# server.webpath=""
+
+# Set to True if you are deploying your App behind a proxy
+# e.g. Apache using mod_proxy
+# base_url_filter.on = False
+
+# Set to True if your proxy adds the x_forwarded_host header
+# base_url_filter.use_x_forwarded_host = True
+
+# If your proxy does not add the x_forwarded_host header, set
+# the following to the *public* host url.
+# (Note: This will be overridden by the use_x_forwarded_host option
+# if it is set to True and the proxy adds the header correctly.
+# base_url_filter.base_url = "http://www.example.com"
+
+# Set to True if you'd like to abort execution if a controller gets an
+# unexpected parameter. False by default
+# tg.strict_parameters = False
+
+# LOGGING
+# Logging configuration generally follows the style of the standard
+# Python logging module configuration. Note that when specifying
+# log format messages, you need to use *() for formatting variables.
+# Deployment independent log configuration is in tgpisa/config/log.cfg
+[logging]
+
+[[handlers]]
+
+[[[access_out]]]
+# set the filename as the first argument below
+args="('server.log',)"
+class='FileHandler'
+level='INFO'
+formatter='message_only'
+
+[[loggers]]
+[[[tgpisa]]]
+level='ERROR'
+qualname='tgpisa'
+handlers=['error_out']
+
+[[[access]]]
+level='INFO'
+qualname='turbogears.access'
+handlers=['access_out']
+propagate=0

demo/tgpisa/setup.py

+# -*- coding: utf-8 -*-
+
+from setuptools import setup, find_packages
+from turbogears.finddata import find_package_data
+
+import os
+execfile(os.path.join("tgpisa", "release.py"))
+
+packages=find_packages()
+package_data = find_package_data(where='tgpisa',
+    package='tgpisa')
+if os.path.isdir('locales'):
+    packages.append('locales')
+    package_data.update(find_package_data(where='locales',
+        exclude=('*.po',), only_in_packages=False))
+
+setup(
+    name="tgpisa",
+    version=version,
+    # uncomment the following lines if you fill them out in release.py
+    #description=description,
+    #author=author,
+    #author_email=email,
+    #url=url,
+    #download_url=download_url,
+    #license=license,
+
+    install_requires=[
+        "TurboGears >= 1.0.4.3",
+        "SQLObject>=0.8,<=0.10.0"
+    ],
+    zip_safe=False,
+    packages=packages,
+    package_data=package_data,
+    keywords=[
+        # Use keywords if you'll be adding your package to the
+        # Python Cheeseshop
+
+        # if this has widgets, uncomment the next line
+        # 'turbogears.widgets',
+
+        # if this has a tg-admin command, uncomment the next line
+        # 'turbogears.command',
+
+        # if this has identity providers, uncomment the next line
+        # 'turbogears.identity.provider',
+
+        # If this is a template plugin, uncomment the next line
+        # 'python.templating.engines',
+
+        # If this is a full application, uncomment the next line
+        # 'turbogears.app',
+    ],
+    classifiers=[
+        'Development Status :: 3 - Alpha',
+        'Operating System :: OS Independent',
+        'Programming Language :: Python',
+        'Topic :: Software Development :: Libraries :: Python Modules',
+        'Framework :: TurboGears',
+        # if this is an application that you'll distribute through
+        # the Cheeseshop, uncomment the next line
+        # 'Framework :: TurboGears :: Applications',
+
+        # if this is a package that includes widgets that you'll distribute
+        # through the Cheeseshop, uncomment the next line
+        # 'Framework :: TurboGears :: Widgets',
+    ],
+    test_suite='nose.collector',
+    entry_points = {
+        'console_scripts': [
+            'start-tgpisa = tgpisa.commands:start',
+        ],
+    },
+    # Uncomment next line and create a default.cfg file in your project dir
+    # if you want to package a default configuration in your egg.
+    #data_files = [('config', ['default.cfg'])],
+    )

demo/tgpisa/start-tgpisa.py

+#!C:\Python25\python.exe
+# -*- coding: utf-8 -*-
+"""Start script for the tgpisa TurboGears project.
+
+This script is only needed during development for running from the project
+directory. When the project is installed, easy_install will create a
+proper start script.
+"""
+
+import sys
+
+from tgpisa.commands import start, ConfigurationError
+
+if __name__ == "__main__":
+    try:
+        start()
+    except ConfigurationError, exc:
+        sys.stderr.write(str(exc))
+        sys.exit(1)

demo/tgpisa/test.cfg

+[global]
+# You can place test-specific configuration options here (like test db uri, etc)
+
+# DATABASE
+
+sqlobject.dburi = "sqlite:///:memory:"
+
+# LOGGING
+
+[logging]
+
+[[formatters]]
+[[[full_content]]]
+format='*(asctime)s *(name)s *(levelname)s *(message)s'
+
+[[handlers]]
+[[[test_out]]]
+class='StreamHandler'
+level='DEBUG'
+args='(sys.stdout,)'
+formatter='full_content'
+
+[[loggers]]
+[[[tgpisa]]]
+level='DEBUG'
+qualname='tgpisa'
+handlers=['test_out']
+
+[[[turbogears]]]
+level='INFO'
+qualname='turbogears'
+handlers=['test_out']
Add a comment to this file

demo/tgpisa/tgpisa/__init__.py

Empty file added.

demo/tgpisa/tgpisa/commands.py

+# -*- coding: utf-8 -*-
+"""This module contains functions called from console script entry points."""
+
+import os
+import sys
+
+from os.path import dirname, exists, join
+
+import pkg_resources
+pkg_resources.require("TurboGears")
+
+import turbogears
+import cherrypy
+
+cherrypy.lowercase_api = True
+
+class ConfigurationError(Exception):
+    pass
+
+def start():
+    """Start the CherryPy application server."""
+
+    setupdir = dirname(dirname(__file__))
+    curdir = os.getcwd()
+
+    # First look on the command line for a desired config file,
+    # if it's not on the command line, then look for 'setup.py'
+    # in the current directory. If there, load configuration
+    # from a file called 'dev.cfg'. If it's not there, the project
+    # is probably installed and we'll look first for a file called
+    # 'prod.cfg' in the current directory and then for a default
+    # config file called 'default.cfg' packaged in the egg.
+    if len(sys.argv) > 1:
+        configfile = sys.argv[1]
+    elif exists(join(setupdir, "setup.py")):
+        configfile = join(setupdir, "dev.cfg")
+    elif exists(join(curdir, "prod.cfg")):
+        configfile = join(curdir, "prod.cfg")
+    else:
+        try:
+            configfile = pkg_resources.resource_filename(
+              pkg_resources.Requirement.parse("tgpisa"),
+                "config/default.cfg")
+        except pkg_resources.DistributionNotFound:
+            raise ConfigurationError("Could not find default configuration.")
+
+    turbogears.update_config(configfile=configfile,
+        modulename="tgpisa.config")
+
+    from tgpisa.controllers import Root
+
+    turbogears.start_server(Root())
Add a comment to this file

demo/tgpisa/tgpisa/config/__init__.py

Empty file added.

demo/tgpisa/tgpisa/config/app.cfg

+[global]
+# The settings in this file should not vary depending on the deployment
+# environment. dev.cfg and prod.cfg are the locations for
+# the different deployment settings. Settings in this file will
+# be overridden by settings in those other files.
+
+# The commented out values below are the defaults
+
+# VIEW
+
+# which view (template engine) to use if one is not specified in the
+# template name
+# tg.defaultview = "kid"
+
+# The following kid settings determine the settings used by the kid serializer.
+
+# Kid output method (e.g. html, html-strict, xhtml, xhtml-strict, xml, json)
+# and formatting (e.g. default, straight, compact, newlines, wrap, nice)
+# kid.outputformat="html default"
+
+# kid.encoding="utf-8"
+
+# The sitetemplate is used for overall styling of a site that
+# includes multiple TurboGears applications
+# tg.sitetemplate="<packagename.templates.templatename>"
+
+# Allow every exposed function to be called as json,
+# tg.allow_json = False
+
+# Suppress the inclusion of the shipped MochiKit version, which is rather outdated.
+# Attention: setting this to True and listing 'turbogears.mochikit' in 'tg.include_widgets'
+# is a contradiction. This option will overrule the default-inclusion to prevent version
+# mismatch bugs.
+# tg.mochikit_suppress = True
+
+# List of Widgets to include on every page.
+# for example ['turbogears.mochikit']
+# tg.include_widgets = []
+
+# Set to True if the scheduler should be started
+# tg.scheduler = False
+
+# Set to True to allow paginate decorator redirects when page number gets
+# out of bound. Useful for getting the real page id in the url
+# paginate.redirect_on_out_of_range = True
+
+# Set to True to allow paginate decorator redirects when last page is requested.
+# This is useful for getting the real last page id in the url
+# paginate.redirect_on_last_page = True
+
+# Set session or cookie
+# session_filter.on = True
+
+
+# compress the data sends to the web browser
+# [/]
+# gzip_filter.on = True
+# gzip_filter.mime_types = ["application/x-javascript", "text/javascript", "text/html", "text/css", "text/plain"]
+
+[/static]
+static_filter.on = True
+static_filter.dir = "%(top_level_dir)s/static"
+
+[/favicon.ico]
+static_filter.on = True
+static_filter.file = "%(top_level_dir)s/static/images/favicon.ico"

demo/tgpisa/tgpisa/config/log.cfg

+# LOGGING
+# Logging is often deployment specific, but some handlers and
+# formatters can be defined here.
+
+[logging]
+[[formatters]]
+[[[message_only]]]
+format='*(message)s'
+
+[[[full_content]]]
+format='*(asctime)s *(name)s *(levelname)s *(message)s'
+
+[[handlers]]
+[[[debug_out]]]
+class='StreamHandler'
+level='DEBUG'
+args='(sys.stdout,)'
+formatter='full_content'
+
+[[[access_out]]]
+class='StreamHandler'
+level='INFO'
+args='(sys.stdout,)'
+formatter='message_only'
+
+[[[error_out]]]
+class='StreamHandler'
+level='ERROR'
+args='(sys.stdout,)'

demo/tgpisa/tgpisa/controllers.py

+from turbogears import controllers, expose, flash
+# from tgpisa import model
+import pkg_resources
+try:
+    pkg_resources.require("SQLObject>=0.8,<=0.10.0")
+except pkg_resources.DistributionNotFound:
+    import sys
+    print >> sys.stderr, """You are required to install SQLObject but appear not to have done so.
+Please run your projects setup.py or run `easy_install SQLObject`.
+
+"""
+    sys.exit(1)
+# import logging
+# log = logging.getLogger("tgpisa.controllers")
+
+from turbogears.decorator import weak_signature_decorator
+import sx.pisa3 as pisa
+import cStringIO as StringIO
+import cherrypy
+
+def pdf(filename=None, content_type="application/pdf"):
+    def entangle(func):
+        def decorated(func, *args, **kw):
+            def kwpop(default, *names):
+                for name in names:
+                    if kw.has_key(name):
+                        return kw.pop(name)
+                return default
+
+            # get the output from the decorated function
+            output = func(*args, **kw)
+
+            dst = StringIO.StringIO()
+            result = pisa.CreatePDF(
+                StringIO.StringIO(output),
+                dst
+                )
+
+            # print cherrypy.url("index.html")
+            if not result.err:
+                cherrypy.response.headers["Content-Type"] = content_type
+                if filename:
+                    cherrypy.response.headers["Content-Disposition"] = "attachment; filename=" + filename
+                output = dst.getvalue()
+
+            return output
+        return decorated
+    return weak_signature_decorator(entangle)
+
+class Root(controllers.RootController):
+
+    @expose()
+    def index(self):
+        import time
+        return """<a href="pdf">Open PDF...</a>"""
+
+    @pdf(filename="test.pdf")
+    @expose(template="tgpisa.templates.welcome")
+    def pdf(self):
+        import time
+        # log.debug("Happy TurboGears Controller Responding For Duty")
+        flash("Your application is now running")
+        return dict(now=time.ctime())

demo/tgpisa/tgpisa/json.py

+# A JSON-based API(view) for your app.
+# Most rules would look like:
+# @jsonify.when("isinstance(obj, YourClass)")
+# def jsonify_yourclass(obj):
+#     return [obj.val1, obj.val2]
+# @jsonify can convert your objects to following types:
+# lists, dicts, numbers and strings
+
+from turbojson.jsonify import jsonify
+

demo/tgpisa/tgpisa/model.py

+from turbogears.database import PackageHub
+# import some basic SQLObject classes for declaring the data model
+# (see http://www.sqlobject.org/SQLObject.html#declaring-the-class)
+from sqlobject import SQLObject, SQLObjectNotFound, RelatedJoin
+# import some datatypes for table columns from SQLObject
+# (see http://www.sqlobject.org/SQLObject.html#column-types for more)
+from sqlobject import StringCol, UnicodeCol, IntCol, DateTimeCol
+
+__connection__ = hub = PackageHub('tgpisa')
+
+
+# your data model
+
+
+# class YourDataClass(SQLObject):
+#     pass
+
+

demo/tgpisa/tgpisa/release.py

+# Release information about tgpisa
+
+version = "1.0"
+
+# description = "Your plan to rule the world"
+# long_description = "More description about your plan"
+# author = "Your Name Here"
+# email = "YourEmail@YourDomain"
+# copyright = "Vintage 2006 - a good year indeed"
+
+# if it's open source, you might want to specify these
+# url = "http://yourcool.site/"
+# download_url = "http://yourcool.site/download"
+# license = "MIT"

demo/tgpisa/tgpisa/static/css/style.css

+/*
+ * Quick mash-up of CSS for the TG quick start page.
+ */
+
+html, body {
+  color: black;
+  background-color: #ddd;
+  font: x-small "Lucida Grande", "Lucida Sans Unicode", geneva, verdana, sans-serif;
+  margin: 0;
+  padding: 0;
+}
+
+td, th {padding:3px;border:none;}
+tr th {text-align:left;background-color:#f0f0f0;color:#333;}
+tr.odd td {background-color:#edf3fe;}
+tr.even td {background-color:#fff;}
+
+#header {
+  height: 80px;
+  width: 777px;
+  background: blue URL('../images/header_inner.png') no-repeat;
+  border-left: 1px solid #aaa;
+  border-right: 1px solid #aaa;
+  margin: 0 auto 0 auto;
+}
+
+a.link, a, a.active {
+  color: #369;
+}
+
+
+#main_content {
+  color: black;
+  font-size: 127%;
+  background-color: white;
+  width: 757px;
+  margin: 0 auto 0 auto;
+  border-left: 1px solid #aaa;
+  border-right: 1px solid #aaa;
+  padding: 10px;
+}
+
+#sidebar {
+  border: 1px solid #aaa;
+  background-color: #eee;
+  margin: 0.5em;
+  padding: 1em;
+  float: right;
+  width: 200px;
+  font-size: 88%;
+}
+
+#sidebar h2 {
+  margin-top: 0;
+}
+
+#sidebar ul {
+  margin-left: 1.5em;
+  padding-left: 0;
+}
+
+h1,h2,h3,h4,h5,h6,#getting_started_steps {
+  font-family: "Century Schoolbook L", Georgia, serif;
+  font-weight: bold;
+}
+
+h2 {
+  font-size: 150%;
+}
+
+#getting_started_steps a {
+  text-decoration: none;
+}
+
+#getting_started_steps a:hover {
+  text-decoration: underline;
+}
+
+#getting_started_steps li {
+  font-size: 80%;
+  margin-bottom: 0.5em;
+}
+
+#getting_started_steps h2 {
+  font-size: 120%;
+}
+
+#getting_started_steps p {
+  font: 100% "Lucida Grande", "Lucida Sans Unicode", geneva, verdana, sans-serif;
+}
+
+#footer {
+  border: 1px solid #aaa;
+  border-top: 0px none;
+  color: #999;
+  background-color: white;
+  padding: 10px;
+  font-size: 80%;
+  text-align: center;
+  width: 757px;
+  margin: 0 auto 1em auto;
+}
+
+.code {
+  font-family: monospace;
+}
+
+span.code {
+  font-weight: bold;
+  background: #eee;
+}
+
+#status_block {
+  margin: 0 auto 0.5em auto;
+  padding: 15px 10px 15px 55px;
+  background: #cec URL('../images/ok.png') left center no-repeat;
+  border: 1px solid #9c9;
+  width: 450px;
+  font-size: 120%;
+  font-weight: bolder;
+}
+
+.notice {
+  margin: 0.5em auto 0.5em auto;
+  padding: 15px 10px 15px 55px;
+  width: 450px;
+  background: #eef URL('../images/info.png') left center no-repeat;
+  border: 1px solid #cce;
+}
+
+.fielderror {
+    color: red;
+    font-weight: bold;
+}
Add a comment to this file

demo/tgpisa/tgpisa/static/images/favicon.ico

Added
New image
Add a comment to this file

demo/tgpisa/tgpisa/static/images/header_inner.png

Added
New image
Add a comment to this file

demo/tgpisa/tgpisa/static/images/info.png

Added
New image
Add a comment to this file

demo/tgpisa/tgpisa/static/images/ok.png

Added
New image
Add a comment to this file

demo/tgpisa/tgpisa/static/images/tg_under_the_hood.png

Added
New image
Add a comment to this file

demo/tgpisa/tgpisa/static/images/under_the_hood_blue.png

Added
New image
Add a comment to this file

demo/tgpisa/tgpisa/templates/__init__.py

Empty file added.

demo/tgpisa/tgpisa/templates/login.kid

+<!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"
+    xmlns:py="http://purl.org/kid/ns#">
+
+<head>
+    <meta content="text/html; charset=UTF-8"
+        http-equiv="content-type" py:replace="''"/>
+    <title>Login</title>
+    <style type="text/css">
+        #loginBox
+        {
+            width: 30%;
+            margin: auto;
+            margin-top: 10%;
+            padding-left: 10%;
+            padding-right: 10%;
+            padding-top: 5%;
+            padding-bottom: 5%;
+            font-family: verdana;
+            font-size: 10px;
+            background-color: #eee;
+            border: 2px solid #ccc;
+        }
+
+        #loginBox h1
+        {
+            font-size: 42px;
+            font-family: "Trebuchet MS";
+            margin: 0;
+            color: #ddd;
+        }
+
+        #loginBox p
+        {
+            position: relative;
+            top: -1.5em;
+            padding-left: 4em;
+            font-size: 12px;
+            margin: 0;
+            color: #666;
+        }
+
+        #loginBox table
+        {
+            table-layout: fixed;
+            border-spacing: 0;
+            width: 100%;
+        }
+
+        #loginBox td.label
+        {
+            width: 33%;
+            text-align: right;
+        }
+
+        #loginBox td.field
+        {
+            width: 66%;
+        }
+
+        #loginBox td.field input
+        {
+            width: 100%;
+        }
+
+        #loginBox td.buttons
+        {
+            text-align: right;
+        }
+
+    </style>
+</head>
+
+<body>
+    <div id="loginBox">
+        <h1>Login</h1>
+        <p>${message}</p>
+        <form action="${previous_url}" method="POST">
+            <table>
+                <tr>
+                    <td class="label">
+                        <label for="user_name">User Name:</label>
+                    </td>
+                    <td class="field">
+                        <input type="text" id="user_name" name="user_name"/>
+                    </td>
+                </tr>
+                <tr>
+                    <td class="label">
+                        <label for="password">Password:</label>
+                    </td>
+                    <td class="field">
+                        <input type="password" id="password" name="password"/>
+                    </td>
+                </tr>
+                <tr>
+                    <td colspan="2" class="buttons">
+                        <input type="submit" name="login" value="Login"/>
+                    </td>
+                </tr>
+            </table>
+
+            <input py:if="forward_url" type="hidden" name="forward_url"
+                value="${forward_url}"/>
+                
+            <div py:for="name,values in original_parameters.items()" py:strip="1">
+            <input py:for="value in isinstance(values, list) and values or [values]"
+                type="hidden" name="${name}" value="${value}"/>
+            </div>
+        </form>
+    </div>
+</body>
+</html>

demo/tgpisa/tgpisa/templates/master.kid

+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?python import sitetemplate ?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"
+    py:extends="sitetemplate">
+
+<head py:match="item.tag=='{http://www.w3.org/1999/xhtml}head'" py:attrs="item.items()">
+    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
+    <title py:replace="''">Your title goes here</title>
+    <meta py:replace="item[:]" name="description" content="master template"/>
+    <style type="text/css" media="screen">
+        #pageLogin
+        {
+            font-size: 10px;
+            font-family: verdana;
+            text-align: right;
+        }
+    </style>
+    <link rel="stylesheet" type="text/css" media="screen" href="../static/css/style.css"
+        py:attrs="href=tg.url('/static/css/style.css')"/>
+</head>
+
+<body py:match="item.tag=='{http://www.w3.org/1999/xhtml}body'" py:attrs="item.items()">
+    <div py:if="tg.config('identity.on') and not defined('logging_in')" id="pageLogin">
+        <span py:if="tg.identity.anonymous">
+            <a href="${tg.url('/login')}">Login</a>
+        </span>
+        <span py:if="not tg.identity.anonymous">
+            Welcome ${tg.identity.user.display_name or tg.identity.user.user_name}.
+            <a href="${tg.url('/logout')}">Logout</a>
+        </span>
+    </div>
+
+    <div id="header">&#160;</div>
+
+    <div id="main_content">
+        <div id="status_block" class="flash"
+            py:if="value_of('tg_flash', None)" py:content="tg_flash"></div>
+        <div py:replace="[item.text]+item[:]">page content</div>
+    </div>
+
+    <div id="footer">
+        <img src="${tg.url('/static/images/under_the_hood_blue.png')}"
+            alt="TurboGears under the hood" />
+        <p>TurboGears is a open source front-to-back web development framework
+            written in Python</p>
+        <p>Copyright &#169; 2007 Kevin Dangoor</p>
+    </div>
+</body>
+
+</html>

demo/tgpisa/tgpisa/templates/welcome.kid

+<!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" xmlns:py="http://purl.org/kid/ns#"
+    py:extends="'master.kid'">
+<head>
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type" py:replace="''"/>
+<title>Welcome to TurboGears</title>
+</head>
+<body>
+