The $RemoteURI parameter tells Lookup::Remote which URI to request user information from, given a user-id. It performs this request via LWP. The User class encapsulates information concerning a user (surprise!).

To avoid heavy network traffic, user data is cached locally for a time, so when $user->info is requested, the user code first tries Lookup::Local to determine if information is cached locally, and if not then uses Lookup::Remote (I realise these are less than perfect names, but they suffice).

It's actually not separated out like that (there is just one Lookup class to perform the actual information collection), but for the purposes of discussion it might help to know that there are potentially two steps to determine user information.

The $RemoteURI doesn't relate at all to the User, it is just where information will be pulled from - it's configurable, because one installation of the code may be configured to query server A, while another is configured for server B; and it's a class variable because all instances of the class have to hit the same server, and it seems wasteful to store this per-instance. The nature of this product means that round-robin DNS or other centralised user management is not an option.

Some very simplified sample code is shown below, with questionable bits commented.

use User; my $config = AppConfig->new; $config->define( remote_uri => { DEFAULT => '', ARGCOUNT => ARGCOUNT_ONE } ); # config file sets remote_uri; $config->file('/path/to/conf'); ### I'm trying to avoid having to do this. use Lookup::Remote; Lookup::Remote->remote_uri($config->remote_uri); ####### # Set user data from cache or remote as available. my $user = User->new(id => '1234')->init(); # Do stuff with $user..

--
Now hiring in Atlanta. /msg moot for details.


In reply to Re^2: OO, Library Configuration and Class Variables by moot
in thread OO, Library Configuration and Class Variables by moot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.