On Wed, Feb 06, 2002 at 10:31:00AM -0500, Perrin Harkins wrote: > > So what I'd really like is some sort of 'interface' object that could be > > passed into the template instead of the 'real' object, which only has a > > subset of the methods available. > My approach to this is to not pass objects at all. I have my data objects > implement a method called view(), which returns a plain vanilla data > structure (usually a hash, possibly with nested lists, etc.) and pass that > to the template.
Hmmm ... my immediate problem with that is that as Class::DBI handles relational database mapping, this could easily end up pulling in the entire database! And then there's the circular structures ... for example, in a simple video shop example, the Video class has a 'stars' method returning a list of Star objects, each of which has a 'stars_in' method, returning a list of Video objects, each of which ... Part of the point of Class::DBI is that you don't load data until you need it, so pre-populating a data structure with all the data you might need isn't really a good fit... Tony
