Problem rendering a sorted table to PDF

4 views
Skip to first unread message

Bob Cotton

unread,
May 18, 2007, 12:01:39 AM5/18/07
to Ruby Reports
I have a table that was created from Hash data. When I sort the table,
then redner it to PDF I get the following error. It works fine for
HTML and Text.

/usr/local/lib/ruby/gems/1.8/gems/transaction-simple-1.4.0/lib/
transaction/simple.rb:129:in `dump': singleton can't be dumped
(TypeError)
from /usr/local/lib/ruby/gems/1.8/gems/transaction-
simple-1.4.0/lib/transaction/simple.rb:129:in `start_transaction'
from /usr/local/lib/ruby/gems/1.8/gems/transaction-
simple-1.4.0/lib/transaction/simple/group.rb:102:in
`start_transaction'
from /usr/local/lib/ruby/gems/1.8/gems/transaction-
simple-1.4.0/lib/transaction/simple/group.rb:102:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/transaction-
simple-1.4.0/lib/transaction/simple/group.rb:102:in
`start_transaction'
from /usr/local/lib/ruby/gems/1.8/gems/pdf-writer-1.1.3/lib/
pdf/simpletable.rb:397:in `render_on'
from /usr/local/lib/ruby/gems/1.8/gems/ruport-1.0.0/lib/ruport/
formatter/pdf.rb:324:in `draw_table'
from /usr/local/lib/ruby/gems/1.8/gems/pdf-writer-1.1.3/lib/
pdf/simpletable.rb:110:in `initialize'
from /usr/local/lib/ruby/gems/1.8/gems/ruport-1.0.0/lib/ruport/
formatter/pdf.rb:315:in `new'
... 12 levels...
from /usr/local/lib/ruby/gems/1.8/gems/ruport-1.0.0/lib/ruport/
data/table.rb:719:in `method_missing'
from table.rb:21
from table.rb:20:in `open'
from table.rb:20

Gregory Brown

unread,
May 18, 2007, 12:47:26 AM5/18/07
to ruby-r...@googlegroups.com
On 5/18/07, Bob Cotton <bob.c...@gmail.com> wrote:
>
> I have a table that was created from Hash data. When I sort the table,
> then redner it to PDF I get the following error. It works fine for
> HTML and Text.

can you send the inspect output of the table?

thanks,
greg

Ball, Donald A Jr (Library)

unread,
May 18, 2007, 4:09:14 PM5/18/07
to ruby-r...@googlegroups.com
> -----Original Message-----
> From: ruby-r...@googlegroups.com
> [mailto:ruby-r...@googlegroups.com] On Behalf Of Bob Cotton
> Sent: Thursday, May 17, 2007 11:02 PM
> To: Ruby Reports
> Subject: [ruport] Problem rendering a sorted table to PDF
>
>
> I have a table that was created from Hash data. When I sort
> the table, then redner it to PDF I get the following error.
> It works fine for HTML and Text.

A little while back when I ran into something similar it turned out that
I was putting arbitrary objects in the table, expecting to_s to be
called on them. Worked fine in text and HTML, barfed similarly in PDF.
Just a thought.

- donald

Gregory Brown

unread,
May 18, 2007, 4:57:55 PM5/18/07
to ruby-r...@googlegroups.com
On 5/18/07, Ball, Donald A Jr (Library) <donal...@nashville.gov> wrote:
>
> > -----Original Message-----
> > From: ruby-r...@googlegroups.com
> > [mailto:ruby-r...@googlegroups.com] On Behalf Of Bob Cotton
> > Sent: Thursday, May 17, 2007 11:02 PM
> > To: Ruby Reports
> > Subject: [ruport] Problem rendering a sorted table to PDF
> >
> >
> > I have a table that was created from Hash data. When I sort
> > the table, then redner it to PDF I get the following error.
> > It works fine for HTML and Text.

This is the issue I'm suspecting that could be what Bob is running
into. I wonder, should we add the explicit to_s action? If Text and
HTML behave that way, pehaps a bug for them not to be uniform. What
are your thoughts on this Donald?

Ball, Donald A Jr (Library)

unread,
May 21, 2007, 11:29:51 AM5/21/07
to ruby-r...@googlegroups.com
> This is the issue I'm suspecting that could be what Bob is
> running into. I wonder, should we add the explicit to_s
> action? If Text and HTML behave that way, pehaps a bug for
> them not to be uniform. What are your thoughts on this Donald?

I think that would be a good change. It's what I expected would happen,
and apparently this developer did as well.

- donald

Gregory Brown

unread,
May 21, 2007, 11:47:26 AM5/21/07
to ruby-r...@googlegroups.com

I'm willing to patch 1.0, but I need a reproducable bug report
(preferably a unit test) that shows the issue. I can investigate
that myself soon, but since you've both ran into that, it'd speed
things up a whole lot if you can show me some code that breaks.

Bob Cotton

unread,
May 21, 2007, 6:33:04 PM5/21/07
to Ruby Reports
Actually I'm putting objects into the table expecting to_hash to be
called on them (which I believe they are). My objects are backed by a
hash, which is just returned. @data looks just like the hash I'm
returning from to_hash

My #inspect output is very large, but here's the first Record:

#<Ruport::Data::Table:0x218336c

@column_names=[:formatted_i_d, :name, :priority, :severity, :found_in_build],
@data=
[#<Ruport::Data::Record:0x218304c

@attributes=[:formatted_i_d, :name, :priority, :severity, :found_in_build],
@data=
{:task_remaining_total=>"0.0",
:priority=>"Low",
:blocked=>"false",
:name=>"Salesforce integration broken in User Story Mode",
:formatted_i_d=>"DE46",
:salesforce_case_number=>"00004239",
:notes=>nil,
:tasks=>nil,
:severity=>"Major Problem",
:environment=>"Production",
:schedule_state=>"Defined",
:owner=>"mri...@rallydev.com",
:customer=>"Arc Solutions",
:opened_date=>"2007-04-25T16:48:25.000Z",
:object_i_d=>"42222945",
:submitted_by=>"ashley",
:state=>"Open",
:revision_history=>
#<RestObject:0x2153068
@document=<UNDEFINED> ... </>,
@document_content=
"<RevisionHistory rallyAPIMajor='1' type='RevisionHistory'
rallyAPIMinor='0' ref='https://rally1.rallydev.com:443/slm/webservice/
1.0/revisionhistory/42222946'/>",
@elements=nil,
@password="xxx",
@rally_rest=
#<RallyRestAPI:0x5b1490
@base_url="https://rally1.rallydev.com/slm",
@builder=
#<RestBuilder:0x5b1440
@base_url="https://rally1.rallydev.com/slm",
@password="xxx",
@username="bob">,
@logger=nil,
@parse_collections_as_hash=false,
@password="xxx",
@raise_on_warning=nil,
@username="bob">,
@username="bob">,
:description=>"Affects both APM and Salesforce",
:workspace=>
#<RestObject:0x2156830
@document=<UNDEFINED> ... </>,
@document_content=
"<Workspace rallyAPIMajor='1' type='Workspace'
rallyAPIMinor='0' refObjectName='Rally' ref='https://
rally1.rallydev.com:443/slm/webservice/1.0/workspace/41529001'/>",
@elements=nil,
@password="xxx",
@rally_rest=
#<RallyRestAPI:0x5b1490
@base_url="https://rally1.rallydev.com/slm",
@builder=
#<RestBuilder:0x5b1440
@base_url="https://rally1.rallydev.com/slm",
@password="xxx",
@username="bob">,
@logger=nil,
@parse_collections_as_hash=false,
@password="xxx",
@raise_on_warning=nil,
@username="bob">,
@username="bob">,
:exception_email=>"false",
:release_note=>"false",
:task_actual_total=>"0.0",
:affects_doc=>"false",
:resolution=>"None",
:creation_date=>"2006-12-04T20:21:17.000Z",
:task_estimate_total=>"0.0",
:attachments=>nil,
:salesforce_case_i_d=>"50030000002tUtA",
:duplicates=>nil,
:subscription=>
#<RestObject:0x2158130
@document=<UNDEFINED> ... </>,
@document_content=
"<Subscription rallyAPIMajor='1' type='Subscription'
rallyAPIMinor='0' refObjectName='Rally Development' ref='https://
rally1.rallydev.com:443/slm/webservice/1.0/subscription/400059'/>",
@elements=nil,
@password="xxx",
@rally_rest=
#<RallyRestAPI:0x5b1490
@base_url="https://rally1.rallydev.com/slm",
@builder=
#<RestBuilder:0x5b1440
@base_url="https://rally1.rallydev.com/slm",
@password="xxx",
@username="bob">,
@logger=nil,
@parse_collections_as_hash=false,
@password="xxx",
@raise_on_warning=nil,
@username="bob">,
@username="bob">}>,
#<Ruport::Data::Record:0x2182e08
@attributes=[:formatted_i_d, :name, :priority, :severity,
:found_in_build],

[and so on]

On May 18, 2:09 pm, "Ball, Donald A Jr \(Library\)"

Gregory Brown

unread,
May 21, 2007, 6:43:40 PM5/21/07
to ruby-r...@googlegroups.com
On 5/21/07, Bob Cotton <bob.c...@gmail.com> wrote:
>
> Actually I'm putting objects into the table expecting to_hash to be
> called on them (which I believe they are). My objects are backed by a
> hash, which is just returned. @data looks just like the hash I'm
> returning from to_hash

Hmm... It seems like that :revision_history data may be to blame.

I will look at the to_hash implementation and see if anything strange
might be happening with it, but let me know what happens when you drop
the :revision_history data.

Bob Cotton

unread,
Jun 4, 2007, 10:37:35 PM6/4/07
to Ruby Reports
Ok, found it. There were values in the hash that were not Marshal-
able. Learned all about what can
be Marshal'ed and what cant.

All good now.
-Bob

On May 21, 4:43 pm, "Gregory Brown" <gregory.t.br...@gmail.com> wrote:

Gregory Brown

unread,
Jun 4, 2007, 10:41:55 PM6/4/07
to ruby-r...@googlegroups.com
On 6/4/07, Bob Cotton <bob.c...@gmail.com> wrote:
>
> Ok, found it. There were values in the hash that were not Marshal-
> able. Learned all about what can
> be Marshal'ed and what cant.

Oh, right. PDF::Writer depends on being able to roll back
transactions, so the objects need to be serializable.

Good to know we can safely close this issue for now.

Reply all
Reply to author
Forward
0 new messages