nti.site.site module¶
Implementations of sites and helpers for working with sites.
-
class
nti.site.site.
BTreeLocalAdapterRegistry
(bases=())[source]¶ Bases:
zope.site.site._LocalAdapterRegistry
A persistent adapter registry that can switch its internal data structures to be more persistent friendly when they get large.
Caution
This registry doesn’t support registrations on bare classes. This is because the Implements and Provides objects returned on bare classes do not support comparison or equality and hence cannot be used in BTrees. (They only hash and compare equal to themselves; within the same process this works out because of aggressive caching on class objects.) Registering a utility to provide a bare class is quite hard to do, in any case. Registering adapters to require bare classes is easier but generally not a best practice.
-
btree_family
= <BTree family using 64 bits. Supports signed integer values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 and maximum unsigned integer value 18,446,744,073,709,551,615.>¶ The family for the provided map. Defaults to 64-bit maps. I.e., long.
-
btree_map_threshold
= 2000¶ The size at which individual keys in the lookup decision maps will be switched to BTrees. The map threshold is lower than the provided threshold because it is there are many keys in the map so the overall effect is amplified.
-
btree_oo_type
¶ alias of
BTrees.OOBTree.OOBTree
-
btree_provided_threshold
= 5000¶ The size at which the total number of registered adapters will be switched to a BTree.
-
-
class
nti.site.site.
BTreeLocalSiteManager
(site, default_folder=True)[source]¶ Bases:
nti.site.site.BTreePersistentComponents
,zope.site.site.LocalSiteManager
Persistent local site manager that will be friendly to ZODB when they get large.
Caution
This registry doesn’t support bare class registrations. See
BTreeLocalAdapterRegistry
for details.
-
class
nti.site.site.
BTreePersistentComponents
(name='', bases=())[source]¶ Bases:
zope.component.persistentregistry.PersistentComponents
Persistent components that will be friendly to ZODB when they get large.
Note that despite the name, this class is not Persistent, only its internal components are.
Caution
This registry doesn’t support bare class registrations. See
BTreeLocalAdapterRegistry
for details.-
btree_family
= <BTree family using 64 bits. Supports signed integer values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 and maximum unsigned integer value 18,446,744,073,709,551,615.>¶
-
btree_threshold
= 5000¶ The size at which we will switch from maps to BTrees for registered adapters and registered utilities (individually).
-
-
class
nti.site.site.
SiteMapping
(**kw)[source]¶ Bases:
nti.schema.schema.SchemaConfigured
Maps one site to another.
:raises a
SiteNotFoundError
object if no site found-
source_site_name
¶ Computed attributes based on schema fields
Field properties provide default values, data validation and error messages based on data found in field meta-data.
Note that FieldProperties cannot be used with slots. They can only be used for attributes stored in instance dictionaries.
-
target_site_name
¶ Computed attributes based on schema fields
Field properties provide default values, data validation and error messages based on data found in field meta-data.
Note that FieldProperties cannot be used with slots. They can only be used for attributes stored in instance dictionaries.
-
-
exception
nti.site.site.
WrongRegistrationTypeError
[source]¶ Bases:
exceptions.TypeError
Raised if an adapter registration is of the wrong type.
Changed in version 1.0.1: This is no longer raised by this package.
-
nti.site.site.
find_site_components
(site_names, check_alternate=False)[source]¶ Return an (global, registered)
IComponents
implementation named for the first virtual site found in the sequence of site_names. If no such components can be found, returns none.
-
nti.site.site.
get_site_for_site_names
(site_names, site=None)[source]¶ Return an
ISite
implementation named for the first virtual site found in the sequence of site_names.First, we’ll attempt to find the registered persistent site; either given by the site name or redirected by a registered
ISiteMapping
pointing to a persistent site. Otherwise, we’ll look for a site without theISiteMapping
lookup.We’ll then look a registered persistent site having the same name as the registered global components found for site_names, then that site will be used. Otherwise, if there is only a registered global components, a non-persistent site that incorporates those components in the lookup order while still incorporating the current (or provided) site will be returned.
If no such site or components can be found, returns the fallback site (the current or provided site).
Parameters: - site_names – Sequence of strings giving the virtual host names to use.
- site – If given, this will be the fallback site (and site manager). If not given, then the currently installed site will be used.
Changed in version 1.2.0: Look for a
ISiteMapping
registration to map a non-persistent site to a persistent site.Changed in version 1.3.0: Prioritize
ISiteMapping
so that persistent sites can be mapped to other persistent sites.