Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:marinho/geraldo
Browse files Browse the repository at this point in the history
Conflicts:
	CHANGES
  • Loading branch information
marinho committed May 6, 2010
2 parents f04ec8b + 78f0bb5 commit 9a4ff09
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 2 deletions.
7 changes: 6 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
2010-05-06: Version 0.4.2-stable
2010-05-06: Version 0.4.3-stable
--------------------------------
* Fixed cross reference matrix and expressions to avoid use existing object as dictionary

2010-04-29: Version 0.4.2-stable
--------------------------------
* Implemented support to merge default_style to inherite reports
* Fixed ReportGroup.force_new_page that wasn't rendering page footer on the first page

2010-04-27: Version 0.4.1-stable
--------------------------------
* Implementing ReportGroup to support 'force_new_page' to force a new page for each new
Expand Down
2 changes: 1 addition & 1 deletion geraldo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
- tests - a package with automated doc tests.
"""

VERSION = (0, 4, 2, 'stable')
VERSION = (0, 4, 3, 'stable')

def get_version():
return '%d.%d.%d-%s'%VERSION
Expand Down
11 changes: 11 additions & 0 deletions geraldo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,17 @@ class ReportMetaclass(type):
"""This metaclass registers the declared classes to a local variable."""

def __new__(cls, name, bases, attrs):
# Merges default_style with inherited report classes
if isinstance(attrs.get('default_style', None), dict):
default_style = {}

for base in bases:
if isinstance(getattr(base, 'default_style', None), dict):
default_style.update(base.default_style)

default_style.update(attrs['default_style'])
attrs['default_style'] = default_style

new_class = super(ReportMetaclass, cls).__new__(cls, name, bases, attrs)

# Defines a registration ID
Expand Down
1 change: 1 addition & 0 deletions geraldo/generators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ def render_groups_headers(self):

# Forces a new page if this group is defined to do it
if not new_page and group.force_new_page and self._current_object_index > 0:
self.render_page_footer()
self.force_new_page(insert_new_page=False)

# Renders the group header band
Expand Down
39 changes: 39 additions & 0 deletions geraldo/tests/30-styles.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
STYLES
======

This test will be increased to support all kinds of report stylizing, including
widgets and graphic styles and templating.

>>> import os
>>> cur_dir = os.path.dirname(os.path.abspath(__file__))

>>> from geraldo import Report, ReportBand, DetailBand, SubReport, ReportGroup,\
... Label, ObjectValue, SystemField, BAND_WIDTH
>>> from geraldo.utils import cm, A4, TA_RIGHT, TA_LEFT
>>> from geraldo.generators import PDFGenerator

Data to test
------------

>>> numbers = [{'number': number} for number in range(100)]
>>> letters = [{'letter': chr(ch)} for ch in range(65,91)] + [{'letter': chr(ch)} for ch in range(97,123)]

A base report
-------------

Just a simple report to be inherited

>>> class BaseReport(Report):
... page_size = A4
... default_style = {'fontName': 'Helvetica'}

>>> class MyReport(BaseReport):
... default_style = {'fontSize': 6}
... class band_detail(DetailBand):
... height = 0.5*cm
... elements = [ObjectValue(expression='number')]

>>> report = MyReport(queryset=numbers)

>>> report.generate_by(PDFGenerator, filename=os.path.join(cur_dir, 'output/testing-styles.pdf'))

0 comments on commit 9a4ff09

Please sign in to comment.