[Dbix-class] class layout [was "Alias" schema option]

Richard Jolly richardjolly at mac.com
Wed Jul 26 00:22:39 CEST 2006


On 24 Jul 2006, at 18:54, Brandon Black wrote:

> On 7/24/06, Richard Jolly <richardjolly at mac.com> wrote:
>> On 5 Apr 2006, at 16:39, Brandon Black wrote:
>>
>> [snip]
>>
>>> This also touches on (to some degree) the whole issue of best
>>> practices for namespace management (class names) of the various
>>> classes related to a single table (the ResultSource, the ResultSet,
>>> and the Result classes), ResultSetManager and the related issues of
>>> "default" resultset_class's (::_resultset? ::ResultSet?
>>> MySchema::ResultSet::Foo? etc) and the load_classes M::F thing (in
>>> that it would be nice if ->load_classes() would pick up
>>> resultset/result classes that fit the default naming convention and
>>> stuff them in the right place).
>>
>> What is the current best practice for package layout of user-written
>> code?
>>
>> Currently we have files like:
>>
>> Project/Schema/Foo.pm            # table definition
>> Project/Schema/ResultSet/Foo.pm  # resultset additions
>> Project/Foo.pm                   # returned object additions
>>
>> Since Project::Foo objects are returned from
>> $schema->resultset('Foo')->search, we defined additional methods 
>> needed
>> in that package. But should they be there, or defined in
>> Project::Schema::Foo?
>
> I don't think there's anything wrong with what you're doing now.
>
> I'm working on a feature for 0.08 (which hasn't been discussed or
> approved by general consensus yet, so it might just die where its at,
> or change significantly, ymmv), which adds a method "load_namespaces"
> to Schema.pm.  There's a branch for it at
> branches/DBIx-Class/load_namespaces.  These are the docs for it atm
> (notice that I didn't add a facility for custom row objects yet, but
> it would follow the same scheme as what you see here for sources and
> resultsets).

[snip details]

I'd like this very much. Having a default layout just makes it easier.

Richard




More information about the Dbix-class mailing list