Различия между версиями 6 и 7
Версия 6 от 2010-06-11 06:57:16
Размер: 4670
Редактор: RostislavDzinko
Комментарий:
Версия 7 от 2010-06-11 06:58:45
Размер: 6192
Редактор: RostislavDzinko
Комментарий:
Удаления помечены так. Добавления помечены так.
Строка 71: Строка 71:

=== Организация нового пакета ===

Если вы перейдете в папку ''ticketcollector'', вы увидите несколько папок и файлов:
{{{
jack@computer:/projects/ticketcollector$ ls -CF
bootstrap.py debug.ini etc/ src/ versions.cfg
buildout.cfg deploy.ini setup.py var/
}}}

Once the project directory layout is ready you can add it to your version control system. You should not add the src/ticketcollector.egg-info directory as it is generated automatically by setuptools. Here is an example using bzr:

{{{
jack@computer:/projects/ticketcollector$ rm -fr src/ticketcollector.egg-info/
jack@computer:/projects/ticketcollector$ bzr init
Created a standalone tree (format: 2a)
jack@computer:/projects/ticketcollector$ bzr add *
adding bootstrap.py
adding buildout.cfg
adding debug.ini
...
jack@computer:/projects/ticketcollector$ bzr ci -m "Initial import"
Committing to: /projects/ticketcollector/
added bootstrap.py
added buildout.cfg
...
Committed revision 1.
}}}

Adding the project to a version control system is an optional but recommended step. You now have a valid source code distribution of your project that, after building, will produce a running application. The project is now completely independent of the bluebream distribution, it’s only purpose is to help us get to this point. The project now contains everything required to install the dependencies from the Internet and to set-up the application.

Учебник - часть 1

Вступление

В главе Первые шаги, был описан процесс установки BlueBream и создания проекта из шбалона bluebream. В этом учебнике, вы научитесь создавать простое приложение ticket collector. Данная серия уроков поможет ближе ознакомится с принципами BlueBream.

Вот несколько функций будущего приложения:

  • В один накопитель можно добавить сколько угодно билетов.
  • Каждый новый билет должен иметь описание и один начальный комментарий.
  • К билету можно добавлять комментарии.

Это первая часть обучения. После завершения этой главы, вы должны уметь:

  • Понимать структуру директорий проекта.
  • Использовать и настраивать Buildout.
  • Создавать контент-объекты (content objects) и интерфейсы.
  • Использовать инструмент для генерации форм (zope.formlib).

Примеры, которые предлагаются для изучения в документации можно загрузить отсюда. Исходники доступны на разных этапах, соответственно разделам.

  • Этап 1 : разделы от 5.2 до 5.7
  • Этап 2 : раздел 5.8
  • Этап 3 : раздел 5.9
  • Этап 4 : раздел 6.2
  • Этап 5 : раздел 6.3
  • Этап 6 : разделы 6.4 & 6.5

Создание нового проекта

Использование шаблона проекта bluebream

В этом разделе мы будем создавать структуру папок для нашего приложения. Я предполагаю, что вы уже установили bluebream, используя команду easy_install bluebream, как упоминалось в главе Первые шаги. Давайте назовем приложение ticketcollector, и создадим Python пакет с именем tc.main. Итак, мы создали проект с именем ticketcollector, пакетом пространства имен tc и под-пакетом main. Давайте создадим структуру папок для нашего приложения:

   1 $ paster create -t bluebream
   2 
   3 Selected and implied templates:
   4   bluebream#bluebream  A BlueBream project, base template
   5 
   6 Enter project name: ticketcollector
   7 Variables:
   8   egg:      ticketcollector
   9   package:  ticketcollector
  10   project:  ticketcollector
  11 Enter python_package (Main Python package (with namespace, if any)) ['ticketcollector']: tc.main
  12 Enter interpreter (Name of custom Python interpreter) ['breampy']:
  13 Enter version (Version (like 0.1)) ['0.1']:
  14 Enter description (One-line description of the package) ['']: Ticket Collector
  15 Enter long_description (Multi-line description (in reST)) ['']: An issue tracking application
  16 Enter keywords (Space-separated keywords/tags) ['']:
  17 Enter author (Author name) ['']: Baiju M
  18 Enter author_email (Author email) ['']: baiju@example.com
  19 Enter url (URL of homepage) ['']:
  20 Enter license_name (License name) ['']: ZPL
  21 Enter zip_safe (True/False: if the package can be distributed as a .zip file) [False]:
  22 Creating template bluebream
  23 Creating directory ./ticketcollector
  24 
  25 Your project has been created! Now, you want to:
  26 1) put the generated files under version control
  27 2) run: python boostrap.py
  28 3) run: ./bin/buildout

Как видно из примера выше, мы предоставили почти всю информацию о проекте. Значения, которые были указаны, можно поменять позже. Это сделать очень просто; все, что трудно изменить позже - это имена пакетов, потому что на них позже может быть много ссылок в коде.

Организация нового пакета

Если вы перейдете в папку ticketcollector, вы увидите несколько папок и файлов:

jack@computer:/projects/ticketcollector$ ls -CF
bootstrap.py  debug.ini   etc/      src/  versions.cfg
buildout.cfg  deploy.ini  setup.py  var/

Once the project directory layout is ready you can add it to your version control system. You should not add the src/ticketcollector.egg-info directory as it is generated automatically by setuptools. Here is an example using bzr:

jack@computer:/projects/ticketcollector$ rm -fr src/ticketcollector.egg-info/
jack@computer:/projects/ticketcollector$ bzr init
Created a standalone tree (format: 2a)
jack@computer:/projects/ticketcollector$ bzr add *
adding bootstrap.py
adding buildout.cfg
adding debug.ini
...
jack@computer:/projects/ticketcollector$ bzr ci -m "Initial import"
Committing to: /projects/ticketcollector/
added bootstrap.py
added buildout.cfg
...
Committed revision 1.

Adding the project to a version control system is an optional but recommended step. You now have a valid source code distribution of your project that, after building, will produce a running application. The project is now completely independent of the bluebream distribution, it’s only purpose is to help us get to this point. The project now contains everything required to install the dependencies from the Internet and to set-up the application.

Документации/Bluebream/Bluebream-Учебник-1 (последним исправлял пользователь RostislavDzinko 2010-06-12 21:49:54)