cybertools/commerce
helmutm cb7c2927a1 reimplement relation-based collection attributes
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2844 fd906abe-77d9-0310-91a1-e0d9ade77398
2008-08-24 08:10:21 +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 reimplement relation-based collection attributes 2008-08-24 08:10:21 +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 Add Description fiel 2008-08-14 12:39:32 +00:00
product.py reimplement relation-based collection attributes 2008-08-24 08:10:21 +00:00
README.txt reimplement relation-based collection attributes 2008-08-24 08:10:21 +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$)


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

Let's start with two shops:

  >>> from cybertools.commerce.shop import Shop
  >>> shop1 = Shop(u'shop1', u'PC up Ltd')
  >>> shop2 = Shop(u'shop2', u'Video up Ltd')

Now we add products to the shops.

  >>> from cybertools.commerce.product import Product
  >>> p001 = Product(u'p001', u'Silent Case')
  >>> p002 = Product(u'p002', u'Portable Projector')
  >>> p003 = Product(u'p003', u'HD Flatscreen Monitor')
  >>> p004 = Product(u'p004', 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'p001', u'Silent Case'), (u'p003', u'HD Flatscreen Monitor'),
   (u'p004', 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
=========

  >>> from cybertools.commerce.customer import Customer
  >>> c001 = Customer(u'c001', u'Your Local Computer Store')
  >>> c002 = Customer(u'c002', u'Speedy Gonzales')
  >>> c003 = Customer(u'c003', u'TeeVee')
  >>> c004 = Customer(u'c004', 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'c001', u'Your Local Computer Store'), (u'c002', u'Speedy Gonzales'),
   (u'c004', 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
======