Package: pdxdisplay
A simple web application for viewing PDX (Product Data eXchange) XML
filesIntroductionFromthe Wikipedia article on
PDX: “the PDX (Product
Data eXchange) standard for manufacturing is a multi-part standard,
represented by the IPC 2570 series of specifications.”As the name implies, it is a standard for exchanging product definition
between companies or organizations, and can include bill of material
(BOM), approved manufacturer list, drawings, documents, etc.; pretty
much anything can be included if desired.In simple terms, a *.pdx file (usually exported from Agile/Oracle) is
really just a ZIP file that contains all the files (“attachments”)
associated with the product (assembly), plus a special XML file calledpdx.xml. This XML file contains the particulars of the various Items
and their properties/attributes, the relationship between the Items,
which forms the bill-of-materials (BOM), and also information about the
various files that are inside the PDX/ZIP file.The DTD of this XML file (identified as “DTD 2571 200111”) can be found
on theIPC
website.
Free PDX viewers are available, one of the most popular being PDXViewer
fromPDXplorer.Since the *.pdx file is simply a ZIP file, it is easy to extract all
the attachments (documents, schematics, drawings, etc.) from the ZIP
file, and there are several ways one can view XML files. However, trying
to make sense of the assembly from a generic XML viewer is not really
feasible, and although there are specialized free (and non-free)
viewers, there are times when you might want to extract the data for
your own use. To this end I have written a simple PDX XML file parser,pypdxfor doing this (for
details, please head over to the github page or thePython Package
Indexsite.Thepypdxprogram can be used as a Python module, but also as a
command-line stand-alone program that is more or less ready to use. But
after storing the data into the database, you have to figure out how to
view it. To make life easier for people who just want a quick view of
what the items and bill of materials looks like, there is now a separate
programpdxdisplaythat will let you import and display the items.
(I had wanted to call itpdxviewer, butthat name is already
taken.)Thepdxdisplayprogram is a web application written inFlaskthat provides a simple interface
(via a web browser) to upload and display a PDX XML file. The program
depends on thepypdxmodule.Please note that this is not intended to be a full-fledged viewer for
PDX XML files (never mind managing the complete PDX file with all the
attachements). In particular it does not run on HTTPS (although it is
trivial to do that with a simple add-on module), there is no user
authentication, and it does not allow any editing of the data. There is
minimal sorting providing, but no additional filtering or searching.
Also note that some of the data from the PDX XML file is not included
(see thepypdxmodule). In particular, none of theAdditionalAttributefields in the XML file are included (I might add
those at a later time, but no promises).Nevertheless, I hope this might still be useful to some people. This is
of course provided at no cost, and with no warranty. Use at your own
risk!Installation and UsageTo install the module and program, runpip install pdxdisplayThis should install all the necessary dependencies, and create an
executable pdxdisplay. Before you run this program, you will need a
database: either aSQLite3database or aPostgreSQLdatabase, as described in
document for thepypdxmodule. You specify the DSN by setting up the
environment variablePDX_DSN; thepdxdisplayprogram will not run
without this.If you are using the SQLite3 file-based database, do something like
this:% set PDX_DSN=mydatabase.sqlite3
% pdxdisplay(the extension of the SQLite3 database file needs to end with the
extension.sqlite3for the program to recognize it as a SQLite3 file).
For a PostgreSQL database, do something like this% set PDX_DSN="dbname='pdx' user='pdxuser' host='localhost' password='billofmaterials' port=5432"
$ pdxdisplayIf you are connecting to the default PostgreSQL databasepdx(as
listed above), you can also use the short-hand:% set PDX_DSN=pg
% pdxdisplayRunning thepdxdisplayprogram will start the Flask web server athttp://localhost:5000/You can then connect to this URL with your web browser.By defaultFlaskdoes not accept external connections (i.e.,
connections from outside your computer). If you really want to accept
external connections, set the environment variablePDX_EXTACCESSto 1:% export PDX_EXACCESS=1before runningpdxdisplay(but keep in mind that the connection is not
encrypted, nor is there any authentication).Note that you do not really need to install the PostgreSQL component if
you do not care for the PostgreSQL database. You should still be able to
use the program without installing thepsycopg2module, since it is
not imported unless you specify the PostgreSQL database option. But
there maybe dependencies issues when trying to install this throughpip.Issues with Python2Thepdxdisplayprogram was tested primarily with Python3, and for best
results you should use the Python3. If you are running one of the Ubuntu
derivates, it is likely that yourpythonis Python2, and Python3 is
listed aspython3. In this case you may try to change “#!” line in thepdxdisplayfile to point to python3. The programshouldrun under
Python2 also, but there were some issues having to do with non-ASCII
characters that caused the program to fail. Specifically, it seems that
non-ASCII characters sent to therender_template()method (from Flask)
will cause it to break. This only occurs with Python2; Python3 does not
have this problem.As a work-around, the program will filter out all non-ASCII characters
in thedescriptionfields (of the Item, Attachments, etc. tables), butonly if it detects the script running under Python2. However, the
program does not check for this in other fields. If there are non-ASCII
characters in those fields, the program will likely crash (but, as I
said, only if you are using Python2).Even in Python3, you may need to set your locale to UTF-8 when using a
SQLite3 database file. In particular, if you are running this in aUbuntu docker container, set the
environment variables:% export LC_ALL=C.UTF-8
% export LANG=C.UTF-8Closing RemarksI have only seen a very small number of PDX files, and there does not
seem to be any sample PDX files that you can download from the Internet
(likely because the only PDX files available contain proprietary
manufacturing information!). Naturally the testing of thepypdxmodule
and thepdxdisplayprogram has been very limited. While I believe the
implementation to be correct (if incomplete), there is always the
possibility of bugs. So use at your own risk; you have been warned!(Last Revised 2018-02-01)