cybertools/commerce
helmutm 62a45109c0 add manufacturer and supplier classes
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2911 fd906abe-77d9-0310-91a1-e0d9ade77398
2008-10-09 13:03:13 +00:00
..
browser work in progress: commerce.product 2008-07-27 14:33:06 +00:00
locales work in progress: shops and products 2008-08-10 09:14:19 +00:00
__init__.py create cybertools.commerce package 2008-07-12 14:00:12 +00:00
common.py add manager class + functionality 2008-08-24 11:27:48 +00:00
configure.zcml fix field definition 2008-08-14 12:21:11 +00:00
customer.py reimplement relation-based collection attributes 2008-08-24 08:10:21 +00:00
interfaces.py Category 2008-09-23 14:02:55 +00:00
manager.py add manager class + functionality 2008-08-24 11:27:48 +00:00
product.py add manufacturer and supplier classes 2008-10-09 13:03:13 +00:00
README.txt add manager class + functionality 2008-08-24 11:27:48 +00:00
shop.py reimplement relation-based collection attributes 2008-08-24 08:10:21 +00:00
tests.py work in progress: shops and products 2008-08-10 09:14:19 +00:00

=================================================
Commerce: Shope, Products, Customers, Orders, ...
=================================================

  ($Id$)

  >>> from cybertools.commerce.manager import Manager
  >>> manager = Manager()


Shops and Products
==================

Let's start with two shops:

  >>> shop1 = manager.shops.create(u'shop1', title=u'PC up Ltd')
  >>> shop2 = manager.shops.create(u'shop2', title=u'Video up Ltd')

  >>> len(list(manager.shops))
  2

Now we add products to the shops.

  >>> p001 = manager.products.create(u'001', title=u'Silent Case')
  >>> p002 = manager.products.create(u'002', title=u'Portable Projector')
  >>> p003 = manager.products.create(u'003', title=u'HD Flatscreen Monitor')
  >>> p004 = manager.products.create(u'004', title=u'Giga Mainboard')

  >>> shop1.products.add(p001)
  >>> shop1.products.add(p003)
  >>> shop1.products.add(p004)
  >>> shop2.products.add(p002)
  >>> shop2.products.add(p003)

  >>> sorted((p.productId, p.title) for p in shop1.products)
  [(u'001', u'Silent Case'), (u'003', u'HD Flatscreen Monitor'),
   (u'004', u'Giga Mainboard')]

Let's have a look at the product - it should correctly reference the shops
it belongs to.

  >>> sorted((s.name, s.title) for s in p003.shops)
  [(u'shop1', u'PC up Ltd'), (u'shop2', u'Video up Ltd')]


Customers
=========

  >>> c001 = manager.customers.create(u'001', title=u'Your Local Computer Store')
  >>> c002 = manager.customers.create(u'002', title=u'Speedy Gonzales')
  >>> c003 = manager.customers.create(u'003', title=u'TeeVee')
  >>> c004 = manager.customers.create(u'004', title=u'MacVideo')

  >>> shop1.customers.add(c001)
  >>> shop1.customers.add(c002)
  >>> shop1.customers.add(c004)
  >>> shop2.customers.add(c002)
  >>> shop2.customers.add(c003)
  >>> shop2.customers.add(c004)

  >>> sorted((c.customerId, c.title) for c in shop1.customers)
  [(u'001', u'Your Local Computer Store'), (u'002', u'Speedy Gonzales'),
   (u'004', u'MacVideo')]

  >>> sorted((s.name, s.title) for s in c002.shops)
  [(u'shop1', u'PC up Ltd'), (u'shop2', u'Video up Ltd')]


Orders
======