At 04:39 PM 11/30/00 +0100, Ulrich Eck wrote:
>>>>
I've a db_sequence specialist who serves the Framework with
db_id's for new Records like:
<<<<

May I suggest calling your Specialist "Sequences" or "Counters" since it appears that it returns objects which produce sequential integer values?


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

The Attribute nextid is provided by a Skinscript-Method:
________________________________________________
WITH getNextId(seq_name=self.id)
COMPUTE seq_name=seq_name,nextid=_.int(nextid)
________________________________________________
<<<<

I would not suggest using nextid as an attribute. This should really be a method, e.g. getNextId(). The method should then return the result of calling Counters.getNextId(seq_name=self.id).

However, if you insist on using the above approach, your SkinScript should read:

WITH
getNextId(seq_name=self.id)
COMPUTE
nextid=RESULT['nextid'], seq_name=RESULT['seq_name']

Notice that since your Python method returns a dictionary, RESULT is a dictionary, not an object, so you have to retrieve the elements you want in your expressions that way. Of course, you could just have getNextId() return an integer result, and use:

WITH getNextId(seq_name=self.id) COMPUTE nextid=RESULT
WITH SELF COMPUTE seq_name=id

to achieve the same effects.

>>>>


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=self.id) COMPUTE sid=_.int(id),name,time_start
WHEN OBJECT ADDED CALL insertEvent(id=self.sid)
WHEN OBJECT ADDED,CHANGED STORE sid,name,time_start
USING updateEvent(id=self.sid,name=self.name,time_start=self.time_start)



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

I call

<dtml-let ni="newItem(key=db.getItem('data_event').nextid)" nips="ni.propertysheets.get('Basic')">
<dtml-var "nips.manage_changeProperties(REQUEST=REQUEST)">
</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.
<<<<

Here's what you're missing. There is no "sid" attribute when you add an object. You need to add this to your SkinScript (assuming I'm guessing correctly what sid is supposed to be):

INITIALIZE OBJECT WITH sid=_.int(self.id)

Otherwise, your two ADDED triggers will execute with no value for the sid attribute.


>>>>
- 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 ??
<<<<

Yes. DataSkin Property sheets would be the ones you need to use.


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

When you change the attributes of the object, the action is logged for the trigger to fire at transaction commit time. The Property Sheet is just a way to change the attributes.


_______________________________________________ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )

Reply via email to