set_uk has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to identify the most painless way for generating object classes (so that I have many of the accessor methods defined for me etc) and for persisting and iterating over objects.

I have looked about and it appears SPOPS satisfies in most areas.

I dont fully understand the documentation and am about to start to try it out but thought I would ask the following questions first:-

1) All SPOPS field data examples I have looked at use single scalar values - can hashes and arrays be used as class data in an SPOPS object. If so is it as simple as defining a field and then setting it equal to a hash?

2) I understand that when SPOPS creates a class it can inherit methods from other classes via the isa config variable - how else can class methods specific to the new class be defined.

3) Where else can I find some worked examples.

Replies are listed 'Best First'.
Re: SPOPS Question
by lachoy (Parson) on May 26, 2003 at 20:39 UTC

    1) I'm not sure what you mean by 'class data'. Every SPOPS class stores its configuration in a hashref accessible with $class->CONFIG, and the values in that hashref can be any normal Perl scalar (hashref, arrayref, etc.)

    If you mean 'instance data', then that's a different matter. Serializing hashrefs and arrayrefs to a database is nontrivial, although the SPOPS::LDAP implementation does this fairly well.

    2) You can define one or more classes in 'code class' whose methods get read into the generated class at initialization.

    3) If you've downloaded the SPOPS source, check out the 'eg/' directory for a number of examples (see the README file there for pointers). The documentation (also web accessible) has a number of examples scattered throughout as well.

    Also, feel free to post questions to the openinteract-help mailing list (that's where SPOPS is supported).

    Chris
    M-x auto-bs-mode

      Yes I did mean instance data (just going up the OO learning curve as well :-) )