Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Tips / Package Skeleton

Package Skeleton

mr.bob 是 Zope 和 Plone 建立程式碼骨架的工具程式,它協助開發者管理專案目錄和初始程式碼,它會用來取代舊版 Paster 或 ZopeSkel 或 Templer 扮演的角色和功能。

想要建立 mr.bob 工作環境,常見的方式之一,是利用 Plone 4.3.7 或 Plone 5 Unified Installer 的 develop.cfg:

$ bin/buildout -c develop.cfg
... ...
Installing mrbob.
Getting distribution for 'markupsafe==0.23'.
Got MarkupSafe 0.23.
Generated script '/home/marr/plone437/zinstance/bin/mrbob'.
... ...

bin/mrbob 就是工具程式。想要自編 buildout.cfg 內容,可參考 develop.cfg 裡跟 mr.bob 設定有關的部份:

parts +=
    mrbob

[mrbob]
recipe = zc.recipe.egg
eggs =
    mr.bob
    bobtemplates.plone

或是參考 Version 更新的範例

mr.bob

mr.bob 會蓋掉之前的設定值 也沒產生 model/schema 的範例碼?

bobtemplates.plone create bobtemplate for Dexterity Separate Dexterity from Addon ZCML configuration

$ ../bin/mrbob -O collective.myaddon2 bobtemplates:plone_addon
# I would recommend a git init ; git add . ; git commit here in real situations
$ ../bin/mrbob -O collective.myaddon2 mrbob:template_sample/
Welcome to mr.bob interactive mode. Before we generate directory structure, some questions need to be answered.

Answer with a question mark to display help.
 Values in square brackets at the end of the questions show the default value if there is no answer.

 --> What is your name?: Daniel

 --> How old are you? [24]: 135

 --> Enter password: 

Generated file structure at /home/daniel/dev/Plone/Development/highfields_ph2.1/src/collective.myaddon2
$ ls -ltr collective.myaddon2 
 ....
 -rw-rw-r-- 1 daniel daniel   89 Feb 12 11:47 CHANGES.rst
 -rw-rw-r-- 1 daniel daniel   83 Feb 16 11:32 sample.txt

 $ more collective.myaddon2/sample.txt 
 My name is Daniel. I am 135 years old.

 This is my password to everything:  doodah
$ cd ~/Plone/zinstance/src
$ ../bin/mrbob -O my.pkg bobtemplates:plone_addon

Welcome to mr.bob interactive mode. Before we generate directory structure, some questions need to be answered.

Answer with a question mark to display help.
Values in square brackets at the end of the questions show the default value if there is no answer.


--> What kind of package would you like to create? Choose between 'Basic', 'Dexterity', and 'Theme'. [Basic]:

--> Author's name [John Doe]:

--> Author's email [john.doe@gmail.com]:

--> Author's github username: jdoe

--> Package description [An add-on for Plone]:

--> Plone version [4.3.7]:


Generated file structure at /home/jdoe/plone439/zinstance/src/my.pkg

單獨使用的範例如下:

$ mkdir test
$ cd test
$ virtualenv-2.7 .
$ source bin/activate
$ pip install bobtemplates.plone
$ mrbob -O collective.addon bobtemplates:plone_addon

profiles/uninstall is only created for Plone 5 packages. Or rather, when plone.is_plone5 is False, we delete it afterwards. Until now our answer to that question in the tests was always wrongly interpreted to mean True, so it got generated.

更新版本的修改項目 同時相容 Plone 4 和 5 的範例 同時相容 Python 2 + 3 的範例 Creating Portlet Replacing Import Steps by Post_Handlers hooks.py 建立動態年份的範例

標題使用 # 作為底線,依據字數長度來決定 # 數量

功能改版討論

Config and Dot Files

bootstrap-buildout.py travis.cfg buildout.cfg MANIFEST.in

.coveragerc .editorconfig .gitattributes .gitignore .travis.yml

Default Short Name Issue: IBrowserLayer

ZopeSkel

paste 是 Plone 4.x 之前的舊工具。下列內容可視為歷史說明文件。以 Unified Installer 環境為例,ZopeSkel 的工具程式位於 bin/zopeskel,為了讓產生的程式碼骨架建立在 src 目錄裡,通常會在 src 目錄裡執行 zopeskel 程式。先檢查有哪些樣版可以使用:

$ cd src
$ ../bin/zopeskel

Usage:

    zopeskel <template> <output-name> [var1=value] ... [varN=value]

    zopeskel --help                Full help
    zopeskel --list                List template verbosely, with details
    zopeskel --make-config-file    Output .zopeskel prefs file
    zopeskel --version             Print installed version


Plone Development

|  archetype:         A Plone project that uses Archetypes content types
|  kss_plugin:        A project for a KSS plugin
|  plone:             A project for Plone add-ons
|  plone2_theme:      A theme for Plone 2.1
|  plone3_portlet:    A Plone 3 portlet
|  plone_app:         A project for Plone add-ons with a nested namespace (2 dots in name)
|  plone_pas:         A project for a Plone PAS plugin

Plone Theme Development

|  plone2.5_theme:    A theme for Plone 2.5
|  plone3_theme:      A theme for Plone 3

Buildout

|  plone2.5_buildout: A buildout for Plone 2.5 projects
|  plone3_buildout:   A buildout for Plone 3 installation
|  plone4_buildout:   A buildout for Plone 4 developer installation
|  plone_hosting:     Plone hosting: buildout with ZEO and Plone versions below 3.2
|  recipe:            A recipe project for zc.buildout
|  silva_buildout:    A buildout for Silva projects

Core Python

|  basic_namespace:   A basic Python project with a namespace package
|  nested_namespace:  A basic Python project with a nested namespace (2 dots in name)

Zope Development

|  basic_zope:        A Zope project

Warning:  use of the --svn-repository argument is not allowed with this script

For further help information, please invoke this script with the
option "--help".

搭配 ZopeSkel 的 paster recipe 會建立 Paster* 的 eggs 檔案,它們可以協助建立骨架程式碼,如果不需要,可以自行刪除 Paster* 目錄檔案,或是編輯 setup.py 檔案內容,把 setup_requires 的 PasteScript 和 paster_plugins 的 ZopeSkel 設定值刪除。

建立 Plone 模組的範例:

Dexterity Content Package

建立 Dexterity Content 模組的範例:

$ ../bin/zopeskel dexterity crgis.content
dexterity: A Dexterity-based product



If at any point, you need additional help for a question, you can enter
'?' and press RETURN.

Expert Mode? (What question mode would you like? (easy/expert/all)?) ['easy']:
Version (Version number for project) ['1.0']: 0.1
Description (One-line description of the project) ['Example Dexterity Product']: CRGIS Content Types
Grok-Based? (True/False: Use grok conventions to simplify coding?) [True]:
Creating directory ./crgis.content
Replace 0 bytes with 146 bytes (0/0 lines changed; 4 lines added)
Replace 902 bytes with 1365 bytes (1/32 lines changed; 12 lines added)
------------------------------------------------------------------------------
The project you just created has local commands. These can be used from within
the product.

usage: paster COMMAND

Commands:
  addcontent  Adds plone content types to your project

For more information: paster help COMMAND
------------------------------------------------------------------------------

Archetypes Example

http://plone.org/products/dexterity/documentation/manual/developer-manual/referencemanual-all-pages -- dexterity is Zope 3 product? Answer False when asked to create a Zope 2 product, and False again when asked if the product is zip-safe.

zopeskel.dexterity 搭配 ZopeSkel 2 開發,並不支援 ZopeSkel 3 以上版本,另外有 ImportError: No module named dexterity.localcommands.dexterity 的情況。

Diazo Theme Package

zopeskel.diazotheme

$ ../bin/zopeskel diazotheme my.theme

diazotheme: Diazo Theme package with css and js resources

If at any point, you need additional help for a question, you can enter '?' and press RETURN.

Expert Mode? (What question mode would you like? (easy/expert/all)?) ['easy']:
Version (Version number for project) ['1.0']:
Description (One-line description of the project) ['Example Diazo Theme Package']:
Creating directory ./my.theme
my.theme/
├── README.txt
├── bootstrap.py
├── buildout.cfg
├── dgcn
│   ├── __init__.py
│   └── theme
│       ├── __init__.py
│       ├── configure.zcml
│       ├── diazo_resources
│       │   ├── README.txt
│       │   ├── favicon.ico
│       │   ├── index.html
│       │   ├── manifest.cfg
│       │   ├── preview.png
│       │   ├── rules.xml
│       │   └── static
│       │       ├── main.css
│       │       └── main.js
│       ├── interfaces.py
│       ├── locales
│       │   └── README.txt
│       ├── profiles
│       │   └── default
│       │       ├── browserlayer.xml
│       │       ├── cssregistry.xml
│       │       ├── jsregistry.xml
│       │       └── metadata.xml
│       ├── template_overrides
│       │   └── plone.app.layout.viewlets.footer.pt
│       └── version.txt
├── docs
│   ├── HISTORY.txt
│   ├── INSTALL.txt
│   ├── LICENSE.GPL
│   └── LICENSE.txt
├── plone.cfg
├── setup.cfg
└── setup.py

PasteScript Dependency

Issues by 2013 Dec

local commands and parameters

plonetheme.webpacktemplate