Personal tools
You are here: Home Documentation How-Tos Make use of add-ons via eggs

Make use of add-ons via eggs

This How-to applies to: Any version.
This How-to is intended for: Developer, Advanced Developer

How to include additional third-party code packaged as eggs (using megrok.form as the example).

Might be outdated! This document hasn't been reviewed for Grok 1.0 and may be outdated. If you would like to review the document, please read this post

Purpose

A new egg has been released that will give your application lots more functionality or bling. The developer was nice enough to release it as an egg to the community via the Python packaging index (pypi). The steps below will explain how to get the new functionality into your application.

Prerequisities

I'm assuming that you already have grok installed using grokproject. For this howto, I'm using a grokproject called 'megrokformexample'. The directory structure is represented below. The key files for this exercise are setup.py and configure.zcml, they are highlighted below:

megrokformexample/
|-- bin
|-- buildout.cfg
|-- develop-eggs
|   `-- megrokformexample.egg-link
|-- parts
|-- setup.py
`-- src
    |-- megrokformexample
    |   |-- __init__.py
    |   |-- app.py
    |   |-- app_templates
    |   |   `-- index.pt
    |   |-- configure.zcml
    |   |-- ftesting.zcml
    |   `-- testing.py
    `-- megrokformexample.egg-info

 

Step by step

Step 1 - Identify the package that you would like to use

For our example we want to use megrok.form

the listing at pypi looks like screenshot below:

megrok.form pypi listing

 

Step 2 - Add the package information to the setup.py and configure.zcml of your project

This is what megrokformexample/setup.py

looks like:

from setuptools import setup, find_packages

version = '0.0'

setup(name='megrokformexample',
      version=version,
      description="",
      long_description="""\
""",
      # Get strings from http://www.python.org/pypi?%3Aaction=list_classifiers
      classifiers=[],
      keywords="",
      author="",
      author_email="",
      url="",
      license="",
      package_dir={'': 'src'},
      packages=find_packages('src'),
      include_package_data=True,
      zip_safe=False,
      install_requires=['setuptools',
                        'grok',
                        'megrok.form',
                        # Add extra requirements here
                        ],
      entry_points="""
      # Add entry points here
      """,
      )

This is what src/megrokformexample/configure.zcml looks like:

<configure xmlns="http://namespaces.zope.org/zope"
           xmlns:grok="http://namespaces.zope.org/grok">
  <include package="grok" />
  <include package="megrok.form" />
  <grok:grok package="." />
</configure>

Step 3 - run bin/buildout

While inside the megrokformexample directory run bin/buildout:

bin/buildout

The output should look similar to this:

Develop: '/home/david/megrokform/megrokformexample/.'
Updating app.
Getting distribution for 'megrok.form'.
Got megrok.form 0.1.
Getting distribution for 'collective.namedfile'.
Got collective.namedfile 1.1.
Getting distribution for 'zc.datetimewidget'.
Got zc.datetimewidget 0.6.1dev-r72453.
Getting distribution for 'z3c.widget'.
Got z3c.widget 0.1.7.
Getting distribution for 'zc.resourcelibrary'.
Got zc.resourcelibrary 1.0.0.
Getting distribution for 'zc.i18n>=0.5'.
Got zc.i18n 0.6.1dev-r72454.
Getting distribution for 'zope.app.cache'.
Got zope.app.cache 3.4.0.
Getting distribution for 'z3c.schema'.
Got z3c.schema 0.1-r73916.
Getting distribution for 'z3c.javascript'.
Got z3c.javascript 0.2-r80712.
Getting distribution for 'z3c.i18n'.
Got z3c.i18n 0.1.1.
Generated script '/home/david/megrokform/megrokformexample/parts/app/runzope'.
Generated script '/home/david/megrokform/megrokformexample/parts/app/debugzope'.
Updating data.
Updating zopectl.
Updating i18n.
The recipe for i18n doesn't define an update method. Using its install method.
i18n: setting up i18n tools
Generated script 'bin/i18nextract'.
Generated script 'bin/i18nmergeall'.
Updating test.
Generated script '/home/david/megrokform/megrokformexample/bin/test'.

Further information

Always read the information about the package at pypi. This is helpful in cases where a package may need additional things before it will install.

see also:

Install multiple Grok apps using zc.buildout
Grok is packaged as Python eggs. zc.buildout is a tool for managing these eggs, and let's you quickly try out or develop a Grok-based project.

Problem on Windows XP

Posted by Alaa Barazi at Feb 29, 2008 12:26 PM

I followed all the steps in the tutorial and had the error in the last step which is :

C:\megrokformexample\bin>buildout.exe

While: Initializing. Error: Couldn't open C:\megrokformexample\bin\buildout.cfg

Could you help me in solving this problem?

Thanks

Problem Solved

Posted by Alaa Barazi at Mar 01, 2008 03:55 AM

Copy buildout.exe and buildout-script.py from C:\megrokformexample\bin\ to C:\megrokformexample\ and run builout.exe from C:\megrokformexample\.

No need to copy buildout.exe and buildout-script.py

Posted by Alaa Barazi at Mar 01, 2008 09:46 AM

No need to copy buildout.exe and buildout-script.py just run bin\builout "not bin/buildout" from C:\megrokformexample. Like the following: C:\megrokformexample>bin\builout

"bin\buildout" not "bin\builout"

Posted by Alaa Barazi at Mar 01, 2008 10:23 AM

"C:\megrokformexample>bin\buildout.exe" not "C:\megrokformexample\bin>buildout.exe"

SUBJ1

Posted by Royaryshoma at Oct 20, 2011 07:10 PM
Effexor Xr For Depression No Prescription Accutane Online Acne <a href=http://effexornoprescription.renspace.com/>Effexor Xr No Prescription Taking</a> Ordering Alprazolam Online Motrin For Kittens Infant Immunizations And Motrin Stops Working Effexor Xr Buy Motrin 800 <a href=http://www.mycraft.com/motrinnoprescription/>No Prescription Motrin Acetaminophen</a> Lisinopril With Motrin How Fast Does Accutane Create Working Effexor Bijwerkingen Toddler Motrin Dosage Pain Reliever Effexor Canada Delivery <a href=http://www.buncospace.com/p[…]noprescription>Promotion Paroxetine No Prescription</a> Motrin And Delsym Cough Medicine Acne Treatment After Accutane My Doctor Weight Gain On Effexor Effexor Depression Clinical Webkinz Effexor Xr 150 <a href=http://www.mycraft.com/avodartnoprescription>Generic Drugs No Prescription Avodart</a> Alprazolam Pdr Paroxetine And Xanax Social Anxiety Disorder Alprazolam Mechanism Panic Disorder