Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install icemac.ab.importer

How to install icemac.ab.importer

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install icemac.ab.importer
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.8.1
1.10.0Never BuiltWhy not?
1.8.1 Available View build log
1.8.0 Available View build log
1.7.2 Available View build log
1.7.1 Available View build log
1.6.0 Available View build log
1.5.0 Available View build log
1.4.0 Available View build log
Windows (64-bit)
1.8.1
1.10.0Never BuiltWhy not?
1.8.1 Available View build log
1.8.0 Available View build log
1.7.2 Available View build log
1.7.1 Available View build log
1.6.0 Available View build log
1.5.0 Available View build log
1.4.0 Available View build log
Mac OS X (10.5+)
1.10.0 Available View build log
1.8.1 Available View build log
1.8.0 Available View build log
1.7.2 Available View build log
1.7.1 Available View build log
1.6.0 Available View build log
1.5.0 Available View build log
1.4.0 Available View build log
Linux (32-bit)
1.10.0 Available View build log
1.8.1 Available View build log
1.8.0 Available View build log
1.7.2 Available View build log
1.7.1 Available View build log
1.6.0 Available View build log
1.5.0 Available View build log
1.4.0 Available View build log
Linux (64-bit)
1.10.0 Available View build log
1.8.1 Available View build log
1.8.0 Available View build log
1.7.2 Available View build log
1.7.1 Available View build log
1.6.0 Available View build log
1.5.0 Available View build log
1.4.0 Available View build log
 
License
ZPL 2.1
Lastest release
version 1.10.0 on Jun 15th, 2013

This package provides import infrastructure for icemac.addressbook.

Concept

Importing data requires the following steps:

  • A user having the Administrator role uploads an import file to the address book. It gets stored there inside the importer.
  • When the user decides to import the the uploaded file, he is presented with a list of readers which claim to be able to read the import file.
  • After choosing the import file reader the user has to map which field data in the import file should be stored in which field in the address book.
  • The imported data gets shown and the user can decide to keep or to discard the imported data.

Hacking

Source code

Get the source code:

$ hg clone https://bitbucket.org/icemac/icemac.ab.importer

or fork me on: https://bitbucket.org/icemac/icemac.ab.importer

Running Tests
https://secure.travis-ci.org/icemac/icemac.ab.importer.png

To run the tests yourself call:

$ python2.6 bootstrap.py
$ bin/buildout
$ bin/test

Write your own import file reader

The key to extend the import mechanism is to provide a reader for the needed import file type.

This package already provides an import file reader for CSV files.

icemac.ab.importxls provides a reader for XLS files, so it could be a starting point, too.

1. Write a reader class

The reader class must implement the interface icemac.ab.importer.interfaces.IImportFileReader. There is a base implementation in icemac.ab.importer.reader.base.BaseReader which the new reader class can extend, so there are only four things left to implement (see the interface for a more specific description):

  • title attribute -- shown to the user in the dialog when choosing the reader
  • getFieldNames method -- lists the names of the fields in the import file
  • getFieldSamples method -- returns samples of a specific field to ease the mapping task for the user
  • __iter__ method -- iterates the import file to get the data for the import.

The base class file stores the file for reading on the file attribute.

2. Test reader class

icemac.ab.importer.reader.testing.ReaderTest provides a (base) test class which checks whether the reader behaves as expected. It requires some example files for the reader. The derived reader tests must fulfill the following conventions:

  1. The directory structure must look like this: (directories in italic)

    • reader.py
    • tests
      • __init__.py
      • test_reader.py
      • data
        • short.file
        • long.file
  2. The __init__.py file can be empty.

  3. The test_reader.py file contains the test class which extends icemac.ab.importer.reader.testing.BaseReaderTest. Three attributes have to be set on this class:

    • reader_class - must point to the reader's class object
    • import_file - name of the longer import file (see below), without path
    • import_file_short name of the shorter import file (see below), without path
  4. There must be two files in the data directory:

    • a file for the import_file_short attribute on the test class, containing the following data:

      last name

      firstname

      birth_date

      Koch

       

      1976-01-24

    • a file for the import_file attribute on the test class, containing the following data:

      last name

      firstname

      birth_date

      Koch

      Andreas

      1976-01-24

      Hula

      Hanna

      2000-01-01

      Jänsen

      Jens

       

      Fruma

       

      2001-12-31

3. Register the reader class

To register the reader class with icemac.addressbook write a configure.zcml file in the reader package:

<configure xmlns="http://namespaces.zope.org/zope">
  <include package="icemac.ab.importer" />
  <adapter
     name="<name>"
     factory="<path>" />
</configure>

The icemac.ab.importer package is necessary to integrate the importer UI into the address book. The name attribute contains a unique name to identify the importer internally. The factory attribute contains the python path to the reader class.

4. Create a python package

The reader class must be inside a python package. The package must depend on icemac.ab.importer (install_requires parameter in setup.py).

5. Integrate the reader in icemac.addressbook

During installing icemac.addressbook, it is possible to enter the name of external dependencies. This is the place to integrate your reader into icemac.addressbook.

Changelog

1.10.0 (2013-06-13)
1.9.0 (2012-12-29)
  • Adapted tests to run with icemac.addressbook version 1.9.
1.8.1 (2012-04-20)
  • Adapted test set up to run with icemac.addressbook version 1.8.1.
1.8.0 (2011-12-14)
  • Adapted tests and test set up to run with icemac.addressbook version 1.8.
Previous Versions

See OLD_CHANGES.rst inside the package.

Subscribe to package updates

Last updated Jun 15th, 2013

Download Stats

Last month:3

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.