官术网_书友最值得收藏!

Installing the product

Congratulations! You have created your first Archetypes-based content type.

Let's add it in our already configured Zope instance to see what it looks like.

Instead of using the ArchGenXML product as it is, we will wrap it in an egg structure and install it in the src folder of our buildout.

How to do it…

First of all, we must create the egg structure that will hold the ArchGenXML generated code:

  1. Go to your buildout folder and create — if not created yet — a src folder.
    mkdir ./src
    
  2. Then call paster to create the egg folder structure:
    paster create -t plone 
    

It will start a very short wizard to select some options for our product. Most important is the first one:

Add whatever you want to the remaining options or just hit Enter to each one.

Once finished, paster should have created a folder structure like:

Products.poxContentTypes

+ docs

+ Products

+ poxContentTypes

...

- __init__.py

+ Products.poxContentTypes.egg-info

- dependency_links.txt

...

- README.txt

- setup.cfg

- setup.py

The new egg product is empty, but we already have some code that ArchGenXML has generated. So let's use it to make things work.

  1. Copy all the contents of ./models/poxContentTypes inside your ArchGenXML folder, (not the poxContentTypes folder itself, but its contents) into the src/Products.poxContentTypes/Products/poxContentTypes folder inside your buildout folder. Some of the existing files will be overwritten, don't worry about them.

    We are done! We have a working content type. Now we should tell our Zope instance to be aware of it. To do that, modify the buildout and build the instance again.

  2. In the main [buildout] part, modify the eggs parameter by adding a new line:
    [buildout]
    
    ...
    
    eggs = 
    
    ...
    
     Products.poxContentTypes
    
  3. Given that our product is in development stage (that is, it's inside the src folder of our instance), we must also change the develop parameter to tell our instance where to fetch its code from:
    [buildout]
    
    ...
    
    develop = 
     src/Products.poxContentTypes
    
  4. Build your instance again and re-launch it:
    ./bin/buildout
    ./bin/instance fg
    

How it works…

Unfortunately, ArchGenXML doesn't create the egg structure together with the product. Neither does it allow us to use arbitrary namespaces. This is why we have chosen a simple word for the package name: poxContentTypes that will be preceded by the Zope-ish Products to create the final namespace: Products.poxContentTypes.

Note

If you choose a dotted package name, ArchGenXML will automatically replace the dots by underscores in the final product namespace.

Nevertheless we can still use ArchGenXML’s power to generate the necessary code and insert it into an egg structure we create ad-hoc with paster .

主站蜘蛛池模板: 崇礼县| 浦东新区| 武宁县| 闻喜县| 霍山县| 喀什市| 武宣县| 玉田县| 新龙县| 镇宁| 瑞金市| 黔南| 那曲县| 洪雅县| 柯坪县| 祥云县| 左云县| 彝良县| 漳平市| 赣州市| 北京市| 桐庐县| 新郑市| 衡阳县| 汶川县| 治多县| 遵化市| 巴彦县| 屯门区| 彭阳县| 怀集县| 子长县| 黔东| 那曲县| 巴中市| 汶上县| 玉溪市| 雷山县| 饶平县| 西宁市| 凉山|