New API reference documentation is available for testing at http://thewinecellarbook.com/daboDocTestAlt/. Please report any problems or suggestions on the dabo-users mailing list.

Class dReportWriter

The Dabo Report Writer Engine, which mixes a data cursor and a report
format file (.rfxml) to output a PDF.

For each row in the Cursor, a detail band is printed. For each page in the
report, the pageBackground, pageHeader, pageFooter, and pageForeground
bands are printed. For each defined grouping, the groupHeader and groupFooter
bands are printed.

Report variables can be defined as accumulators, or for any purpose you
need. All properties of the report form are evaluated at runtime, so that
you can achieve full flexibility and ultimate control.

There is also a pure-python interface available.

Properties

Application Bands BaseClass
BasePrefKey Canvas Class
CurrentBandName CurrentBandObj Cursor
Encoding HomeDirectory LogEvents
Name NoneDisplay OutputFile
PageCount PageNumber Parent
PreferenceManager PrintStatus ProgressControl
Record RecordNumber ReportForm
ReportFormFile ReportFormXML ShowBandOutlines
UseTestCursor

Events

ReportBegin ReportCancel ReportEnd
ReportEvent ReportIteration

Methods

afterInit autoBindEvents beforeInit
bindEvent bindEvents cancel
clearSpanningObjects convertParagraphsToMemos draw
drawPageCounts drawSpanningObjects getAbsoluteName
getBandHeight getColorTupleFromReportLab getFramesetCount
getFramesets getPageSize getProperties
getPt getReportLabColorTuple getStory
initEvents initProperties printBandOutline
ptToUnit raiseEvent setProperties
setPropertiesFromAtts storeSpanningObject storeUndo
unbindEvent undo write




Properties

Application
Read-only object reference to the Dabo Application object.  (dApp).

(inherited from dObject)
Bands
Provides runtime access to bands of the currently running report.

(inherited from ReportWriter)
BaseClass
The base Dabo class of the object. Read-only.  (class)

(inherited from dObject)
BasePrefKey
Base key used when saving/restoring preferences  (str)

(inherited from dObject)
Canvas
Returns a reference to the reportlab canvas object.

(inherited from ReportWriter)
Class
The class the object is based on. Read-only.  (class)

(inherited from dObject)
CurrentBandName
During a report run, returns the name of the currently printing band.

(inherited from ReportWriter)
CurrentBandObj
During a report run, returns a reference to the current band object.

(inherited from ReportWriter)
Cursor
Specifies the data cursor that the report runs against.

(inherited from ReportWriter)
Encoding
Specifies the encoding for unicode strings.  (str)

(inherited from ReportWriter)
HomeDirectory
Specifies the home directory for the report.

Resources on disk (image files, etc.) will be looked for relative to the
HomeDirectory if specified with relative pathing. The HomeDirectory should
be the directory that contains the report form file. If you set
self.ReportFormFile, HomeDirectory will be set for you automatically.
Otherwise, it will get set to self.Application.HomeDirectory.

(inherited from ReportWriter)
LogEvents
Specifies which events to log.  (list of strings)

If the first element is 'All', all events except the following listed events
will be logged.
Event logging is resource-intensive, so in addition to setting this LogEvents
property, you also need to make the following call:

	>>> dabo.eventLogging = True


(inherited from dObject)
Name
The name of the object.  (str)

(inherited from dObject)
NoneDisplay
Specifies the string displayed if Value is None  (str or None)

If None, self.Application.NoneDisplay will be used. If there's no
instantiated dApp, then "< None >" will be used.

(inherited from ReportWriter)
OutputFile
Specifies the output PDF file (name or file object).

(inherited from ReportWriter)
PageCount
Returns the page count at runtime.

(inherited from ReportWriter)
PageNumber
Returns the current page number at runtime.

(inherited from ReportWriter)
Parent
The containing object.  (obj)

(inherited from dObject)
PreferenceManager
Reference to the Preference Management object  (dPref)

(inherited from dObject)
PrintStatus
Specifies whether status info is printed to stdout.

(inherited from ReportWriter)
ProgressControl
Specifies the control to receive progress updates.

The specified control will be updated with every record processed. It must have
a updateProgress(current_row, num_rows) method.

For the default control, use dabo.ui.dReportProgress.
Record
Specifies the dictionary that represents the current record.

The report writer will automatically fill this in during the running
of the report. Allows expressions in the report form like:

	self.Record["cFirst"]

(inherited from ReportWriter)
RecordNumber
Returns the current record number of Cursor.

(inherited from ReportWriter)
ReportForm
Specifies the python report form data dictionary.

(inherited from ReportWriter)
ReportFormFile
Specifies the path and filename of the report form spec file.

(inherited from ReportWriter)
ReportFormXML
Specifies the report format xml.

(inherited from ReportWriter)
ShowBandOutlines
Specifies whether the report bands are printed with outlines for
debugging and informational purposes. In addition to the band, there is also
a caption with the band name at the x,y origin point for the band.

(inherited from ReportWriter)
UseTestCursor
Specifies whether the TestCursor in the spec file is used.

(inherited from ReportWriter)



Events

ReportBegin
Occurs at the beginning of the report.
ReportCancel
Occurs when the user cancels the report.
ReportEnd
Occurs at the end of the report.
ReportEvent

		
ReportIteration
Occurs when the RecordNumber changes at report runtime.



Methods

afterInit(self)
Subclass hook. Called after the object's __init__ has run fully.
Subclasses should place their __init__ code here in this hook, instead of
overriding __init__ directly, to avoid conflicting with base Dabo behavior.

(inherited from dObject)
autoBindEvents(self, force=True)
Automatically bind any on*() methods to the associated event.

User code only needs to define the callback, and Dabo will automatically
set up the event binding. This will satisfy lots of common cases where
you want an object or its parent to respond to the object's events.

To use this feature, just define a method on<EventName>(), or	if you
want a parent container to respond to the event, make a method in the
parent on<EventName>_<object Name or RegID>().

For example::
	
	class MyButton(dabo.ui.dButton):
		def onHit(self, evt):
			print "Hit!"

	class MyPanel(dabo.ui.dPanel):
		def afterInit(self):
			self.addObject(MyButton, RegID="btn1")

		def onHit_btn1(self, evt):
			print "panel: button hit!"

When the button is pressed, you'll see both 'hit' messages because of
auto event binding.

If you want to bind your events explicitly, you can turn off auto event
binding by calling::

	 dabo.autoBindEvents = False

This feature is inspired by PythonCard.

(inherited from EventMixin)
beforeInit(self, *args, **kwargs)
Subclass hook. Called before the object is fully instantiated.
Usually, user code should override afterInit() instead, but there may be
cases where you need to set an attribute before the init stage is fully
underway.

(inherited from dObject)
bindEvent(self, eventClass, function, _auto=False)
Bind a dEvent to a callback function.

(inherited from EventMixin)
bindEvents(self, bindings)
Bind a sequence of [dEvent, callback] lists.

(inherited from EventMixin)
cancel(self)
Cancel the report printout on the next iteration of self.Cursor.

(inherited from ReportWriter)
clearSpanningObjects(self, group=None)

			
(inherited from ReportWriter)
convertParagraphsToMemos(self)
Converts all Paragraph objects to Memo objects.

(inherited from ReportWriter)
draw(self, obj, origin=(0, 0), availableHeight=None, deferred=None)
Draw the given object on the Canvas.

The object is a dictionary containing properties, and	origin is the (x,y)
tuple where the object will be drawn.

availableHeight is the height available on the current page; deferred is
the contents of the object partially printed on the last page that needs
to continue printing now (paragraph story).

(inherited from ReportWriter)
drawPageCounts(self, pageNum, pageCount)

			
(inherited from ReportWriter)
drawSpanningObjects(self, origin=(0, 0), group=None)
Draw all spanning objects. Called when page is changing or group is ending.

(inherited from ReportWriter)
getAbsoluteName(self)
Return the fully qualified name of the object.

(inherited from dObject)
getBandHeight(self, bandDict)
Return the height of the band.

If the band's Height property is None, the height will be
calculated based on the objects in the band.

(inherited from ReportWriter)
getColorTupleFromReportLab(self, val)
Given a color tuple in reportlab format (values between 0 and 1), return
a color tuple in 0-255 format.

(inherited from ReportWriter)
getFramesetCount(self)
Returns the number of framesets in the report.

(inherited from ReportWriter)
getFramesets(self)
Returns a list of (idx, frameset, band) for every frameset in the report.

idx is the position in the Objects list for whatever band the
frameset is part of.

(inherited from ReportWriter)
getPageSize(self)

			
(inherited from ReportWriter)
getProperties(self, propertySequence=(), propsToSkip=(), ignoreErrors=False, *propertyArguments)
Returns a dictionary of property name/value pairs.

If a sequence of properties is passed, just those property values
will be returned. Otherwise, all property values will be returned.
The sequence of properties can be a list, tuple, or plain string
positional arguments. For instance, all of the following are
equivilent::

	print self.getProperties("Caption", "FontInfo", "Form")
	print self.getProperties(["Caption", "FontInfo", "Form"])
	t = ("Caption", "FontInfo", "Form")
	print self.getProperties(t)
	print self.getProperties(\*t)

An exception will be raised if any passed property names don't
exist, aren't actual properties, or are not readable (do not have
getter functions).

However, if an exception is raised from the property getter function,
the exception will get caught and used as the property value in the
returned property dictionary. This allows the property list to be
returned even if some properties can't be evaluated correctly by the
object yet.

(inherited from PropertyHelperMixin)
getPt(self, val)
Given a string or a number, convert the value into a numeric pt value.

Strings can have the unit appended, like "3.5 in", "2 cm", "3 pica", "10 mm".

> print self.getPt("1 in")
72
> print self.getPt("1")
1
> print self.getPt(1)
1

(inherited from ReportWriter)
getReportLabColorTuple(self, val)
Given a color tuple in rgb format (values between 0 and 255), return
a color tuple in reportlab 0-1 format.

(inherited from ReportWriter)
getStory(self, obj, overrideExpr=None, overrideFontSize=None)

			
(inherited from ReportWriter)
initEvents(self)
Hook for subclasses. User code should do custom event binding
here, such as::
	
	self.bindEvent(dEvents.GotFocus, self.customGotFocusHandler)
	

(inherited from dObject)
initProperties(self)
Hook for subclasses. User subclasses should set properties
here, such as::
	
	self.Name = "MyTextBox"
	self.BackColor = (192,192,192)
	

(inherited from dObject)
printBandOutline(self, band, x, y, width, height)

			
(inherited from ReportWriter)
ptToUnit(self, pt, unit)
Given a numeric pt like 36, return a string like '0.5 in'.

Warning, this isn't exact, and isn't intended to be.

(inherited from ReportWriter)
raiseEvent(self, eventClass, uiEvent=None, *args, **kwargs)
Send the event to all registered listeners.

If uiEvent is sent, dEvents.Event will be able to parse it for useful
information to send along to the callback. 

Additional arguments, if any, are sent along to the constructor	of the
event. While this feature exists so that UI-lib event handlers can pass
along information (such as the keystroke information in a key event), user
code may pass along additional arguments as well, which	will exist in the
event.EventData dictionary property.

In most cases, user code should call raiseEvent() with
the event class (dEvents.Hit, for example) as the only parameter.

(inherited from EventMixin)
setProperties(self, propDict={}, ignoreErrors=False, **propKw)
Sets a group of properties on the object all at once.

You have the following options for sending the properties:
	
	1) Property/Value pair dictionary
	2) Keyword arguments
	3) Both

The following examples all do the same thing::

	self.setProperties(FontBold=True, ForeColor="Red")
	self.setProperties({"FontBold": True, "ForeColor": "Red"})
	self.setProperties({"FontBold": True}, ForeColor="Red")


(inherited from PropertyHelperMixin)
setPropertiesFromAtts(self, propDict={}, ignoreExtra=True, context=None)
Sets a group of properties on the object all at once. This
is different from the regular setProperties() method because
it only accepts a dict containing prop:value pairs, and it
assumes that the value is always a string. It will convert
the value to the correct type for the property, and then set
the property to that converted value. If the value needs to be evaluated
in a specific namespace, pass that as the 'context' parameter.

(inherited from PropertyHelperMixin)
storeSpanningObject(self, obj, origin=(0, 0), group=None)
Store the passed spanning object for printing when the group or
page ends. Pass the group expr to identify group headers, or None to refer
to the pageHeader.

(inherited from ReportWriter)
storeUndo(self, *args)

			
(inherited from ReportWriter)
unbindEvent(self, eventClass=None, function=None)
Remove a previously registered event binding.

Removes all registrations that exist for the given binding for this
object. If event is None, all bindings for the passed function are
removed. If function is None, all bindings for the passed event are
removed. If both event and function are None, all event bindings are
removed.

(inherited from EventMixin)
undo(self)

			
(inherited from ReportWriter)
write(self, save=True)
Write the PDF file based on the ReportForm spec.

If the save argument is True (the default), the PDF file will be
saved and closed after the report form has been written. If False,
the PDF file will be left open so that additional pages can be added
with another call, perhaps after creating a different report form.

(inherited from ReportWriter)

Dabo 0.9.4 (rev. 7089)
9 Feb 2012 23:31:09