This set works for me: ---------------------------------------------------------------------- WHEN OBJECT ADDED CALL sqlInsertProduct(client_name=self.id, email=self.email, rate=self.rate, last_payment=self.last_payment, primary=self.primary, services=self.services) WHEN OBJECT CHANGED STORE email, rate, last_payment, primary, services USING sqlUpdateProduct(client_name=self.id, email=self.email, rate=self.rate, last_payment=self.last_payment, primary=self.primary, services=self.services) WHEN OBJECT DELETED CALL sqlDeleteProduct(client_name=self.id) WITH QUERY lookup_product(client_name=self.id) COMPUTE client_name,email,rate,last_payment,primary,services ---------------------------------------------------------------------- Where each of the queries does the 'right' thing. You generally don't want to attribute that you are using for the 'id' to be present in any propertysheet since that property will come from the ZClass and fool the 'Virtual' instance machinery. Note that if you don't specify "STORE" on the WHEN OBJECT CHANGED line then you'll have trouble with the Rack not being able to find attribute storage for the changed property. Good Luck! -steve
"AP" == Aaron Payne <aaron@aaronpayne.com> writes:
AP> Hi all, AP> I'm trying to use Gadfly as storage for a Zpatterns rack. AP> With the following skinscript trigger I can view records in AP> the database. But I can't insert a new one. AP> WHEN OBJECT ADDED CALL sqlInsertProduct() AP> WITH QUERY lookup_product(client_name=self.id) COMPUTE AP> client_name,email,rate,last_payment,primary,services AP> Where: AP> sqlInsertProduct is a zsql method. args: client_name email AP> rate last_payment primary services Query template: INSERT INTO AP> clienttracker_table (client_name, email, rate, last_payment, AP> primary, services) VALUES ( '<dtml-var client_name>', AP> '<dtml-var email>', '<dtml-var rate>', '<dtml-var AP> last_payment>', '<dtml-var primary>', '<dtml-var services>' ) AP> lookup_product is a zsql method. args: client_name Query AP> template: select * from clienttracker_table where AP> <dtml-sqltest client_name type=string> AP> client_name,email,rate,last_payment,primary,services are AP> fields of the table clienttracker_table and properties of the AP> dataskin. AP> If I remove "=self.id" from the trigger I am able to add a AP> record to the db through the trigger. Without "=self.id" in AP> the trigger I am unable to view the records in the db. AP> I noticed in a post today that said AP> ... you should probably choose some attribute other than 'id' AP> as the attribute to check for your DataSkin. The 'id' AP> attribute is always there... AP> Objects are loaded by accessing attribute client_name and I AP> still get the "object already exists" error. AP> Questions: -Should I just create the record directly with the AP> zsql method? That would defeat the purpose of using AP> ZPatterns. -How do I eliminate the "already exists" error AP> Zope version: Zope 2.2.1 Python version: 1.5.2 System AP> Platform: freebsd4 AP> -Aaron AP> _______________________________________________ Zope maillist AP> - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** AP> No cross posts or HTML encoding! ** (Related lists - AP> http://lists.zope.org/mailman/listinfo/zope-announce AP> http://lists.zope.org/mailman/listinfo/zope-dev )