[Zope-dev] Python method wrapping around DTML method
Title: Message Hi, This has been buggering me for ages, and I've spent too many hours trying to figure it out already, so I'm resorting to the list for help. :) I have two functions, PlainFunc and DTMLFunc, where PlainFunc is Python method in a file system product, and DTMLFunc is a DTML Methodin the ZODB. What I want to do is this: ZPublisher calls PlainFunc (publishes it) PlainFunc calls DTMLFunc in such a way that DTMLFunc gets everything it needs, e.g., namespace, but PlainFunc can do funky things to this namespace before-hand (like insert a few variables into it). In other words, I want a Python method to wrap around a DTML method. I've encountered many problems caused by the awkward calling conventions for DTML methods and the automagic switching between different calling conventions by the ZPublisher (isDocTemp; can I set that for a normal Python method?). Right now, I'm struggeling because I cannot get the namespace to be passed to PlainFunc, therefore PlainFunc cannot pass the namespace on to DTMLFunc. Any clues? Bye,-- Bjorn Stabell [EMAIL PROTECTED]Tel +86 (10) 65918490
Re: [Zope-dev] Python method wrapping around DTML method
On Friday 03 January 2003 10:13 am, Bjorn Stabell wrote: Right now, I'm struggeling because I cannot get the namespace to be passed to PlainFunc, therefore PlainFunc cannot pass the namespace on to DTMLFunc. Any clues? There isnt one true namespace. You can create your own as easy as { }, and it will be as good as any other. If you want an authentic ZPublisher namespace then you need http://www.zope.org/Members/htrd/howto/FunctionTemplate -- Toby Dickenson http://www.geminidataloggers.com/people/tdickenson ___ 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 )
Re: [Zope-dev] Strange Problem with a Product using SWIG Python Proxy Classes
Sean Gillies wrote at 2003-1-2 12:52 -0700: My question concerns the use of SWIG Python proxy classes in a Zope Product. In the ZDG and elsewhere, I have seen the statement that if an object is pickleable, it can be used as a persistent object in a Zope Product. In my experience, my SWIG Python proxy classes are pickleable, can be stored in a ZODB, the Product that uses them can be installed in Zope, instances of the Product classes can be added and work, but on a restart of Zope, the instances of my Product classes are broken and will cause Zope to segfault on any attempt to access the proxy class. I am using Python 2.1.3 with threads and the thread stack size patch built on OS X 10.2 and Zope 2.6.0. I've had no other problems with Python or Zope on this machine until I began developing this new Product. Sounds like an unpickling problem. For security reasons, unpickling is quite restricted. Objects must have special declarations to be unpicklable. Try to unpickle your objects and see whether this produces any errors. Dieter ___ 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 )
Re: [Zope-dev] Strange Problem with a Product using SWIG Python Proxy Classes
On Friday, January 3, 2003, at 12:33 PM, Dieter Maurer wrote: Sean Gillies wrote at 2003-1-2 12:52 -0700: My question concerns the use of SWIG Python proxy classes in a Zope Product. In the ZDG and elsewhere, I have seen the statement that if an object is pickleable, it can be used as a persistent object in a Zope Product. In my experience, my SWIG Python proxy classes are pickleable, can be stored in a ZODB, the Product that uses them can be installed in Zope, instances of the Product classes can be added and work, but on a restart of Zope, the instances of my Product classes are broken and will cause Zope to segfault on any attempt to access the proxy class. I am using Python 2.1.3 with threads and the thread stack size patch built on OS X 10.2 and Zope 2.6.0. I've had no other problems with Python or Zope on this machine until I began developing this new Product. Sounds like an unpickling problem. For security reasons, unpickling is quite restricted. Objects must have special declarations to be unpicklable. Try to unpickle your objects and see whether this produces any errors. Dieter Dieter, Thanks for taking time to reply. I am able to unpickle the object without any problems. I am also able to save the object to a FileStorage using ZODB and can load it again from the database without problems. There must be more to it in Zope? I found a Product that also uses SWIG (m2crypto) and am going to look through it to see if I'm missing anything. cheers, Sean ___ 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 )
Re: [Zope-dev] Python method wrapping around DTML method
Bjorn Stabell wrote: in such a way that DTMLFunc gets everything it needs, e.g., namespace, but PlainFunc can do funky things to this namespace before-hand (like insert a few variables into it). In other words, I want a Python method to wrap around a DTML method. It is pretty simple: class myProduct: # The dtml object DtmlFunc = HTMLFile('DtmlFunc', globals()) # to call it def PlainFunc(self): Remember docstring extraParameter = 'Some string' return self.DtmlFunc(self, self.REQUEST, extraParameter=extraParameter) regvards Max M ___ 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 )