dabo Commit
Revision 4553
Date: 2008-10-05 15:51:41 -0700 (Sun, 05 Oct 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4553
Changed:
A trunk/daboserver/
A trunk/daboserver/__init__.py
A trunk/daboserver/appSource/
A trunk/daboserver/appSource/orders/
A trunk/daboserver/appSource/orders/App.py
A trunk/daboserver/appSource/orders/__version__.py
A trunk/daboserver/appSource/orders/biz/
A trunk/daboserver/appSource/orders/biz/Base.py
A trunk/daboserver/appSource/orders/biz/Orders.py
A trunk/daboserver/appSource/orders/biz/__init__.py
A trunk/daboserver/appSource/orders/buildwin.bat
A trunk/daboserver/appSource/orders/db/
A trunk/daboserver/appSource/orders/db/__init__.py
A trunk/daboserver/appSource/orders/db/default.cnxml
A trunk/daboserver/appSource/orders/db/getSampleDataSet.py
A trunk/daboserver/appSource/orders/go.sh
A trunk/daboserver/appSource/orders/orders.exe.manifest
A trunk/daboserver/appSource/orders/orders.py
A trunk/daboserver/appSource/orders/reports/
A trunk/daboserver/appSource/orders/reports/sampleReport.rfxml
A trunk/daboserver/appSource/orders/resources/
A trunk/daboserver/appSource/orders/setup.py
A trunk/daboserver/appSource/orders/test/
A trunk/daboserver/appSource/orders/ui/
A trunk/daboserver/appSource/orders/ui/FrmBase.py
A trunk/daboserver/appSource/orders/ui/FrmMain.py
A trunk/daboserver/appSource/orders/ui/FrmOrders.py
A trunk/daboserver/appSource/orders/ui/FrmReportBase.py
A trunk/daboserver/appSource/orders/ui/FrmReportSample.py
A trunk/daboserver/appSource/orders/ui/GrdBase.py
A trunk/daboserver/appSource/orders/ui/GrdOrders.py
A trunk/daboserver/appSource/orders/ui/MenFileOpen.py
A trunk/daboserver/appSource/orders/ui/MenReports.py
A trunk/daboserver/appSource/orders/ui/PagBase.py
A trunk/daboserver/appSource/orders/ui/PagEditBase.py
A trunk/daboserver/appSource/orders/ui/PagEditOrders.py
A trunk/daboserver/appSource/orders/ui/PagSelectBase.py
A trunk/daboserver/appSource/orders/ui/PagSelectOrders.py
A trunk/daboserver/appSource/orders/ui/__init__.py
A trunk/daboserver/config/
A trunk/daboserver/config/__init__.py
A trunk/daboserver/config/deployment.ini_tmpl
A trunk/daboserver/config/environment.py
A trunk/daboserver/config/middleware.py
A trunk/daboserver/config/routing.py
A trunk/daboserver/controllers/
A trunk/daboserver/controllers/OrdersBizobj.py
A trunk/daboserver/controllers/README.txt
A trunk/daboserver/controllers/__init__.py
A trunk/daboserver/controllers/bizservers.py
A trunk/daboserver/controllers/error.py
A trunk/daboserver/lib/
A trunk/daboserver/lib/__init__.py
A trunk/daboserver/lib/app_globals.py
A trunk/daboserver/lib/base.py
A trunk/daboserver/lib/helpers.py
A trunk/daboserver/model/
A trunk/daboserver/model/__init__.py
A trunk/daboserver/public/
A trunk/daboserver/public/bg.png
A trunk/daboserver/public/index.html
A trunk/daboserver/public/pylons-logo.gif
A trunk/daboserver/templates/
A trunk/daboserver/tests/
A trunk/daboserver/tests/__init__.py
A trunk/daboserver/tests/functional/
A trunk/daboserver/tests/functional/__init__.py
A trunk/daboserver/tests/functional/test_bizobj.py
A trunk/daboserver/tests/functional/test_bizservers.py
A trunk/daboserver/tests/test_models.py
A trunk/daboserver/websetup.py
Log:
This is the app portion of the Pylons code used to create the server side of a
Dabo web application. If you have Pylons installed, this is the second-level
directory that is created inside the main directory of the app. Since the main
directory contains common distutils stuff, I've not included it here.
The 'appSource' directory contains a typical datanav application using the
dabodev.com public database. I chose this because there still are some unicode
issues to work out, and this has lots of non-ASCII values. For your own app,
place each app in its own directory under 'appSource'.
The only files you would have to customize are in the daboserver/controllers/
directory. First, you have to add your RemoteBizobj classes there, and then
modify bizservers.py to import them. Instructions for customizing bizservers.py
are in the comments of that file.
Diff:
Added: trunk/daboserver/__init__.py
===================================================================
Added: trunk/daboserver/appSource/orders/App.py
===================================================================
--- trunk/daboserver/appSource/orders/App.py (rev 0)
+++ trunk/daboserver/appSource/orders/App.py 2008-10-05 22:51:41 UTC (rev
4553)
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+
+import dabo
+from __version__ import version
+
+
+class App(dabo.dApp):
+ def initProperties(self):
+ # Manages how preferences are saved
+ self.BasePrefKey = "dabo.app.orders"
+
+ ## The following information can be used in various places in
your app:
+ self.setAppInfo("appShortName", "Orders")
+ self.setAppInfo("appName", "Orders")
+ self.setAppInfo("companyName", "Your company name")
+ self.setAppInfo("companyAddress1", "Your company address")
+ self.setAppInfo("companyAddress2", "Your company CSZ")
+ self.setAppInfo("companyPhone", "Your company phone")
+ self.setAppInfo("companyEmail", "Your company email")
+ self.setAppInfo("companyUrl", "Your company url")
+
+ self.setAppInfo("appDescription", "")
+
+ ## Information about the developer of the software:
+ self.setAppInfo("authorName", "")
+ self.setAppInfo("authorEmail", "")
+ self.setAppInfo("authorURL", "")
+
+ ## Set appVersion and appRevision from __version__.py:
+ self.setAppInfo("appVersion", version["version"])
+ self.setAppInfo("appRevision", version["revision"])
+
+ def setup(self):
+ if dabo.settings.MDI:
+ self.MainFormClass = self.ui.FrmMain
+ else:
+ # no need for main form in SDI mode:
+ self.MainFormClass = None
+ self.super()
Added: trunk/daboserver/appSource/orders/__version__.py
===================================================================
--- trunk/daboserver/appSource/orders/__version__.py
(rev 0)
+++ trunk/daboserver/appSource/orders/__version__.py 2008-10-05 22:51:41 UTC
(rev 4553)
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+
+# Place your application's version information in the dictionary, and your
+# Application object will store it in getAppInfo("appVersion") and
+# getAppInfo("appRevision").
+
+version = {"version": "", "revision": ""}
Added: trunk/daboserver/appSource/orders/biz/Base.py
===================================================================
--- trunk/daboserver/appSource/orders/biz/Base.py
(rev 0)
+++ trunk/daboserver/appSource/orders/biz/Base.py 2008-10-05 22:51:41 UTC
(rev 4553)
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+
+import dabo.lib.datanav2 as datanav
+
+class Base(datanav.Bizobj):
+
+ def afterInit(self):
+ self.super()
+ self.setBaseSQL()
+
+
+ def setBaseSQL(self):
+ """Hook for subclasses to set the base sql, using
self.addField(), etc."""
+ pass
+
+
+ def addFieldsFromDataStructure(self):
+ """Call addField() for each field listed in
self.DataStructure."""
+ # The max_fill stuff has to do with getting the sql looking
pretty, by
+ # lining up the "as" keyword horizontally.
+ max_fill = 0
+ for field in self.DataStructure:
+ fill = len("%s.%s" % (field[3], field[4]))
+ max_fill = max(max_fill, fill)
+ for field in self.DataStructure:
+ fill = " " * (max_fill - len("%s.%s" % (field[3],
field[4])))
+ self.addField("%s.%s %sas %s" % (field[3], field[4],
fill, field[0]))
Added: trunk/daboserver/appSource/orders/biz/Orders.py
===================================================================
--- trunk/daboserver/appSource/orders/biz/Orders.py
(rev 0)
+++ trunk/daboserver/appSource/orders/biz/Orders.py 2008-10-05 22:51:41 UTC
(rev 4553)
@@ -0,0 +1,67 @@
+# -*- coding: utf-8 -*-
+
+from Base import Base
+
+
+class Orders(Base):
+
+ def initProperties(self):
+ self.super()
+ self.Caption = "Orders"
+ self.DataSource = "orders"
+ self.KeyField = "pkid"
+
+ # Setting the DataStructure explicitly here is optional, but
recommended as
+ # it will keep Dabo from interpreting field types from the
backend every
+ # time. It lets you specify what types you expect which fields
to be. Also,
+ # this information is used in self.setSQL() to add the fields
to the query.
+ # (field_alias, field_type, pk, table_name, field_name,
field_scale)
+ self.DataStructure = (
+ ("pkid", "I", True, "orders", "pkid"),
+ ("cust_fk", "I", False, "orders", "cust_fk"),
+ ("employee_fk", "I", False, "orders",
"employee_fk"),
+ ("order_id", "C", False, "orders", "order_id"),
+ ("cust_id", "C", False, "orders", "cust_id"),
+ ("emp_id", "C", False, "orders", "emp_id"),
+ ("to_name", "C", False, "orders", "to_name"),
+ ("to_address", "C", False, "orders",
"to_address"),
+ ("to_city", "C", False, "orders", "to_city"),
+ ("to_region", "C", False, "orders",
"to_region"),
+ ("postalcode", "C", False, "orders",
"postalcode"),
+ ("to_country", "C", False, "orders",
"to_country"),
+ ("ship_count", "C", False, "orders",
"ship_count"),
+ ("ship_via", "C", False, "orders", "ship_via"),
+ ("order_date", "D", False, "orders",
"order_date"),
+ ("order_amt", "N", False, "orders",
"order_amt"),
+ ("order_dsc", "I", False, "orders",
"order_dsc"),
+ ("order_net", "N", False, "orders",
"order_net"),
+ ("require_by", "D", False, "orders",
"require_by"),
+ ("shipped_on", "D", False, "orders",
"shipped_on"),
+ ("freight", "N", False, "orders", "freight"),
+ )
+
+ # Use the DefaultValues dict to specify default field values
for new
+ # records. By default DefaultValues is the empty dict, meaning
that
+ # no default values will be filled in.
+ #self.DefaultValues['<field_name>'] = <value_or_function_object>
+
+ # Default encoding is set to utf8, but if your backend db
encodes in
+ # something else, you need to set that encoding here (or in
each
+ # bizobj individually. A very common encoding for the Americas
and
+ # Western Europe is "latin-1", so if you are getting errors but
are
+ # unsure what encoding to pick, try uncommenting the following
line:
+ #self.Encoding = "latin-1"
+
+
+ def afterInit(self):
+ self.super()
+
+
+ def setBaseSQL(self):
+ # Set up the base SQL (the fields clause, the from clause,
etc.) The
+ # UI refresh() will probably modify the where clause and maybe
the
+ # limit clause, depending on what the runtime user chooses in
the
+ # select page.
+ self.addFrom("orders")
+ self.setLimitClause("500")
+ self.addFieldsFromDataStructure()
Added: trunk/daboserver/appSource/orders/biz/__init__.py
===================================================================
--- trunk/daboserver/appSource/orders/biz/__init__.py
(rev 0)
+++ trunk/daboserver/appSource/orders/biz/__init__.py 2008-10-05 22:51:41 UTC
(rev 4553)
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+
+## To have your bizobjs available from Application.biz, you need to explicitly
+## import them by name here.
+
+from Orders import Orders
Added: trunk/daboserver/appSource/orders/buildwin.bat
===================================================================
--- trunk/daboserver/appSource/orders/buildwin.bat
(rev 0)
+++ trunk/daboserver/appSource/orders/buildwin.bat 2008-10-05 22:51:41 UTC
(rev 4553)
@@ -0,0 +1,9 @@
+del /q dist
+rmdir /s /q dist
+python -OO setup.py py2exe --bundle 3
+
+rem You may need to change these paths:
+copy c:\python25\lib\site-packages\wx-2.8-msw-unicode\wx\MSVCP71.dll dist
+copy c:\python25\lib\site-packages\wx-2.8-msw-unicode\wx\gdiplus.dll dist
+copy c:\windows\system32\mfc71.dll dist
+
Added: trunk/daboserver/appSource/orders/db/__init__.py
===================================================================
--- trunk/daboserver/appSource/orders/db/__init__.py
(rev 0)
+++ trunk/daboserver/appSource/orders/db/__init__.py 2008-10-05 22:51:41 UTC
(rev 4553)
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+
+## To have any database functions, classes, etc. available from the
+## Application.db namespace, you need to explicitly import them by name here.
+
+# example:
+# from getInvoicesDataSet import getInvoicesDataSet
+
+from getSampleDataSet import getSampleDataSet
Added: trunk/daboserver/appSource/orders/db/default.cnxml
===================================================================
--- trunk/daboserver/appSource/orders/db/default.cnxml
(rev 0)
+++ trunk/daboserver/appSource/orders/db/default.cnxml 2008-10-05 22:51:41 UTC
(rev 4553)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<connectiondefs xmlns="http://www.dabodev.com"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://www.dabodev.com conn.xsd"
+xsi:noNamespaceSchemaLocation = "http://dabodev.com/schema/conn.xsd">
+
+ <connection dbtype="Web">
+ <name>Orders</name>
+ <remotehost>http://localhost:7777</remotehost>
+ <host></host>
+ <database></database>
+ <user></user>
+ <password></password>
+ <port></port>
+ </connection>
+
+
+</connectiondefs>
Added: trunk/daboserver/appSource/orders/db/getSampleDataSet.py
===================================================================
--- trunk/daboserver/appSource/orders/db/getSampleDataSet.py
(rev 0)
+++ trunk/daboserver/appSource/orders/db/getSampleDataSet.py 2008-10-05
22:51:41 UTC (rev 4553)
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+
+import datetime
+import decimal
+import dabo
+
+
+def getSampleDataSet():
+ """Return the dataset for the sample report.
+
+ Your real code here would run ad-hoc sql queries and build up a
+ dataset (list of dicts).
+ """
+ ds = [{"name": "Denise", "sex": "F"},
+ {"name": "Paul", "sex": "M"}]
+ return ds
+
Added: trunk/daboserver/appSource/orders/go.sh
===================================================================
--- trunk/daboserver/appSource/orders/go.sh (rev 0)
+++ trunk/daboserver/appSource/orders/go.sh 2008-10-05 22:51:41 UTC (rev
4553)
@@ -0,0 +1,5 @@
+# go.sh
+# launches the orders app.
+cd /Users/ed/apps/daboserver/daboserver/appSource/orders
+python orders.py Orders
+# python orders.py --OpenAll
Property changes on: trunk/daboserver/appSource/orders/go.sh
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/daboserver/appSource/orders/orders.exe.manifest
===================================================================
--- trunk/daboserver/appSource/orders/orders.exe.manifest
(rev 0)
+++ trunk/daboserver/appSource/orders/orders.exe.manifest 2008-10-05
22:51:41 UTC (rev 4553)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+<assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="*.*.*"
type="win32" />
+<description>*</description>
+<dependency>
+<dependentAssembly>
+<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls"
+ version="6.0.0.0" processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df" language="*" />
+</dependentAssembly>
+</dependency>
+</assembly>
Added: trunk/daboserver/appSource/orders/orders.py
===================================================================
--- trunk/daboserver/appSource/orders/orders.py (rev 0)
+++ trunk/daboserver/appSource/orders/orders.py 2008-10-05 22:51:41 UTC (rev
4553)
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# If this is a web application, set the remote host here
+remotehost = "http://localhost:7777"
+
+import sys
+import os
+import dabo
+
+# The loading of the UI needs to happen before the importing of the
+# db, biz, and ui packages:
+dabo.ui.loadUI("wx")
+if sys.platform[:3] == "win":
+ dabo.settings.MDI = True
+
+from App import App
+app = App(SourceURL=remotehost)
+
+import db
+import biz
+import ui
+
+app.db = db
+app.biz = biz
+app.ui = ui
+
+# If we are running frozen, let's reroute the errorLog:
+if hasattr(sys, "frozen"):
+ dabo.errorLog.Caption = ""
+ dabo.errorLog.LogObject = open(os.path.join(app.HomeDirectory,
+ "error.log"), "a")
+
+# Make it easy to find any images or other files you put in the resources
+# directory.
+sys.path.append(os.path.join(app.HomeDirectory, "resources"))
+
+# Set the BasePrefKey for the app
+app.BasePrefKey = "orders"
+app.setup()
+
+# Set up a global connection to the database that all bizobjs will share:
+app.dbConnection = app.getConnectionByName("Orders")
+
+# Open one or more of the defined forms. A default one was picked by the app
+# generator, but you can change that here. Additionally, if form names were
+# passed on the command line, they will be opened instead of the default one
+# as long as they exist.
+ui = app.ui
+default_form = ui.FrmOrders
+formsToOpen = []
+form_names = [class_name[3:] for class_name in dir(ui) if class_name[:3] ==
"Frm"]
+for arg in sys.argv[1:]:
+ arg = arg.lower()
+ for form_name in form_names:
+ if arg == form_name.lower():
+ formsToOpen.append(getattr(ui, "Frm%s" % form_name))
+if not formsToOpen:
+ formsToOpen.append(default_form)
+for frm in formsToOpen:
+ frm(app.MainForm).show()
+
+# Start the application event loop:
+app.start()
Property changes on: trunk/daboserver/appSource/orders/orders.py
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/daboserver/appSource/orders/reports/sampleReport.rfxml
===================================================================
--- trunk/daboserver/appSource/orders/reports/sampleReport.rfxml
(rev 0)
+++ trunk/daboserver/appSource/orders/reports/sampleReport.rfxml
2008-10-05 22:51:41 UTC (rev 4553)
@@ -0,0 +1,231 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+
+<report>
+ <page>
+ <marginBottom>".5 in"</marginBottom>
+ <marginLeft>".75 in"</marginLeft>
+ <marginRight>".75 in"</marginRight>
+ <marginTop>".75 in"</marginTop>
+ <orientation>"portrait"</orientation>
+ <size>"letter"</size>
+ </page>
+
+ <pageHeader>
+ <height>"1.75 in"</height>
+ <objects>
+ <string>
+ <align>"left"</align>
+ <vAlign>"top"</vAlign>
+ <vAnchor>"top"</vAnchor>
+ <borderWidth>"0 pt"</borderWidth>
+
<expr>self.Application.getAppInfo("companyName")</expr>
+ <fontName>"Helvetica"</fontName>
+ <fontBold>True</fontBold>
+ <fontSize>14</fontSize>
+ <hAnchor>"left"</hAnchor>
+ <height>16</height>
+ <name>companyName</name>
+ <width>"4 in"</width>
+ <x>"1.1 in"</x>
+ <y>"1.7875 in"</y>
+ </string>
+
+ <string>
+ <align>"left"</align>
+ <vAlign>"top"</vAlign>
+ <vAnchor>"top"</vAnchor>
+ <borderWidth>"0 pt"</borderWidth>
+
<expr>self.Application.getAppInfo("companyAddress1")</expr>
+ <fontName>"Helvetica"</fontName>
+ <fontSize>14</fontSize>
+ <hAnchor>"left"</hAnchor>
+ <height>16</height>
+ <name>companyAddress1</name>
+ <width>"4 in"</width>
+ <x>"1.1 in"</x>
+ <y>"1.5575 in"</y>
+ </string>
+
+ <string>
+ <align>"left"</align>
+ <vAlign>"top"</vAlign>
+ <vAnchor>"top"</vAnchor>
+ <borderWidth>"0 pt"</borderWidth>
+
<expr>self.Application.getAppInfo("companyAddress2")</expr>
+ <fontName>"Helvetica"</fontName>
+ <fontSize>14</fontSize>
+ <hAnchor>"left"</hAnchor>
+ <height>16</height>
+ <name>companyAddress1</name>
+ <width>"4 in"</width>
+ <x>"1.1 in"</x>
+ <y>"1.3275 in"</y>
+ </string>
+
+ <string>
+ <align>"left"</align>
+ <vAlign>"top"</vAlign>
+ <vAnchor>"top"</vAnchor>
+ <borderWidth>"0 pt"</borderWidth>
+
<expr>self.Application.getAppInfo("companyPhone")</expr>
+ <fontName>"Helvetica"</fontName>
+ <fontSize>14</fontSize>
+ <hAnchor>"left"</hAnchor>
+ <height>16</height>
+ <name>companyAddress1</name>
+ <width>"7 in"</width>
+ <x>"1.1 in"</x>
+ <y>"1.0975 in"</y>
+ </string>
+
+ <string>
+ <align>"right"</align>
+ <vAlign>"top"</vAlign>
+ <vAnchor>"top"</vAnchor>
+ <borderWidth>"0 pt"</borderWidth>
+ <expr>self.ReportForm["title"]</expr>
+ <fontName>"Helvetica"</fontName>
+ <fontSize>36</fontSize>
+ <hAnchor>"right"</hAnchor>
+ <height>30</height>
+ <name>title</name>
+ <width>"4 in"</width>
+ <x>self.Bands["pageHeader"]["width"]-1</x>
+ <y>self.Bands["pageHeader"]["height"]</y>
+ </string>
+
+ </objects>
+ </pageHeader>
+
+ <variables>
+<!--
+ <variable>
+ <name>clientBalance</name>
+ <expr>self.Variables['clientBalance'] +
self.Record['amount']</expr>
+ <initialValue>decimal.Decimal('0.00')</initialValue>
+ <resetAt>self.Record['clientid']</resetAt>
+ </variable>
+-->
+ </variables>
+
+ <groups>
+<!--
+ <group>
+ <expr>self.Record['clientid']</expr>
+ <startOnNewPage>True</startOnNewPage>
+ <groupHeader>
+ <height>"2.125 in"</height>
+ <objects>
+ <string>
+
<expr>self.Record["clientname"]</expr>
+ <height>20</height>
+ <width>"6 in"</width>
+ <fontSize>14</fontSize>
+ <x>"0 in"</x>
+ <y>"1.925 in"</y>
+ </string>
+ </objects>
+ </groupHeader>
+ <groupFooter>
+ <height>"0.25 in"</height>
+ <objects>
+ <string>
+ <expr>"Amount due: $
%s" % locale.format('%s',
+
self.Variables["clientBalance"], True)</expr>
+ <align>"right"</align>
+ <hAnchor>"right"</hAnchor>
+ <height>20</height>
+ <width>"6 in"</width>
+ <fontSize>14</fontSize>
+ <x>"7 in"</x>
+ <y>"0 in"</y>
+ </string>
+ </objects>
+ </groupFooter>
+ </group>
+ -->
+ </groups>
+
+ <detail>
+ <height>".25 in"</height>
+ <objects>
+ <rect>
+ <height>".25 in"</height>
+ <strokeWidth>".25 pt"</strokeWidth>
+ <width>"5.5 in"</width>
+ <x>"1.5 in"</x>
+ <y>"0 in"</y>
+ </rect>
+ <string>
+ <expr>self.Record["name"]</expr>
+ <height>15</height>
+ <width>"0.80 in"</width>
+ <x>"1.6 in"</x>
+ <y>5</y>
+ </string>
+ <line>
+ <strokeWidth>0.25</strokeWidth>
+ <strokeColor>(.2,.2,.2)</strokeColor>
+ <x>"2.605 in"</x>
+ <y>0</y>
+ <height>self.Bands["detail"]["height"]</height>
+ <width>0</width>
+ </line>
+ <string>
+ <expr>self.Record["sex"]</expr>
+ <height>15</height>
+ <width>"1.25 in"</width>
+ <x>"2.65 in"</x>
+ <y>5</y>
+ </string>
+ </objects>
+ </detail>
+
+ <pageBackground>
+ <objects>
+ <rect>
+ <strokeColor>(.7,.7,.7)</strokeColor>
+ <height>.25</height>
+ <width>.25</width>
+ <x>"0.25 in"</x>
+ <y>"6.875 in"</y>
+ </rect>
+ <rect>
+ <strokeColor>(.7,.7,.7)</strokeColor>
+ <height>.25</height>
+ <width>.25</width>
+ <x>"8.25 in"</x>
+ <y>"6.875 in"</y>
+ </rect>
+ </objects>
+ </pageBackground>
+
+ <pageFooter>
+ <height>"2.5 in"</height>
+ <objects>
+ <string>
+ <align>"center"</align>
+ <borderWidth>"0 pt"</borderWidth>
+ <expr>"This is a sample report generated by the
Dabo AppWizard"</expr>
+ <fontName>"Helvetica"</fontName>
+ <fontSize>12</fontSize>
+ <fontItalic>True</fontItalic>
+ <hAnchor>"center"</hAnchor>
+ <height>"0.25 in"</height>
+ <width>"8 in"</width>
+ <x>"3.5 in"</x>
+ <y>0</y>
+ </string>
+
+ </objects>
+ </pageFooter>
+
+ <testcursor name="str" sex="str">
+ <record name="'Ringo'" sex="'M'" />
+ <record name="'Patsy'" sex="'F'" />
+ <record name="'Johnny'" sex="'M'" />
+ </testcursor>
+
+ <title>Sample Report</title>
+
+</report>
Added: trunk/daboserver/appSource/orders/setup.py
===================================================================
--- trunk/daboserver/appSource/orders/setup.py (rev 0)
+++ trunk/daboserver/appSource/orders/setup.py 2008-10-05 22:51:41 UTC (rev
4553)
@@ -0,0 +1,124 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import os
+import sys
+import glob
+from distutils.core import setup
+import py2exe
+import dabo.icons
+from App import App
+
+
+daboDir = os.path.split(dabo.__file__)[0]
+
+
+# Find the location of the dabo icons:
+iconDir = os.path.split(dabo.icons.__file__)[0]
+iconSubDirs = []
+def getIconSubDir(arg, dirname, fnames):
+ if ".svn" not in dirname and dirname[-1] != "\\":
+ icons = glob.glob(os.path.join(dirname, "*.png"))
+ if icons:
+ subdir = (os.path.join("resources",
dirname[len(arg)+1:]), icons)
+ iconSubDirs.append(subdir)
+os.path.walk(iconDir, getIconSubDir, iconDir)
+
+# locales:
+localeDir = "%s%slocale" % (daboDir, os.sep)
+#locales = [("dabo.locale", (os.path.join(daboDir, "locale", "dabo.pot"),))]
+locales = []
+def getLocales(arg, dirname, fnames):
+ if ".svn" not in dirname and dirname[-1] != "\\":
+ #po_files = tuple(glob.glob(os.path.join(dirname, "*.po")))
+ mo_files = tuple(glob.glob(os.path.join(dirname, "*.mo")))
+ if mo_files:
+ subdir = os.path.join("dabo.locale", dirname[len(arg)+1:])
+ locales.append((subdir, mo_files))
+os.path.walk(localeDir, getLocales, localeDir)
+
+# The applications App object contains all the meta info:
+app = App(MainFormClass=None)
+app.setup()
+
+_appName = app.getAppInfo("appName")
+_appVersion = app.getAppInfo("appVersion")
+_appDescription = app.getAppInfo("appDescription")
+_copyright = app.getAppInfo("copyright")
+_authorName = app.getAppInfo("authorName")
+_authorEmail = app.getAppInfo("authorEmail")
+_authorURL = app.getAppInfo("authorURL")
+_authorPhone = app.getAppInfo("authorPhone")
+
+
+_appComments = ("This is custom software by %s.\r\n"
+ "\r\n"
+ "%s\r\n"
+ "%s\r\n"
+ "%s\r\n") % (_authorName, _authorEmail, _authorURL,
_authorPhone)
+
+# Set your app icon here:
+_appIcon = None
+#_appIcon = "./resources/stock_addressbook.ico"
+
+_script = "orders.py"
+
+
+class Target:
+ def __init__(self, **kw):
+ self.__dict__.update(kw)
+ # for the versioninfo resources
+ self.version = _appVersion
+ self.company_name = _authorName
+ self.copyright = _copyright
+ self.name = _appName
+ self.description = _appDescription
+ self.comments = _appComments
+
+ self.script=_script
+ self.other_resources=[]
+ if _appIcon is not None:
+ self.icon_resources=[(1, _appIcon)]
+
+
+data_files=[(".", ("orders.exe.manifest",)),
+ ("db", ["db/default.cnxml"]),
+ ("resources", glob.glob(os.path.join(iconDir, "*.ico"))),
+ ("resources", glob.glob("resources/*")),
+ ("reports", glob.glob("reports/*"))]
+data_files.extend(iconSubDirs)
+data_files.extend(locales)
+
+if sys.platform == "win32":
+ import py2exe
+ setup(name=_appName,
+ version=_appVersion,
+ description=_appDescription,
+ author=_authorName,
+ author_email=_authorEmail,
+ url=_authorURL,
+ options={"py2exe": {"packages": ["wx.gizmos",
"wx.lib.calendar"],
+ "optimize": 2,
+ "excludes":
["Tkconstants","Tkinter","tcl",
+ "_imagingtk", "PIL._imagingtk",
+ "ImageTk", "PIL.ImageTk", "FixTk"]}},
+ packages=["ui", "biz", "db"],
+ zipfile=None,
+ windows=[Target()],
+ data_files=data_files
+ )
+
+elif sys.platform == "darwin":
+ import py2app
+ setup(options={"py2app": {iconfile: _appIcon, packages: ['wx',
'wx.gizmos', 'wx.lib.calendar'],
+ site_packages: True, resources: [],
+ plist: dict(
+ CFBundleName =
"MyAppName",
+ CFBundleShortVersionString = "0.2.5",
# must be in X.X.X format
+ CFBundleGetInfoString = "MyAppName
0.2.5",
+ CFBundleExecutable =
"MyAppName",
+ CFBundleIdentifier =
"com.example.myappname",
+ ),
+ },
+ app: [_script]}
+ )
Added: trunk/daboserver/appSource/orders/ui/FrmBase.py
===================================================================
--- trunk/daboserver/appSource/orders/ui/FrmBase.py
(rev 0)
+++ trunk/daboserver/appSource/orders/ui/FrmBase.py 2008-10-05 22:51:41 UTC
(rev 4553)
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+
+import dabo.ui
+import dabo.lib.datanav2 as datanav
+from MenFileOpen import MenFileOpen
+from MenReports import MenReports
+
+
+class FrmBase(datanav.Form):
+
+ def initProperties(self):
+ self.super()
+ # Setting RequeryOnLoad to True will result in an automatic
requery upon
+ # form load, which may be appropriate for your app (if it is
reasonably
+ # certain that the dataset will be small no matter what).
+ self.RequeryOnLoad = False
+ self.Icon = "daboIcon.ico"
+
+
+ def setupMenu(self):
+ self.super()
+ self.fillFileOpenMenu()
+ self.fillReportsMenu()
+
+
+ def fillFileOpenMenu(self):
+ """Add the File|Open menu, with menu items for opening each
form."""
+ app = self.Application
+ fileMenu = self.MenuBar.getMenu("File")
+ fileMenu.prependMenu(MenFileOpen(fileMenu))
+
+
+ def fillReportsMenu(self):
+ """Add the Reports menu."""
+ app = self.Application
+ menReports = MenReports()
+
+ # We want the reports menu right after the Actions menu:
+ idx = self.MenuBar.getMenuIndex("Actions")
+ if idx is None:
+ # punt:
+ idx = 3
+ idx += 1
+ self.MenuBar.insertMenu(idx, menReports)
+
+ # The datanav form puts a Quick Report option at the end of the
Actions
+ # menu, but let's move it over to the Reports menu instead.
+ menu = self.MenuBar.getMenu("Actions")
+ idx = menu.getItemIndex("Quick Report")
+ if idx is not None:
+ qrItem = menu.remove(idx, False)
+ menReports = self.MenuBar.getMenu("Reports")
+ menReports.prependSeparator()
+ menReports.prependItem(qrItem)
+
+
Added: trunk/daboserver/appSource/orders/ui/FrmMain.py
===================================================================
--- trunk/daboserver/appSource/orders/ui/FrmMain.py
(rev 0)
+++ trunk/daboserver/appSource/orders/ui/FrmMain.py 2008-10-05 22:51:41 UTC
(rev 4553)
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+
+import dabo.ui
+from MenFileOpen import MenFileOpen
+
+
+class FrmMain(dabo.ui.dFormMain):
+
+ def afterInit(self):
+ self.super()
+ self.fillFileOpenMenu()
+
+
+ def initProperties(self):
+ self.super()
+ self.Icon = "daboIcon.ico"
+
+
+ def fillFileOpenMenu(self):
+ """Add the File|Open menu, with menu items for opening each
form."""
+ app = self.Application
+ fileMenu = self.MenuBar.getMenu("File")
+ fileMenu.prependMenu(MenFileOpen(fileMenu))
+
+
Added: trunk/daboserver/appSource/orders/ui/FrmOrders.py
===================================================================
--- trunk/daboserver/appSource/orders/ui/FrmOrders.py
(rev 0)
+++ trunk/daboserver/appSource/orders/ui/FrmOrders.py 2008-10-05 22:51:41 UTC
(rev 4553)
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+
+import os
+import dabo
+if __name__ == "__main__":
+ dabo.ui.loadUI("wx")
+from FrmBase import FrmBase
+from GrdOrders import GrdOrders
+from PagSelectOrders import PagSelectOrders
+from PagEditOrders import PagEditOrders
+
+
+class FrmOrders(FrmBase):
+
+ def initProperties(self):
+ self.super()
+ self.NameBase = "frmOrders"
+ self.Caption = "Orders"
+ self.SelectPageClass = PagSelectOrders
+ self.BrowseGridClass = GrdOrders
+ self.EditPageClass = PagEditOrders
+
+
+ def afterInit(self):
+ if not self.Testing:
+ # Instantiate the bizobj and register it with dForm,
and then let the
+ # superclass take over.
+ app = self.Application
+ bizOrders = app.biz.Orders(app.dbConnection)
+ self.addBizobj(bizOrders)
+ self.super()
+
+
+if __name__ == "__main__":
+ app = dabo.dApp(MainFormClass=None)
+ app.setup()
+ frm = FrmOrders(Caption="Test Of FrmOrders", Testing=True)
+ frm.show()
+ app.start()
Added: trunk/daboserver/appSource/orders/ui/FrmReportBase.py
===================================================================
--- trunk/daboserver/appSource/orders/ui/FrmReportBase.py
(rev 0)
+++ trunk/daboserver/appSource/orders/ui/FrmReportBase.py 2008-10-05
22:51:41 UTC (rev 4553)
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+
+import dabo.ui
+import dabo.lib.reportUtils as reportUtils
+
+
+class FrmReportBase(dabo.ui.dDialog):
+
+ def initProperties(self):
+ self.super()
+ ## Do this import here: in case prerequisites aren't installed,
the app
+ ## will still start.
+ from dabo.dReportWriter import dReportWriter
+
+ if self.ReportName:
+ self.Caption = self.ReportName
+ else:
+ self.Caption = "Run Report"
+ self.Modal = True
+ self.ReportForm = None
+ self.DataSet = []
+ self.ReportWriter = dReportWriter(Encoding=dabo.defaultEncoding)
+ self.SizerBorder = 7
+
+
+ def addControls(self):
+ preview = self.addObject(dabo.ui.dButton, Caption="Run Report",
+ RegID="cmdRunReport")
+ hs = dabo.ui.dSizer("h")
+ hs.append(preview, alignment="right", border=self.SizerBorder)
+ self.Sizer.append(hs, alignment="bottom",
border=self.SizerBorder)
+
+
+ def onHit_cmdRunReport(self, evt):
+ self.runReport()
+
+
+ def requery(self):
+ """Subclasses should override to fill self.DataSet"""
+ pass
+
+
+ def runReport(self, requery=True):
+ """Preview the report in the default pdf viewer."""
+ if requery:
+ self.requery()
+ f = self.write()
+ reportUtils.previewPDF(f)
+
+
+ def write(self):
+ """Write the report to a temporary file, and return the file
name."""
+ rw = self.ReportWriter
+ rw.ReportFormFile = self.ReportForm
+ rw.Cursor = self.DataSet
+ f = rw.OutputFile = reportUtils.getTempFile()
+ rw.write()
+ return f
+
Added: trunk/daboserver/appSource/orders/ui/FrmReportSample.py
===================================================================
--- trunk/daboserver/appSource/orders/ui/FrmReportSample.py
(rev 0)
+++ trunk/daboserver/appSource/orders/ui/FrmReportSample.py 2008-10-05
22:51:41 UTC (rev 4553)
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+
+## This is a sample form for putting together a report form xml (rfxml file)
+## and a dataset, and previewing the report. Study this code, as well as the
+## code in FrmReportBase, and then rework it to your specific needs. To put
+## your report in the reports menu, see MenReports.py.
+
+import datetime
+import os
+import dabo.ui
+from FrmReportBase import FrmReportBase
+
+
+class FrmReportSample(FrmReportBase):
+
+ def initProperties(self):
+ app = self.Application
+ self.ReportName = "Sample Report"
+ self.super()
+ self.ReportForm = os.path.join(app.HomeDirectory,
"reports/sampleReport.rfxml")
+ self.DataSetFunction = app.db.getSampleDataSet
+
+
+ def addControls(self):
+ """Add any controls here, such as record selection choices."""
+ self.super()
+
+
+ def requery(self):
+ """Called by preview in FrmReportBase, it's time to requery the
dataset."""
+ # Send whatever parameters your function requires, perhaps as
entered by the
+ # user in the controls you've exposed in this form.
+ self.DataSet = self.DataSetFunction()
+
Added: trunk/daboserver/appSource/orders/ui/GrdBase.py
===================================================================
--- trunk/daboserver/appSource/orders/ui/GrdBase.py
(rev 0)
+++ trunk/daboserver/appSource/orders/ui/GrdBase.py 2008-10-05 22:51:41 UTC
(rev 4553)
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+
+import dabo.lib.datanav2 as datanav
+
+
+class GrdBase(datanav.Grid):
+ pass
Added: trunk/daboserver/appSource/orders/ui/GrdOrders.py
===================================================================
--- trunk/daboserver/appSource/orders/ui/GrdOrders.py
(rev 0)
+++ trunk/daboserver/appSource/orders/ui/GrdOrders.py 2008-10-05 22:51:41 UTC
(rev 4553)
@@ -0,0 +1,90 @@
+# -*- coding: utf-8 -*-
+
+import dabo
+if __name__ == "__main__":
+ dabo.ui.loadUI("wx")
+from GrdBase import GrdBase
+
+
+class GrdOrders(GrdBase):
+
+ def afterInit(self):
+ self.super()
+
+ # Delete or comment out any columns you don't want...
+ self.addColumn(dabo.ui.dColumn(self, DataField="pkid",
Caption="Pkid",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="cust_fk",
Caption="Cust_Fk",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="employee_fk",
Caption="Employee_Fk",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="order_id",
Caption="Order_Id",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="cust_id",
Caption="Cust_Id",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="emp_id",
Caption="Emp_Id",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="to_name",
Caption="To_Name",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="to_address",
Caption="To_Address",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="to_city",
Caption="To_City",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="to_region",
Caption="To_Region",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="postalcode",
Caption="Postalcode",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="to_country",
Caption="To_Country",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="ship_count",
Caption="Ship_Count",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="ship_via",
Caption="Ship_Via",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="order_date",
Caption="Order_Date",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="order_amt",
Caption="Order_Amt",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="order_dsc",
Caption="Order_Dsc",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="order_net",
Caption="Order_Net",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="require_by",
Caption="Require_By",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="shipped_on",
Caption="Shipped_On",
+ Sortable=True, Searchable=True, Editable=False))
+
+ self.addColumn(dabo.ui.dColumn(self, DataField="freight",
Caption="Freight",
+ Sortable=True, Searchable=True, Editable=False))
+
+
+
+if __name__ == "__main__":
+ from FrmOrders import FrmOrders
+ app = dabo.dApp(MainFormClass=None)
+ app.setup()
+ class TestForm(FrmOrders):
+ def afterInit(self): pass
+ frm = TestForm(Caption="Test Of GrdOrders", Testing=True)
+ test = frm.addObject(GrdOrders)
+ frm.Sizer.append1x(test)
+ frm.show()
+ app.start()
Added: trunk/daboserver/appSource/orders/ui/MenFileOpen.py
===================================================================
--- trunk/daboserver/appSource/orders/ui/MenFileOpen.py
(rev 0)
+++ trunk/daboserver/appSource/orders/ui/MenFileOpen.py 2008-10-05 22:51:41 UTC
(rev 4553)
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+
+import dabo
+import dabo.dEvents as dEvents
+
+
+class MenFileOpen(dabo.ui.dMenu):
+
+ def initProperties(self):
+ self.super()
+ self.Caption = "&Open"
+ self.HelpText = "Open a module"
+
+
+ def afterInit(self):
+ app = self.Application
+ autoHotKeys = True
+
+ # Define the forms you want in your open menu here. Insert a
("-", None)
+ # tuple and the code below will insert a separator in its
place. Explicitly
+ # set up which character has the hotkey by adding a & in front
of it and
+
(64227 bytes were truncated as it was too long for the email (max 40000 bytes.)
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]