work in progress: shops and products
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2798 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
7440503f6e
commit
1ff28acd31
7 changed files with 94 additions and 12 deletions
|
@ -1,14 +1,41 @@
|
|||
==========================================
|
||||
Commerce: Products, Customers, Orders, ...
|
||||
==========================================
|
||||
=================================================
|
||||
Commerce: Shope, Products, Customers, Orders, ...
|
||||
=================================================
|
||||
|
||||
($Id$)
|
||||
|
||||
|
||||
Products
|
||||
========
|
||||
Shops and Products
|
||||
==================
|
||||
|
||||
Let's start with a Product:
|
||||
Let's start with a Shop:
|
||||
|
||||
>>> from cybertools.commerce.base import Shop
|
||||
>>> shop1 = Shop(u'shop1', u'PC up Ltd')
|
||||
|
||||
Now we add products to the shop.
|
||||
|
||||
>>> from cybertools.commerce.product import Product
|
||||
>>> p1 = Product()
|
||||
>>> p001 = Product(u'p001', u'Silent Case')
|
||||
|
||||
>>> shop1.addProduct(p001)
|
||||
|
||||
>>> sorted((name, p.title) for name, p in shop1.products.items())
|
||||
[(u'p001', u'Silent Case')]
|
||||
|
||||
Let's have a look at the product - it should correctly reference the shop
|
||||
it belongs to.
|
||||
|
||||
>>> len(p001.shops)
|
||||
1
|
||||
>>> p001.shops.keys()[0]
|
||||
u'shop1'
|
||||
|
||||
|
||||
Customers
|
||||
=========
|
||||
|
||||
|
||||
Orders
|
||||
======
|
||||
|
||||
|
|
44
commerce/base.py
Normal file
44
commerce/base.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
#
|
||||
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
"""
|
||||
Base classes.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from zope.interface import implements, Interface
|
||||
|
||||
from cybertools.commerce.interfaces import IShop
|
||||
|
||||
|
||||
class Shop(object):
|
||||
|
||||
implements(IShop)
|
||||
|
||||
title = u'Shop'
|
||||
|
||||
def __init__(self, name, title=None):
|
||||
self.name = name
|
||||
if title is not None:
|
||||
self.title = title
|
||||
self.products = {}
|
||||
|
||||
def addProduct(self, product):
|
||||
self.products[product.name] = product
|
||||
product.shops[self.name] = self
|
|
@ -61,6 +61,10 @@ class IShop(Interface):
|
|||
u'this shop.')
|
||||
customers = Attribute(u'The customers registered for this shop.')
|
||||
|
||||
def addProduct(product):
|
||||
""" Add the product given to the shop's product listing.
|
||||
"""
|
||||
|
||||
|
||||
# suppliers
|
||||
|
||||
|
@ -98,8 +102,7 @@ class IProduct(Interface):
|
|||
|
||||
productId = schema.ASCIILine(
|
||||
title=_(u'Product Identifier'),
|
||||
description=_(u'A name or number uniquely identifiying the '
|
||||
u'product within a shop.'),
|
||||
description=_(u'A name or number uniquely identifiying the product.'),
|
||||
default='',
|
||||
required=True)
|
||||
title = schema.TextLine(
|
||||
|
|
Binary file not shown.
|
@ -17,8 +17,8 @@ msgstr "Artikel"
|
|||
msgid "Product Identifier"
|
||||
msgstr "Artikelnummer"
|
||||
|
||||
msgid "A name or number uniquely identifiying the product within a shop."
|
||||
msgstr "Kurzbezeichnung oder Nummer, die den Artikel innerhalb eines Shops eindeutig identifiziert."
|
||||
msgid "A name or number uniquely identifiying the product."
|
||||
msgstr "Kurzbezeichnung oder Nummer, die den Artikel eindeutig identifiziert."
|
||||
|
||||
msgid "Product Name"
|
||||
msgstr "Artikelbezeichnung"
|
||||
|
|
|
@ -31,3 +31,11 @@ class Product(object):
|
|||
|
||||
implements(IProduct)
|
||||
|
||||
title = u'Product'
|
||||
|
||||
def __init__(self, name, title=None):
|
||||
self.name = name
|
||||
if title is not None:
|
||||
self.title = title
|
||||
self.shops = {}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ class Test(unittest.TestCase):
|
|||
"Basic tests."
|
||||
|
||||
def testBasicStuff(self):
|
||||
p = Product()
|
||||
p = Product('p001')
|
||||
|
||||
|
||||
def test_suite():
|
||||
|
|
Loading…
Add table
Reference in a new issue