**WPSC_Countries**

Before your read to much farther , if you want to do things with countries, regions or currencies you want to take a look at these classes:

    WPSC_Country  - found in file wpsc-country.class.php
    WPSC_Region   - found in file wpsc-regions.class.php
    WPSC_Currency - found in file wpsc-currency.class.php

These three classes make up the bulk of developer facing classes. After reviewing these classes the login within the WPSC_Countires class will have context.

*About WPSC_Countries:
WPSC_Countries is a WPeC class used to provide easy access to country, region and currency information for all of WPeC an any extensions. Because this data isus  eoften throughout WPeC it is designed to be quick, memory efficient and avoid accessing the database.

The primary purpose of the is class is to centralize the access to country/region/currency data, act as a service provider for access of the data, act as a central place to keep the data set to avoid replicating it many times during execution of the code, and in the end make it very fast and efficient to work with country/region/currency data.

This class is largely procedural, and has many static methods that let the caller get access to country/region/currency data.

*A Note to you OOP purists:
Yes, if you are looking for this can be thought of as a singleton class, as could some aspects of the prior implementation of the WPSC_Country class that have been migrated to here. Only one of these  lasses is entirely appropriate until we start supporting e-commerce from other planets. At that time each planet would have it's own WPSC_Countries class object.  Until that happens the more pervasive use of static variables and methods improves performance enough to make it worthwhile.  I personally promise to make the necessary changes prior to having to support e-commerce to/from the Mars colony.

*How does it work?
This class uses the static currency and region information distributed with WPeC to create an
object that is optimized for access.  A copy of this object is cached.  When WPeC initialized
this cached object is retrieved and used to service any request for geographical data.

*How is this data refreshed if it is cached?
If an administrator changes country data in the WPeC admin tool the object will be rebuilt. If
WPeC is upgraded the object will be rebuilt. And, because the object is stored as a transient, any action that would refresh the WordPress object cache would cause the object

*Where is the global so I can access this data?
I'm not telling! (just kidding) ... There isn't one because I hate globals (and I want you to hate globals also).

You access geography data through the static methods available in WPSC_Countries, or by instantiating objects of type WPSC_Country, WPSC_Region, and WPSC_Currency

*What about the database?
Can you identify the film this quote comes from? ... Forget about Dave. For our immediate purposes, there is no Dave. Dave does not exist.

*Why is that important?
Forget about database. For our immediate purposes, there is no database. database does not exist.

If you use the functionality in this module it is unlikely you will need to find the data storage for the raw geography data. But, If you do any kind of update or modify operation on any of the data that this class uses please invoke the “clear_cache()” method so that the object can refresh itself.

*Before this class existed the direct queries to the database where really simple. Did creating this module really help?
uhhh, Yes. The checkout page was used as a benchmark.  When this class was there were almost 200 fewer queries to the database on just that page. Besides that there was a lot of duplicated code scattered about WPeC do get the data from the database. Much of that code had subtle variations that made it hard to maintain.

Any other benefits to this module over direct to database
Going direct the database prevented us from improving the mechanism used to store and distribute country data and updates without changing a lot of code.  Now all the database access is centralized we can make some improvements when we have time

The WPeC Geography implementation consists of four class

	WPSC_Country - Get anything about a single country you might want to know
	WPSC_Region - Get anything about a single region you might want to know
	WPSC_Currency - Get information about a currency
	WPSC_Countries - Get lists of countries, convert key fields to unique ids, and other useful functions. Also abstracts data storage mechanism from