Up | Next Section | Contents

Factories


Factories provide the connection between objects in a product and the Zope Folder Add List. An entry appears in the Add List for each factory defined in a product. A product may have any number of factory objects.

Creating a factory for our InstantSite product would enable our product to be duplicated simply by selecting the factory from the Add List. Before creating the factory for our product, we need to copy the Home folder and the configuration DTML Methods, Designer and Builder, into the InstantSite product using the Zope copy and paste mechanisms.

Stan completes the following steps to duplicate the InstantSit e product.

After copying and renaming these objects, the InstantSite product appears as in Figure 29 .

Home, Designer and Builder In InstantSite

 

To create a factory, simply select the "Zope Factory" entry in the Available Objects and click. The "Create an Object Factory" form is presented, as shown in Figure 30 . Stan entered Instant Web Site as the "Add List Name" and selected "Designer" as the method to be invoked when the factory is added. Thus, when "Instant Web Site" is selected from the Add List, the Designer DTML Method prompting for the configuration information is rendered.

Factory available in Control Panel

 

When the factory is created, the permissions for that product must be established. The initial method should be the method invoked when using the product. Upon reviewing the "Define Permissions" view, you can disable or enable permissions based on the outcome of the product (Figure 31 ).

Product Permissions defined.

 

Placing the template object and configuration DTML Methods in a product folder made it unnecessary for the objects to be in the destination folder. When an object is added, however, these objects must be somehow accessed. When a new website is added to a destination folder, the Designer script is accessed by the effective address:

manage_addProduct/product_name/factory_name/object_name

Once the Designer script calls the Builder, the Builder script redirects the browser to the manage_main view of the address above. To redirect the browser to the contents view of the destination folder, the Builder's redirect method needs to be modified using function DestinationURL. This modification can be seen in Figure 32 .

Source of the modified Builder DTML Method

<dtml-var standard_html_header>

 

<dtml-with "manage_clone(Home,REQUEST['new_id'],REQUEST)">

<dtml-call "manage_changeProperties(

title=REQUEST['new_name'],

company_name=REQUEST['new_name'],

message=REQUEST['new_message'],

contact_phone=REQUEST['new_phone'],

)">

<dtml-call "logo.manage_upload(REQUEST['new_logo'])">

</dtml-with>

 

<dtml-call "RESPONSE.redirect( DestinationURL() +'manage_main?update_menu=1')">

 

Congratulations!

 

<dtml-var standard_html_footer>

 

Up | Next Section | Contents

Banner.Novgorod.Ru