[Zope-dev] ZPatterns: using PythonMethods from Skinscript

Ulrich Eck ueck@net-labs.de
Thu, 30 Nov 2000 16:39:26 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_0023_01C05AEC.1A124300
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

hi out there,

this is my first posting on this list. Right now I think=20
this is the right place to ask details about ZPatterns.

I think a ZPatterns-Mailinglist should be set up, where
people like me, working hard to get the "Zen of ZPatterns"
can discuss questions related to USING ZPatterns.

Here my first little problem:

I've a db_sequence specialist who serves the Framework with
db_id's for new Records like:

>>> newid =3D db_sequence.getItem('<sequence_name>').nextid

The Attribute nextid is provided by a Skinscript-Method:
________________________________________________
WITH getNextId(seq_name=3Dself.id)=20
COMPUTE seq_name=3Dseq_name,nextid=3D_.int(nextid)
________________________________________________


"getNextId()" is a PythonMethod and uses ZSQL-Methods to
compute the NextId while Locking the Table:=20
________________________________________________
PARAMETER:  self, seq_name
________________________________________________
self.sql_Lock()
nid =3D 1
for cur_id in self.sql_NextIdGet(seq_name=3Dseq_name):
 nid =3D cur_id.nextid + 1
 self.sql_NextIdUpdate(seq_name=3Dseq_name,nextid=3Dnid)
 break

else:
 self.sql_NextIdCreate(seq_name=3Dseq_name,nextid=3D1)

self.sql_Unlock()

return {'seq_name':seq_name, 'nextid':nid}     # HERE'S MY PROBLEM I =
THINK !!!!
________________________________________________

I tried to return nearly everything expect a certain instance of a=20
"special getNextId-Return-Object" e.g. return nid / return =
(seq_name,nid) ...

I tried serveral ways to reach my return values in the SSMethod:
... COMPUTE nextid=3Dnextid or nextid=3Dself.nextid or nextid=3DRESULT =
...

Finally i tried to follow what happens during a get-call of an Attribute =
in the source ..=20
no success ..

except  when i use some Dummy ZSQL-Method which does the following and =
works (but this is not the way to do it ..)
"select <value> as nextid, <value> as seq_name"


can someone give some advice or enlighten me about the Namespace I'm in, =
at SSMethods Attribute providers=20
at execution-time ?!?






My Second "little" Problem:

i'm not the first one who had problems to manage data with rdbms and =
zpatterns. i can get Attributes through SSMethods
easily and now tried to setup ADD/CHANGE/DELETED Rules to manage data.


Here my SSMethod for this(getEventById/insertEvent/updateEvent are =
ZSQL-Methods):

WITH QUERY getEventById(id=3Dself.id) COMPUTE =
sid=3D_.int(id),name,time_start
WHEN OBJECT ADDED CALL insertEvent(id=3Dself.sid)
WHEN OBJECT ADDED,CHANGED STORE sid,name,time_start=20
USING =
updateEvent(id=3Dself.sid,name=3Dself.name,time_start=3Dself.time_start)


I access the Item through loadAttribute: "sid"
I set up a ZClass derived from Dataskin which acts as Storage-Class.

I call =20

<dtml-let ni=3D"newItem(key=3Ddb.getItem('data_event').nextid)" =
nips=3D"ni.propertysheets.get('Basic')">
<dtml-var "nips.manage_changeProperties(REQUEST=3DREQUEST)">
</dtml-let>

and get back an empty object without any attributes =
(propertysheet-problem??)
the record in the database is created (but only because I reduced the =
ZSQL-Insert Method to id-parm only)
this again seems to be a Problem of the namespace I'm in while the =
_objectAdded() ... method.



- Do I need a PropertySheet when I only want to =
access/change/create/delete Items/Attributes from a RDBMS ??
  If yes: Which one (CommonInterfaceProp/DataSkinProp)
  If no: how do i Access/Change my Properties ??

- and another Question related to this:
  Which object fires the Trigger-Event (ADDED/CHANGED/DELETED)  ..
  is it the PropertySheet itself ???


lots of questions still there but these are the points i really tried to =
get working .. but i did'nt..

hope that there is an answer ..

thanks in advance

Ulrich Eck
net-labs









------=_NextPart_000_0023_01C05AEC.1A124300
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3103.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>hi out there,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>this is my first posting on this list. =
Right now I=20
think </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>this is the right place to ask details =
about=20
ZPatterns.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I think a ZPatterns-Mailinglist should =
be set up,=20
where</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>people like me, working hard to get the =
"Zen of=20
ZPatterns"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>can discuss questions related to USING=20
ZPatterns.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Here my first little =
problem:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I've a db_sequence specialist who =
serves the=20
Framework with</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>db_id's for new Records =
like:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; newid =3D=20
db_sequence.getItem('&lt;sequence_name&gt;').nextid</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>The Attribute nextid is provided by a=20
Skinscript-Method:</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>________________________________________________</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>WITH getNextId(seq_name=3Dself.id) =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>COMPUTE=20
seq_name=3Dseq_name,nextid=3D_.int(nextid)</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>________________________________________________</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>"getNextId()" is a PythonMethod and =
uses=20
ZSQL-Methods to</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>compute the NextId while Locking the =
Table:=20
</FONT></DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial=20
size=3D2>________________________________________________</FONT></DIV>
<DIV>PARAMETER:&nbsp; self, seq_name</DIV>
<DIV>
<DIV><FONT face=3DArial=20
size=3D2>________________________________________________</FONT></DIV>
<DIV>self.sql_Lock()<BR>nid =3D 1<BR>for cur_id in=20
self.sql_NextIdGet(seq_name=3Dseq_name):<BR>&nbsp;nid =3D cur_id.nextid =
+=20
1<BR>&nbsp;self.sql_NextIdUpdate(seq_name=3Dseq_name,nextid=3Dnid)<BR>&nb=
sp;break</DIV>
<DIV>&nbsp;</DIV>
<DIV>else:<BR>&nbsp;self.sql_NextIdCreate(seq_name=3Dseq_name,nextid=3D1)=
</DIV>
<DIV>&nbsp;</DIV>
<DIV>self.sql_Unlock()</DIV>
<DIV>&nbsp;</DIV>
<DIV>return {'seq_name':seq_name, 'nextid':nid}&nbsp;&nbsp;&nbsp;&nbsp; =
# HERE'S=20
MY PROBLEM I THINK !!!!</DIV>
<DIV>
<DIV><FONT face=3DArial=20
size=3D2>________________________________________________</FONT></DIV></D=
IV>
<DIV>&nbsp;</DIV>
<DIV>I tried to return nearly everything expect a certain instance of a =
</DIV>
<DIV>"special getNextId-Return-Object" e.g. return nid / return =
(seq_name,nid)=20
...</DIV>
<DIV>&nbsp;</DIV>
<DIV>I tried serveral ways to reach my return values in the =
SSMethod:</DIV>
<DIV>... COMPUTE nextid=3Dnextid or nextid=3Dself.nextid or =
nextid=3DRESULT ...</DIV>
<DIV>&nbsp;</DIV>
<DIV>Finally i tried to follow what happens during a get-call of an =
Attribute in=20
the source .. </DIV>
<DIV>no success ..</DIV>
<DIV>&nbsp;</DIV>
<DIV>except&nbsp; when i use some Dummy ZSQL-Method which does the =
following and=20
works (but this is not the way to do it ..)<BR>"select &lt;value&gt; as =
nextid,=20
&lt;value&gt; as seq_name"</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>can someone give some advice or enlighten me about the Namespace =
I'm in, at=20
SSMethods Attribute providers </DIV>
<DIV>at&nbsp;execution-time ?!?</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>My Second "little" Problem:</DIV>
<DIV>&nbsp;</DIV>
<DIV>i'm not the first one who had problems to manage data with rdbms =
and=20
zpatterns. i can get Attributes through SSMethods</DIV>
<DIV>easily and now tried to setup ADD/CHANGE/DELETED Rules to manage=20
data.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Here my SSMethod for=20
this(getEventById/insertEvent/updateEvent&nbsp;are&nbsp;ZSQL-Methods):</D=
IV>
<DIV>&nbsp;</DIV>
<DIV>WITH QUERY getEventById(id=3Dself.id) COMPUTE=20
sid=3D_.int(id),name,time_start</DIV>
<DIV>WHEN OBJECT ADDED CALL insertEvent(id=3Dself.sid)<BR>WHEN OBJECT=20
ADDED,CHANGED STORE sid,name,time_start </DIV>
<DIV>USING=20
updateEvent(id=3Dself.sid,name=3Dself.name,time_start=3Dself.time_start)<=
/DIV></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I access the Item through =
loadAttribute:=20
"sid"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I set up a ZClass derived from Dataskin =
which acts=20
as Storage-Class.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I call</FONT><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;dtml-let=20
ni=3D"newItem(key=3Ddb.getItem('data_event').nextid)"=20
nips=3D"ni.propertysheets.get('Basic')"&gt;<BR>&lt;dtml-var=20
"nips.manage_changeProperties(REQUEST=3DREQUEST)"&gt;<BR>&lt;/dtml-let&gt=
;<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>and get back an empty object without =
any attributes=20
(propertysheet-problem??)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>the record in the database is created =
(but only=20
because I reduced the ZSQL-Insert Method to id-parm only)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>this again seems to be a Problem of the =
namespace=20
I'm in while the _objectAdded() ... method.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>- Do I need a PropertySheet =
</FONT><FONT face=3DArial=20
size=3D2>when I only want to access/change/create/delete</FONT><FONT =
face=3DArial=20
size=3D2> Items/Attributes from a RDBMS ??</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; If yes: Which one=20
(CommonInterfaceProp/DataSkinProp)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; If no: how do i Access/Change my =
Properties=20
??</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>- and another Question related to=20
this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; Which object fires the =
Trigger-Event=20
(ADDED/CHANGED/DELETED)&nbsp; ..</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; is it the PropertySheet itself=20
???</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>lots of questions still there but these =
are=20
the&nbsp;points i really tried to get working .. but i =
did'nt..</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>hope that there is an answer =
..</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>thanks in advance</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Ulrich Eck</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>net-labs</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0023_01C05AEC.1A124300--