<?xml version="1.0" ?>

<kc>

<title>GNUe Traffic</title>

<editor contact="mailto:psu@burdonvale.co.uk">Peter Sullivan</editor>

<issue num="124" date="18 Sep 2006 12:00:00 -0800" />

<headquote>User error reports - 
'<i>half of mine are &quot;The internet isn't working&quot;</i>' - 
'<i>could you imagine the fun you could have with a squid proxy on that one - 
&quot;Just a minute.  I'll reboot it&quot; - 
then a redirect to a &quot;Internet Reboot in Progress.....Please wait.&quot;</i>'</headquote>

<intro>
  This newsletter mainly covers the the #gnuenterprise IRC channel, 
  with occasional coverage of the three main mailing lists 
  (gnue-announce, gnue and gnue-dev) for the 
  <a href="http://www.gnuenterprise.org">GNU Enterprise</a> 
  project.
</intro>


<section 
   title="Understanding focus trigger types and levels"
   subject="[IRC] 13 Sep 2006"
   archive="http://www.gnuenterprise.org/irc-logs/gnue-public.log.2006-09-13"
   author="Peter Sullivan" 
   contact="mailto:psu@burdonvale.co.uk" 
   startdate="13 Sep 2006 12:00:00 -0800"
   enddate="13 Sep 2006 12:00:00 -0800">

<topic>Forms</topic>

<p>Reinhard M&#252;ller (reinhard) asked about focus triggers in GNUe Forms - 
<quote who="Reinhard M&#252;ller">it seems like navigating from one record to another 
(like scrolling to the next record) fires the FOCUS-OUT triggers for the block 
with the old record loaded - and the FOCUS-IN triggers for the block with the new 
record loaded.</quote> He understood the reasoning for having both focus-in 
and focus-out - <quote who="Reinhard M&#252;ller">you can do consistency 
checks in the focus-out trigger and the user can never navigate out of an 
"incomplete" block</quote>. James Thompson (jamest) confirmed this, and noted 
that each type of focus trigger could be set at form, block or field level 
depending on the type of validation required. Reinhard 
understood this, but was more interested in <quote who="Reinhard M&#252;ller">the 
case when you don't move the cursor at all - but you just navigate to the next 
record - i.e. you *stay* in the same field, entry, and block - but the current 
record of the block changes</quote>. James thought that this should still fire 
the focus triggers. Reinhard agreed, <quote who="Reinhard M&#252;ller">however I found 
it does *only* fire the block level triggers</quote> not the entry-level or 
page-level triggers.</p>

<p>James had not been aware that entry-level triggers and page-level triggers 
had been added - he was struggling to <quote who="James Thompson">think of 
example off top of head where I'd need them vs a block or field level 
trigger</quote>. Reinhard wondered <quote who="Reinhard M&#252;ller">maybe they 
were done &quot;just to play safe&quot; when the</quote> distinction between a 
field and an entry was introduced. James agreed - it allowed developers, 
for instance, to have an entry-level trigger that would work on all instances 
of the same entry, even if they were in multiple fields on different pages of 
a multi-page form.</p>

<p>Reinhard said that he would change the code to check focus-in and 
focus-out type triggers at all appropriate levels whenever the focus changed. 
He queried the order that the various types of trigger should be checked - he felt 
that it should be <quote who="Reinhard M&#252;ller">pre-focusout - pre-focusin - change 
focus - post-focusout - post-focusin</quote>. James agreed.</p>

<p>Later, Reinhard noted that the order of triggers he had proposed 
<quote who="Reinhard M&#252;ller">turns out to be a lot trickier as it seems 
at first sight</quote>. The logic did not necessarily work, for 
instance, when inserting a new record. He could also foresee triggers 
conflicting with each other - for example <quote who="Reinhard M&#252;ller">if 
post-focusout says it's ok to lose focus but pre-focusin says &quot;i 
don't want it&quot;</quote>. He wondered if it would be simpler to 
have fewer types of triggers - just a single 
<quote who="Reinhard M&#252;ller">on-focusout</quote> before creating or 
moving record, and <quote who="Reinhard M&#252;ller">on-focusin 
(which can not block)</quote> afterwards. Jason Cater (jcater) explained 
that the original rationale had been that <quote who="Jason Cater">pre-focusout 
could block</quote> - in fact, <quote who="Jason Cater">that would be its main 
purpose</quote> - but that <quote who="Jason Cater">then the others were called 
knowing that the focus was changing</quote>. In theory, any of the pre-focusout 
triggers at event, block or page level could refuse to allow the focus-out to 
happen (e.g. for data validation) - only if all the pre-focusout triggers at 
each level succeded were the post-focusout triggers at each level then checked. 
Reinhard noted that this meant <quote who="Reinhard M&#252;ller">running the 
post-focusout *before* the focus *really* leaves the entry/block 
doesn't hurt at all</quote>. Jason agreed - <quote who="Jason Cater">as we know 
that it will in fact leave the focus</quote> - only the pre-focusout 
triggers could actually block changing the focus.</p>

<p>Reinhard noted that this actually meant keeping to the current order of trigger 
types - <quote who="Reinhard M&#252;ller">1. pre-focusout - 2. post-focusout - 3. 
actually move around - 4. pre-focusin - 5. post-focusin - where only 1. can 
block</quote>. But at least he now understood the rationale behind this.</p>

</section>


<section 
   title="Changing attributes of a form from within a trigger"
   subject="[IRC] 13 Sep 2006"
   archive="http://www.gnuenterprise.org/irc-logs/gnue-public.log.2006-09-13"
   author="Peter Sullivan" 
   contact="mailto:psu@burdonvale.co.uk" 
   startdate="13 Sep 2006 12:00:00 -0800"
   enddate="13 Sep 2006 12:00:00 -0800">

<topic>Forms</topic>
<topic>Application Server</topic>

<p>Reinhard M&#252;ller (reinhard) noted that <quote who="Reinhard M&#252;ller">a lot of 
attributes of GFBlock and GFField are changeable in trigger namespace</quote>
and <quote who="Reinhard M&#252;ller">wondered what was the 
reasoning behind this</quote>. Jason Cater (jcater) explained 
<quote who="Jason Cater">at one time, our specifications for forms was that 
triggers could practically build a form at runtime and anything/everything was 
changable/scriptable - that was probably a pipe dream (and probably not necessary)
- but it's possible the code you saw was the start of that general trend</quote>.
Reinhard noted that <quote who="Reinhard M&#252;ller">the dream of building a form at 
runtime</quote>, whilst theoretically possible in a two-tier environment (GNUe Forms 
client talks directly to a database), wasn't really practicable in a three-tier 
environment (GNUe Forms client talks to GNUe Application Server talks to 
database), as there would be no mechanism for triggers in the GNUe Forms client 
to dynamically <quote who="Reinhard M&#252;ller">create new objects</quote> on the 
GNUe Application Server. He noted that, as of time of writing, 
<quote who="Reinhard M&#252;ller">*all* possible attributes of the 
&lt;block&gt; tag were exported to trigger namespace - autoCommit, queryable, 
editable, deletable, autoCreate, autoCommit, autoNextRecord, transparent - 
similar for GFField - maxLength, minLenght, queryDefault, case, required...
I think practically none of them are very useful, and with some of them you 
might even be able to screw something up if you change at runtime</quote>.</p>

</section>


<section 
   title="Using either primary keys or object ids to uniquely identify records"
   subject="[IRC] 14 Sep 2006"
   archive="http://www.gnuenterprise.org/irc-logs/gnue-public.log.2006-09-14"
   author="Peter Sullivan" 
   contact="mailto:psu@burdonvale.co.uk" 
   startdate="14 Sep 2006 12:00:00 -0800"
   enddate="14 Sep 2006 12:00:00 -0800">

<topic>Forms</topic>
<topic>Common</topic>

<p>Alex Bodnaru (alexbodn) asked for <quote who="Alex Bodnaru">help to activate the 
inventory demo: the data is ok in the gnue database</quote> but 
<quote who="Alex Bodnaru">there is a query that complains there is no 
oid.</quote> Reinhard M&#252;ller (reinhard) was <quote who="Reinhard M&#252;ller">not 
sure the inventory demo is functional any more at all - I haven't tried it 
in literally years</quote>. James Thompson (jamest) explained that 
<quote who="James Thompson">if a table doesn't define a primary key then 
our system falls back to using oid</quote> to uniquely identify rows 
(for example, in updates). However, the postgresql database software 
(which was the most common database software people tended to use with 
GNUe) had recently <quote who="James Thompson">dropped the oid column by 
default in new tables</quote>. In any case, the preferred way of dealing 
with this was to tell the datasource (GNUe's connection to the database) 
what column - or group of columns - represented the primary key in the 
underlying table. GNUe would then use this to identify unique rows, rather 
than the object id. This would work regardless of whether the database 
software GNUe was being used with had object ids or not. Really, object 
ids were only needed <quote who="James Thompson">when a table is defined 
without a PK - which is really a bad practice that i'm very guilty 
of</quote>. Reinhard confirmed that the GNUe datasource would use the
primary keys on the table, but only if the datasource definition told 
it what the primary keys were. Alex confirmed this - 
<quote who="Alex Bodnaru">it stopped complaining only after i have added 
the primarykey option</quote>.</p>

<p>Later, James noted <quote who="James Thompson">we have a bigger 
issue than i thought - as I just created the zipcode table with a 
PK - and the datasource still attempts to use the oid column in the 
query</quote>. Reinhard said that the reason for this was 
<quote who="Reinhard M&#252;ller">because the primary key field can change 
on inserts if there is a trigger on db side - so the only really 
reliable record identifier is the oid</quote>. James replied that 
<quote who="James Thompson">the oid isn't in newest postgresql</quote>. 
Alex said that it could still be switched on - 
<quote who="Alex Bodnaru">you may create the table with oids option</quote>. 
Reinhard asked <quote who="Reinhard M&#252;ller">are oid's depreciated to use 
or are they just turned off by default but still a valid option?</quote> 
James grabbed <quote who="James Thompson">the latest tarball and read the 
release notes</quote>, reporting that <quote who="James Thompson">reading 
the release notes it looks like OIDs are going to be around for a while - 
just not created by default</quote>.</p>

</section>


<section 
   title="Passing database error messages back to the user"
   subject="[IRC] 18 Sep 2006"
   archive="http://www.gnuenterprise.org/irc-logs/gnue-public.log.2006-09-18"
   author="Peter Sullivan" 
   contact="mailto:psu@burdonvale.co.uk" 
   startdate="18 Sep 2006 12:00:00 -0800"
   enddate="18 Sep 2006 12:00:00 -0800">

<topic>Forms</topic>
<topic>Common</topic>

<p>Reinhard M&#252;ller (reinhard) asked <quote who="Reinhard M&#252;ller">what 
is the easiest way to enforce uniqueness of a database column? 
(other than creating an unique index which will result in db exceptions 
to be thrown at the user)</quote> He <quote who="Reinhard M&#252;ller">did 
a PRE-FOCUSOUT trigger in which a query a second datasource pointing 
to the same table to find out whether the value already exists - 
but that doesn't seem too elegant</quote> and did not catch duplicates 
<quote who="Reinhard M&#252;ller">if you make both entries at the same 
commit</quote>. James Thompson (jamest) said <quote who="James Thompson">my 
users get the dupe entry sql error</quote>. Reinhard replied 
<quote who="Reinhard M&#252;ller">ok, so you simply pass the SQL backend 
error to the user - same for enforcing referential integrity? (e.g. 
making sure no master is deleted as long as details exist)</quote>. 
James said he had actually gone even further in using back-end 
(database) validation - <quote who="James Thompson">something i've 
done in postgresql is setup on update triggers  on my invoice table
that block updates after the invoice has been faxed to customer. 
i'm thinking that the error message generated by that trigger is 
displayed nicely by forms - well, wx24, i've not looked at 2.6 
yet</quote>. Reinhard said that wx 2.6 was slightly different - 
<quote who="Reinhard M&#252;ller">you get the exception text - 
with clicking &quot;details&quot; you get the SQL statement that 
caused the error (in case of an SQL error)</quote>.</p>

<p>However, Reinhard was not that keen on passing 
<quote who="Reinhard M&#252;ller">backend error messages to the user - as 
they look too techy - and they are (what is a problem for me) in 
English generally</quote>. James wondered <quote who="James Thompson">if 
we need a per form mapping of some sort - so you can define &quot;If you 
get this error.  Display this instead&quot;</quote> Reinhard had 
thought about this, <quote who="Reinhard M&#252;ller">but that would mean 
to parse backend error messages - depending on what backend you use 
and probably even on the backend version - maybe also on the current 
locale the backend runs on</quote>. This 
<quote who="Reinhard M&#252;ller">would take away the possibility to 
migrate to a different backend easily</quote>.</p>

</section>

</kc>