Categories

Alex King <[email protected]>
Newsgroups gmane.comp.gnu.enterprise.general
Message-ID <[email protected]>
I'm new to gnue, having a problem with designing a form in a 2 tier
application (ie, without appserver)

I want to have a form for entry of stock items, where the items are
categorised by "type" and "section".

There are 4 types, and each type has a different number of subtypes
which I have called setions.

During normal stock data entry, I want the user to select the type and
section of the item from drop-down lists.

The types and sections are stored in two configuration tables in a
master-detail relationship.  (ie, the types and sections are not hard
coded into the form, but are configurable by adding to database tables.)

When I declare the master detail relationships in the block definition
as I have in the attached gfd file and run the form, it emtis a
traceback when I click on the traceback drop-down.  This wasn't really a
great surprise, because I don't know if this is an intended usage.

My thoughts for resolving this:

1. Hack on gnue to make this work (I'm using the debian sarge gnue
packages).  Can anyone tell me (a) if this is a sane thing to want to
do, and (b) where to start looking if it is.

2. Have type dropdown triggers impose a condition on the section
dropdown datasource somehow.   Ie, when a type is selected, perhaps a
post change trigger on the type field could somehow impose a "where
type='newtype'" condition on the sql used to select the items for the
section dropdown.  Can anyone tell me if I can programatically impose a
condition and re-run the query, and how to do this?

3. Have a datasource not directly tied to a db table, but implemented as
a python object (list) somehow, and have the type trigger fill the list
with a db query each time the type object changes.  This option is
probably the least elegant, but it has a certain amount of appeal
because I am familiar with python.  Does anyone know if it is possible
to have an arbtary python object as a datasource, and if so, how?

4. Would appserver help me?  The docs are scarce, and I've not taken
time yet to investigate, so I have no idea myself.

BTW, I love the whole gnue thing, great work folks.  I'm happy to help
out in any way I can.

Alex

_______________________________________________
Gnue mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnue
StockMaintenanceTest.gfd (text/plain, 2.2 KB)
<?xml version="1.0" encoding="iso8859-1"?>

<!--  GNUe-Designer (0.5.4)
      Saved on: 2004-09-12 09:26:52  -->

<form title="Stock Maintenance">
  <options/>
  <datasource name="dtsSTOCK0" connection="ao" table="stock"/>
  <datasource name="dtsDrp_stocktype_fldType" connection="ao" prequery="Y"
              table="stocktype"/>
  <datasource name="dtsSection" connection="ao" prequery="Y"
              table="stocksection" detaillink="type"
	      master="dtsDrp_stocktype_fldType" masterlink="type"/>
  <logic>
    <block name="blkSTOCK" datasource="dtsstock0">
      <field name="fldType" field="type" fk_description="type" fk_key="type"
             fk_source="dtsDrp_stocktype_fldType"/>
      <field name="fldSection" field="section" fk_description="section"
             fk_key="section" fk_source="dtsSection"/>
      <field name="fldCodename" field="codename" maxLength="16"/>
      <field name="fldDescription" field="description" maxLength="25"/>
    </block>
  </logic>
  <layout xmlns:Char="GNUe:Layout:Char" Char:height="15" Char:width="44">
    <page name="Page1">
      <label name="lblSupplier" Char:height="1" Char:width="5" Char:x="1"
             Char:y="1" text="Type:"/>
      <entry name="entType" Char:height="1" Char:width="12" Char:x="14"
             Char:y="1" block="blkSTOCK" field="fldType" label="" style="dropdown"/>
      <label name="lblSupplier" Char:height="1" Char:width="8" Char:x="1"
             Char:y="2" text="Section:"/>
      <entry name="entSection" Char:height="1" Char:width="12" Char:x="14"
             Char:y="2" block="blkSTOCK" field="fldSection" label="" style="dropdown"/>
      <label name="lblSupplier" Char:height="1" Char:width="9" Char:x="1"
             Char:y="3" text="Codename:"/>
      <entry name="entCodename" Char:height="1" Char:width="16" Char:x="14"
             Char:y="3" block="blkSTOCK" field="fldCodename" label=""/>
      <label name="lblSupplier" Char:height="1" Char:width="12" Char:x="1"
             Char:y="5" text="Description:"/>
      <entry name="entDescription" Char:height="1" Char:width="16" Char:x="14"
             Char:y="5" block="blkSTOCK" field="fldDescription" label=""/>
    </page>
  </layout>
</form>
StockMaintenanceTest.traceback (text/plain, 1.4 KB)
DB000: Traceback (most recent call last):
DB000:   File "/usr/lib/gnue/python/gnue/forms/uidrivers/wx/common.py", line 172, in _processEvent
DB000:     self._eventProcessor('requestFOCUS',gfObject,_form=gfObject._form)
DB000:   File "/usr/lib/gnue/python/gnue/common/events/EventController.py", line 107, in dispatchEvent
DB000:     handler(event)
DB000:   File "/usr/lib/gnue/python/gnue/forms/GFInstance.py", line 926, in changeFocus
DB000:     self.dispatchEvent('gotoENTRY',object=event._form._currentEntry, _form=event._form)
DB000:   File "/usr/lib/gnue/python/gnue/common/events/EventController.py", line 107, in dispatchEvent
DB000:     handler(event)
DB000:   File "/usr/lib/gnue/python/gnue/forms/uidrivers/_base/UIdriver.py", line 282, in switchFocus
DB000:     self.dispatchEvent('beginEDITMODE', object, _form=object._form)
DB000:   File "/usr/lib/gnue/python/gnue/common/events/EventController.py", line 107, in dispatchEvent
DB000:     handler(event)
DB000:   File "/usr/lib/gnue/python/gnue/forms/GFInstance.py", line 469, in proxyEntryEvent
DB000:     handler.subevents.dispatchEvent(event)
DB000:   File "/usr/lib/gnue/python/gnue/common/events/EventController.py", line 107, in dispatchEvent
DB000:     handler(event)
DB000:   File "/usr/lib/gnue/python/gnue/forms/GFDisplayHandler.py", line 787, in beginEdit
DB000:     self.work = self.field._allowedValues ["%s" % self.value]
DB000: TypeError: unsubscriptable object
database.sql (text/plain, 2.3 KB)
-- MySQL dump 9.10
--
-- Host: localhost    Database: ao
-- ------------------------------------------------------
-- Server version	4.0.18-log

--
-- Table structure for table `stocksection`
--

CREATE TABLE stocksection (
  type varchar(9) NOT NULL default '',
  section varchar(12) NOT NULL default ''
) TYPE=MyISAM;

--
-- Dumping data for table `stocksection`
--

INSERT INTO stocksection VALUES ('labour','Bench work');
INSERT INTO stocksection VALUES ('labour','Cutting');
INSERT INTO stocksection VALUES ('labour','Finishing');
INSERT INTO stocksection VALUES ('labour','Sewing time');
INSERT INTO stocksection VALUES ('fabric','jo');
INSERT INTO stocksection VALUES ('fabric','knit');
INSERT INTO stocksection VALUES ('fabric','samples');
INSERT INTO stocksection VALUES ('fabric','special');
INSERT INTO stocksection VALUES ('fabric','woven');
INSERT INTO stocksection VALUES ('component','10 vis zip');
INSERT INTO stocksection VALUES ('component','3 coil zip');
INSERT INTO stocksection VALUES ('component','5 coil zip');
INSERT INTO stocksection VALUES ('component','5 vis zip');
INSERT INTO stocksection VALUES ('component','dome');
INSERT INTO stocksection VALUES ('component','misc item');
INSERT INTO stocksection VALUES ('component','plastic bitt');
INSERT INTO stocksection VALUES ('component','sleeping bag');
INSERT INTO stocksection VALUES ('component','slider');
INSERT INTO stocksection VALUES ('component','toggle');
INSERT INTO stocksection VALUES ('length','chain');
INSERT INTO stocksection VALUES ('length','elastic');
INSERT INTO stocksection VALUES ('length','flag stuff');
INSERT INTO stocksection VALUES ('length','webbing');

--
-- Table structure for table `stocktype`
--

CREATE TABLE stocktype (
  type varchar(9) NOT NULL default ''
) TYPE=MyISAM;

--
-- Dumping data for table `stocktype`
--

INSERT INTO stocktype VALUES ('labour');
INSERT INTO stocktype VALUES ('fabric');
INSERT INTO stocktype VALUES ('component');
INSERT INTO stocktype VALUES ('length');

--
-- Table structure for table `stock`
--

CREATE TABLE stock (
  id int(8) NOT NULL default '0',
  type varchar(9) NOT NULL default '',
  section varchar(12) NOT NULL default '',
  codename varchar(16) NOT NULL default '',
  size varchar(8) default NULL,
  description varchar(30) default NULL,
  supplier varchar(16) default NULL,
  PRIMARY KEY  (id)
) TYPE=MyISAM;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.