<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Factories — zope.component 4.4.1 documentation</title> <link rel="stylesheet" href="_static/alabaster.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <script type="text/javascript" src="_static/language_data.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="Persistent Component Management" href="persistentregistry.html" /> <link rel="prev" title="Events" href="event.html" /> <link rel="stylesheet" href="_static/custom.css" type="text/css" /> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> </head><body> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="factories"> <h1>Factories<a class="headerlink" href="#factories" title="Permalink to this headline">¶</a></h1> <div class="section" id="the-factory-class"> <h2>The Factory Class<a class="headerlink" href="#the-factory-class" title="Permalink to this headline">¶</a></h2> <div class="section" id="calling-a-factory"> <h3>Calling a Factory<a class="headerlink" href="#calling-a-factory" title="Permalink to this headline">¶</a></h3> <p>Here we test whether the factory correctly creates the objects and including the correct handling of constructor elements.</p> <p>First we create a factory that creates instanace of the <cite>Klass</cite> class:</p> <p>Now we use the factory to create the instance</p> <p>and make sure that the correct class was used to create the object:</p> <p>Since we passed in a couple positional and a keyword argument</p> </div> <div class="section" id="title-and-description"> <h3>Title and Description<a class="headerlink" href="#title-and-description" title="Permalink to this headline">¶</a></h3> </div> <div class="section" id="provided-interfaces"> <h3>Provided Interfaces<a class="headerlink" href="#provided-interfaces" title="Permalink to this headline">¶</a></h3> </div> </div> <div class="section" id="the-component-architecture-factory-api"> <h2>The Component Architecture Factory API<a class="headerlink" href="#the-component-architecture-factory-api" title="Permalink to this headline">¶</a></h2> <div class="section" id="creating-an-object"> <h3>Creating an Object<a class="headerlink" href="#creating-an-object" title="Permalink to this headline">¶</a></h3> </div> <div class="section" id="accessing-provided-interfaces"> <h3>Accessing Provided Interfaces<a class="headerlink" href="#accessing-provided-interfaces" title="Permalink to this headline">¶</a></h3> </div> <div class="section" id="list-of-all-factories"> <h3>List of All Factories<a class="headerlink" href="#list-of-all-factories" title="Permalink to this headline">¶</a></h3> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h1 class="logo"><a href="index.html">zope.component</a></h1> <h3>Navigation</h3> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="narr.html">Zope Component Architecture</a></li> <li class="toctree-l1"><a class="reference internal" href="socketexample.html">The Zope 3 Component Architecture (Socket Example)</a></li> <li class="toctree-l1"><a class="reference internal" href="event.html">Events</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="#">Factories</a><ul> <li class="toctree-l2"><a class="reference internal" href="#the-factory-class">The Factory Class</a></li> <li class="toctree-l2"><a class="reference internal" href="#the-component-architecture-factory-api">The Component Architecture Factory API</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="persistentregistry.html">Persistent Component Management</a></li> <li class="toctree-l1"><a class="reference internal" href="zcml.html">ZCML directives</a></li> <li class="toctree-l1"><a class="reference internal" href="configure.html">Package configuration</a></li> <li class="toctree-l1"><a class="reference internal" href="hooks.html">The current component registry</a></li> <li class="toctree-l1"><a class="reference internal" href="testlayer.html">Layers</a></li> <li class="toctree-l1"><a class="reference internal" href="api.html"><code class="docutils literal notranslate"><span class="pre">zope.component</span></code> API Reference</a></li> <li class="toctree-l1"><a class="reference internal" href="hacking.html">Hacking on <code class="docutils literal notranslate"><span class="pre">zope.component</span></code></a></li> </ul> <div class="relations"> <h3>Related Topics</h3> <ul> <li><a href="index.html">Documentation overview</a><ul> <li>Previous: <a href="event.html" title="previous chapter">Events</a></li> <li>Next: <a href="persistentregistry.html" title="next chapter">Persistent Component Management</a></li> </ul></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3>Quick search</h3> <div class="searchformwrapper"> <form class="search" action="search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="footer"> ©Zope Foundation and Contributors. | Powered by <a href="http://sphinx-doc.org/">Sphinx 1.8.3</a> & <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.8</a> | <a href="_sources/factory.rst.txt" rel="nofollow">Page source</a> </div> </body> </html>