cybertools/integrator
helmutm d505f3629a added integrator package: transparent access to filesystem directories and files
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2441 fd906abe-77d9-0310-91a1-e0d9ade77398
2008-03-12 10:53:52 +00:00
..
testdata added integrator package: transparent access to filesystem directories and files 2008-03-12 10:53:52 +00:00
__init__.py added integrator package: transparent access to filesystem directories and files 2008-03-12 10:53:52 +00:00
base.py added integrator package: transparent access to filesystem directories and files 2008-03-12 10:53:52 +00:00
filesystem.py added integrator package: transparent access to filesystem directories and files 2008-03-12 10:53:52 +00:00
interfaces.py added integrator package: transparent access to filesystem directories and files 2008-03-12 10:53:52 +00:00
README.txt added integrator package: transparent access to filesystem directories and files 2008-03-12 10:53:52 +00:00
tests.py added integrator package: transparent access to filesystem directories and files 2008-03-12 10:53:52 +00:00

=========================================
Integrating objects from external systems
=========================================

Integration of external sources.

  ($Id$)


Getting started
===============

Let's do some basic set up

  >>> from zope import component, interface

  >>> from cybertools.integrator.tests import testDir
  >>> from cybertools.integrator.filesystem import ContainerFactory, FileFactory
  >>> from cybertools.integrator.interfaces import IContainerFactory
  >>> component.provideUtility(ContainerFactory(), name='filesystem')
  >>> component.provideUtility(FileFactory(), name='filesystem')


Accessing Objects in the Filesystem
=======================================

  >>> top = component.getUtility(IContainerFactory, name='filesystem')(testDir)
  >>> sorted(top)
  ['index.html', 'sub']
  >>> len(top)
  2

  >>> sub = top['sub']
  >>> sorted(sub)
  ['demo.tgz', 'index.html', 'loops_logo.png']

  >>> file = sub['demo.tgz']
  >>> file.contentType
  'application/x-tar'
  >>> file.getSize()
  432L

  >>> logo = sub['loops_logo.png']
  >>> logo.contentType
  'image/png'
  >>> logo.getImageSize()
  (145, 42)

  >>> html = top['index.html']
  >>> html.contentType
  'text/html'
  >>> print html.data
  <html>...
      <img src="sub/loops_logo.png" />
      <a href="sub">Subdirectory</a>
      <a href="sub/demo.tgz">Demo</a>...
  </html>...