Personal tools
You are here: Home Documentazione Domade Frequenti (FAQ) paster e local commands
Document Actions

paster e local commands

Up to Table of Contents

Con paster possiamo generare dei pacchetti o ambienti per il deploying delle nostre applicazioni. Sapevate invece che da un template paster "archetype" è possibile richiamare altri comandi, detti local commands, che consentono di aggiungere dei content type, schema, browserview e portlet oltre che il semplice scheletro del prodotto?

Creiamo uno scheletro di prodotto utilizzando il template archetype tra quelli disponibili in ZopeSkel:

$ paster create -t archetype esempio.archetype
Selected and implied templates:
  ZopeSkel#basic_namespace  A project with a namespace package
  ZopeSkel#plone            A Plone project
  ZopeSkel#archetype        A Plone project that uses Archetypes

Variables:
  egg:      esempio.archetype
  package:  esempioarchetype
  project:  esempio.archetype
Enter title (The title of the project) ['Plone Example']: esempio.archetype
Enter namespace_package (Namespace package (like plone)) ['plone']: esempio
Enter package (The package contained namespace package (like example)) ['example']: archetype
Enter zope2product (Are you creating a Zope 2 Product?) [False]: True
...

Entriamo nel nostro pacchetto appena creato:

$ cd esempio.archetype

Ora digitando il seguente comando vedremo che abbiamo dei comandi in più a disposizione, che dipendono dal contesto in cui ci troviamo (local commands):

esempio.archetype$ paster --help
usage: paster [paster_options] COMMAND [command_options]

options:
  --version         show program's version number and exit
  --plugin=PLUGINS  Add a plugin to the list of commands (plugins are Egg
                    specs; will also require() the Egg)
  -h, --help        Show this help message

Commands:
  create       Create the file layout for a Python distribution
  grep         Search project for symbol
  help         Display help
  make-config  Install a package and create a fresh config file/directory
  points       Show information about entry points
  serve        Serve the described application
  setup-app    Setup an application, given a config file

ZopeSkel local commands:
  addcontent   Adds plone content types to your project

Nel dettaglio con il local command addcontent possiamo aggiungere:

esempio.archetype$ paster addcontent -l
Available templates:
  atschema:     A handy AT schema builder
  contenttype:  A content type skeleton
  portlet:      A Plone 3 portlet
  view:         A browser view skeleton
  zcmlmeta:     A ZCML meta directive skeleton

Quindi possiamo aggiungere un nuovo content type, uno schema, una portlet o browserview con un semplice comando, assistiti da una comoda procedura interattiva e facendoci risparmiare tempo:

esempio.archetype$ paster addcontent contenttype
Enter contenttype_name (Content type name ) ['Example Type']:
....

Nota bene

Questi strumenti sono utili per aumentare la produttività ed evitarci incombenze noiose, ma devono essere considerati solo un ausilio alla programmazione invece che lo strumento per programmare!

I local commands mostrati sono quelli relativi alla versione PasteScript 1.3.6, in futuro la lista di template disponibili potrebbe essere più ampia.

Risorse in rete

by Davide Moro last modified 2008-07-01 10:09

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: