コード例 #1
0
ファイル: run.py プロジェクト: saibaba/prodcat
def test1():

    catalogs = Catalog.list()
    print "Catalogs: " , catalogs

    master = Catalog.create("master", "Computer/Home/Desktop")

    AttributeType.create("Description", "String")
    AttributeType.create("Status", "String")
    AttributeType.create("Processor", "category_relationship")

    print AttributeType.list()

    computer = master.get_category("Computer")
    computer.add_attribute("Status")
    computer.add_attribute("Processor")

    master.create_categories("Processors/Intel")
    Product.create("Core Duo i5", dict(Description="i5 processor"), master, "Processors/Intel")
    Product.create("Core Duo i7", dict(Description="i7 processor"), master, "Processors/Intel")

    desktop = master.get_category("Computer/Home/Desktop")
    desktop.add_attribute("Description")
    print desktop.get_attributes()

    Product.create("Multimedia Server 1", dict(Description="Multimedia Server for video editing", Status="Active", Processor="Processors/Intel"), master, "Computer/Home/Desktop")
    Product.create("Multimedia Server 2", dict(Description="Multimedia Server for audio editing", Status="Inactive", Processor="Processors/Intel"), master, "Computer/Home/Desktop")
コード例 #2
0
ファイル: run.py プロジェクト: saibaba/prodcat
def test2():
    master = Catalog("master")
    p = Product("Multimedia Server 1")
    print p.enumerate()