Tracker Tracker

 - Bugs ( 20 open / 46 total )
Bug Tracking System

 - Support Requests ( 0 open / 0 total )
Tech Support Tracking System

 - Patches ( 1 open / 1 total )
Patch Tracking System

 - Feature Requests ( 39 open / 48 total )
Feature Request Tracking System


Forums Forums ( 2 messages in 2 forums )
Mail Lists Mailing Lists ( 4 mailing lists )
Screenshots Screenshots
Tasks Task Manager
  - Pymerase
  - Pymerase Website
  - Pymerase Docs
CVS CVS Tree ( 505 commits, 244 adds ) known bug
FTP Released Files

SourceForge Logo

 
Pymerase Docs - Output Modules
Pymerase Docs - Output Modules

Pymerase Docs - Output Modules

Brandon King
Copyright ©  2003 California Institute of Technology

Version 0.1.6
Jul 7, 2003

Contents

Output Modules
    1.1  Overview
        1.1.1  Status Key
        1.1.2  Current CVS Checkout
        1.1.3  Pymerase v0.1.99.0
        1.1.4  Output Formats
        1.1.5  System Requirements
CreateDBAPI
    2.1  Description
    2.2  Usage
    2.3  Caveats
        2.3.1  Packages
CreateGraphvizUML
    3.1  Description
    3.2  Usage
    3.3  Caveats
        3.3.1  UML Diagram Compatiblity
CreateReport
    4.1  Description
    4.2  Usage
    4.3  Caveats
        4.3.1  Not Complete
CreateSQL
    5.1  Description
    5.2  Usage
    5.3  Caveats
        5.3.1  PostgreSQL Only
        5.3.2  PostgreSQL Table Names
CreateTabDelimitedParser
    6.1  Description
    6.2  Usage
CreateTableXML
    7.1  Description
    7.2  Usage
iPymerase
    8.1  Description
    8.2  Usage
    8.3  Caveats
        8.3.1  pymerasegui.py / pymerase -gui

1  Output Modules

1.1  Overview

1.1.1  Status Key

Label Description
Release Stable release.
Beta Functional, has bugs, needs testing.
Alpha Functional, lots of bugs, not finished, needs testing.
WP Work in progress, Non-Functional.
Abandoned Abandoned, Non-Functional.
Planning In Plan phase, little or no code exists.

1.1.2  Current CVS Checkout

Output Module Status Prev. Status Description
CreateCppAPI WP Planning Generation of C++ API
CreateDBAPI Beta Beta Python Database API (Currently
PostgreSQL Support)
CreateDBEditor Abandoned Alpha Prototype CGI
Scripts for accessing DB
CreateGraphvizUML Beta Beta Generates dot files for
use with Graphviz.
CreateHtmlForms Abandoned Alpha Prototype Html Forms
used with CreateDBEditor.
CreatePyTkDBWidgets Alpha Alpha Creates Python
Tkinter DBAPI Aware Widgets
CreatePyTkWidgets Alpha Alpha Creates Python
Tkinter Widget Lib for GUI Building
CreatePythonAPI WP WP Python Object Model
CreateReport Beta Beta Creates a Report text file
describing your model.
CreateSQL Beta Beta Creates SQL statements creating
a database
CreateTabDelimitedParser Alpha Planning Generates Tab Delimited Text
Parser with support for pickling
or saving to database.
CreateTableXML Beta Beta Generates Table.dtd XML
files. Provides more information
iPymerase Beta Beta Exposes an ipython interpreter
for exploring Pymerase API.

1.1.3  Pymerase v0.1.99.0

Output Module Status Prev. Status Description
CreateDBAPI Beta Beta Python Database API (Currently
PostgreSQL Support)
CreateDBEditor Abandoned Alpha Prototype CGI
Scripts for accessing DB
CreateGraphvizUML Beta Beta Generates dot files for
use with Graphviz.
CreateHtmlForms Abandoned Alpha Prototype Html Forms
used with CreateDBEditor.
CreatePyTkDBWidgets Alpha Alpha Creates Python
Tkinter DBAPI Aware Widgets
CreatePyTkWidgets Alpha Alpha Creates Python
Tkinter Widget Lib for GUI Building
CreatePythonAPI WP WP Python Object Model
CreateReport Beta Beta Creates a Report text file
describing your model.
CreateSQL Beta Beta Creates SQL statements creating
a database
CreateTableXML Beta Beta Generates Table.dtd XML
files. Provides more information
iPymerase Beta Beta Exposes an ipython interpreter
for exploring Pymerase API.

1.1.4  Output Formats

Output Module Output Format
CreateCppAPI Directory (C++ Code)
CreateDBAPI Directory (Python Package)
CreateGraphvizUML File (.dot)
CreatePyTkDBWidgets Directory (Python Package)
CreatePyTkWidgets Directory (Python Package)
CreateReport File (.txt)
CreateSQL File (.sql)
CreateTabDelimitedParser File (.py)
CreateTableXML Directory (schema/)
iPymerase No Output

1.1.5  System Requirements

Output Module Python Module Req. Other Requirements
CreateCppAPI None GCC, Make
CreateDBAPI Pygresql (pgdb), mxDatetime (mx.DateTime) Postgresql
CreateGraphvizUML None Graphviz (dot)
CreatePyTkDBWidgets CreateDBAPI, Tkinter (Standard package) None
CreatePyTkWidgets Tkinter (Standard package) None
CreatePythonAPI mxDateTime None
CreateReport None None
CreateSQL None PostgreSQL
CreateTabDelimitedParser CreateDBAPI (Optional) None
CreateTableXML None None
iPymerase None ipython

2  CreateDBAPI

2.1  Description

CreateDBAPI generates a Python Database API to simplify the task of creating Python programs which can access a database. For the DBAPI to work, you need to have a database, you can either try to make a compatible DBAPI for your existing database, or you can use the CreateSQL output module to generate the SQL statements you need to generate your database.

2.2  Usage

Once you generate your DBAPI, you'll want to use it. Below is an example of how to use your DBAPI.
#!/usr/bin/env python2.2

from YourAPI import DBSession

if __name__ == '__main__':
  dbs = DBSession(dsn='localhost',
                  database='dbName',
		  user='userName',
		  password=None)

  #######################################################
  # Getting Objects from the database
  #######################################################
  # Create ObjOne and ObjTwo objects
  #get all ObjectTypeOne objects
  objectTypeOneList = dbs.getAllObjects(dbs.ObjectTypeOne)

  #get all ObjectTypeTwo objects
  groupList = dbs.getAllObjects(dbs.Group)

  #get ObjectTypeOne with primary key/id of 1
  ObjTypeOneId1 = dbs.getObject(dbs.ObjectTypeOne, '1')

  #get ObjectTypeTwo objects with primary keys 1, 3, 4
  ObjTypeTwo134 = dbs.getObject(dbs.NameLinkPair,
                             ['1', '3', '4'])

  #get ObjectTypeOne by database field 'name'
  ObjTypeOneSomeNameList = dbs.getObjectWhere(dbs.ObjectTypeOne,
                                              'name = \'someName\'') 

  #get ObjectTypeTwo that is associated with 'ObjectTypeOne'
  # with name of 'someName'
  if len(ObjTypeOneSomeNameList) > 0:
    someNameObj = ObjTypeOneSomeNameList[0]
    objType2 = someNameObj.getObjectTypeTwo()

  #######################################################
  # Create new objects and associate them with eachother.
  #######################################################
  # Create one new ObjOne, and two new ObjTwo objects
  obj1 = dbs.ObjOne()
  obj2 = dbs.ObjTwo()
  obj2b = dbs.ObjTwo()
  
  #make an association between object one and two
  obj1.setObjTwo(obj2)

  #add another ObjTwo to obj1
  obj1.appendObjTwo(obj2b)

  #get all ObjTwo's associated with ObjOne
  obj2List = obj1.getObjTwo()
  print obj2List #--> [ obj2, obj2b ]

  #commit changes to database
  obj1.commit()
  

2.3  Caveats

2.3.1  Packages

Pymerase has a partial implementation of a concept known in UML terms as a Package. A Package allows you to define a portion of your model which are closely related, so that it may be better organized.
The goal is to allow the generation of different packages with CreateDBAPI. Instead of generating SomeAPI, Pymerase would generate SomeAPI.Package1 and SomeAPI.Package2.
For now, Pymerase is only aware of one package. CreateDBAPI needs to know about the package name inorder for the generated DBAPI to work properly. If you are using parseXMI, it's defined by the UML namespace and/or package name. If you are using parseGenexSchemaXML, it's defined by the destination directory you supply when running Pymerase.

3  CreateGraphvizUML

3.1  Description

CreateGraphvizUML uses the Pymerase API to generate a 'dot' file which can then be used by a Graphviz program called 'dot' to generate graphs which look similar to UML.
This output module isn't really needed if you are using UML as the input source. If you are using the Table.dtd XML file format, then this module becomes useful for displaying your schema to the world.

3.2  Usage

Once you have generated a '.dot' file, you use the following line to generate a '.ps' (postscript) file.
dot -Tps -o nameOfPsFile.ps nameOfDotFile.dot

You should end up with something that looks like the image in Figure 1, which was taken from the xmiSchool example included with Pymerase.
Figure
Figure 1: CreateGraphvizUML Example Output: xmiSchool Example

3.3  Caveats

3.3.1  UML Diagram Compatiblity

In UML, the inheritance arrows have a hollow (white) arrow pointing to the base class which is being inherited from. Unfortunately, I was unable to figure out how to generate these types of arrows with Graphviz. I had to use solid (black) arrows with a dashed line to represent inheritance.

4  CreateReport

4.1  Description

CreateReport is an alternative Output Module developement tool to iPymerase. It generates a human readable text file describing your model using Pymerase API terms. It may not expose all of the Pymerase API functionality, but it can be helpful when you can't use the iPymerase output module.
It's also a good template to start from when creating a new Output module.

4.2  Usage

Just create your .txt file and open it up in your favorite text viewer. =o)

4.3  Caveats

4.3.1  Not Complete

CreateReport isn't complete as it doesn't use all of the Pymerase API, but it does use enough to be useful.

5  CreateSQL

5.1  Description

CreateSQL generates SQL statements that can be used to genearte a database base on the model you provided to Pymerase.

5.2  Usage

Once you have generated your sql file and have PostgreSQL installed, you can create your database. Use the following commands in a shell to setup your database.
$ createdb db_name
CREATE DATABASE

$ psql db_name < name_of_sql_file.sql
<SQL DATABASE GENEARTION MESSAGES>

If everything went well, you should have a database. You should be able to test your database by typing the following commands.
$ psql db_name

db_name=# \dt
 <list of tables shown>

5.3  Caveats

5.3.1  PostgreSQL Only

Currently, Pymerase has been setup to support PostgreSQL only. It shouldn't be too hard to make Pymerase compatible with other Database Management Programs such as MySQL or Oracle. Although, this has not been a priorty and will have to wait for future versions of Pymerase.
Note that the SQL that Pymerase generates uses PostgreSQL sequences and inheritance.

5.3.2  PostgreSQL Table Names

Note that postgres will prune table names that have greater than 32 characters.

6  CreateTabDelimitedParser

6.1  Description

Note that the description below is for the alpha version of the CreateTabDelimitedParser output module. New and improved features are likely to be added in the near future.
This output module generates a tab delimited text file parser. To generate the parser correctly you need to define a single 'Class' in UML, or a single 'Table' using table.dtd XML. The first attribute in the class/table will be column 0 (first column). The second attribute in the class/table will be column 1 (second column) and so on and so forth.
The Parser file itself contains the following:
*Parser Tab Delimited Text Parser
*Record Stores One Line of Parsed Text
*Master Base Container Class of *Records
*PickleMaster Inherits from *Master
Enables class to pickle itself to disk
*DbMaster Inherits from *Master
Enables class to save to DB via DBAPI
The *Master class provides a save() function which doesn't do much by itself. The purpose to this class is to be a base class for a custom Master class which has a custom save command. Two super classes have been provide for use. *PickleMaster which uses Python's 'pickle', to save itself to disc. *DbMaster, on the other hand, will save to database which can be generated by 'CreateSQL' output module. And then accessed by the DBAPI generated by the 'CreateDBAPI' output module.

6.2  Usage

To use the use the parser to save your tab delimited text file to a database after you created the database (CreateSQL) and generated the DBAPI (CreateDBAPI), your import the generated parser module and type the following python code.
#Note that * are replaced by more meaningful names when the parser
# is generated.

#Choose a Master container class and pass it to the parser
parser = *Parser(*DbMaster)

#Pass the file name of the tab delimited text to the parser
parsedData = parser.parse(fileName)

#Tell the parsed data to save itself to the database.
parsedData.save('localhost', 'myDatabase', 'myUser', 'myPassword')

Hopefully that helps, but if are confused or have any questions, feel free to send a message to one of the Pymerase mailing lists. Also note that the generated tab delimited text parser contains documention on how to use it.

7  CreateTableXML

7.1  Description

CreateTableXML generates XML files of your model which can then be read back into Pymerase using the parseGenexSchemaXML input module. This is convenient when you would like to provide Pymerase with more information than you can include with a UML program.

7.2  Usage

All you have to do is tell Pymerase what directory you want your XML files to end up in and then your done. Edit away, and then feed it back into Pymerase.

8  iPymerase

8.1  Description

iPymerase is meant as an Output Module developement tool. It will drop you into an ipython interactive interpreter and allow you to explore the Pymerase API which has been filled up with your model. You can explore the Pymerase API and learn how to use it and then write your new Output Module.

8.2  Usage

Just run pymerase using anything other than the Pymweb interface to Pymerase and launch the iPymerase output module. You will see the following output once iPymerase has been activated.
Welcome to iPymerase!

pymerase class list variable is 'classList'

Convenience Functions:
  printClassess(classList)
  printAttributes(attribList)
  printAssociations(assocList)
  getClassByName(classList, className)
  getAttribByName(attribList, attribName)
  getAssocByName(assocList, assocName)

In [1]: 

Just start exploring the classList and your all set.

8.3  Caveats

8.3.1  pymerasegui.py / pymerase -gui

If you run iPymerase from the Pymerase GUI, then you will have to make sure you exit the ipython interpreter when your done, otherwise the Pymerase GUI won't shutdown or let you run Pymerase again.



File translated from TEX by TTH, version 3.40.
On 7 Jul 2003, 18:24.
Last Modified: Wednesday, 07-May-2003 00:56:29 UTC