Re: [Zope-dev] Python Script to import content into Zope?!
--On Sonntag, 26. Oktober 2003 19:59 Uhr +0100 Simone Unold [EMAIL PROTECTED] wrote: Hi, my question is if there is some kind of Python Script available to update Content into Zope. What do you meanwith update content. Check out the APIs provided by the content types and apply their methods to an object. -aj ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Python Script to import content into Zope?!
Hi, my question is if there is some kind of Python Script available to update Content into Zope. Im programming C++ and thought, that there may be a possibility to call a Python Script in order to automatically import content to zope?! Can anybody help me, has anyone an idea? Thanks a lot! Bye Simone ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Python Script bug?
Hi, The following code: objects = map(lambda b: b.getObject,brains) Results in: Error type: Unauthorized Error value: __len__ File E:\Zope\current\Products\CMFCore\FSPythonScript.py, line 187, in _exec (Object: index_html_postings) (Info: ({'script': FSPythonScript instance at 01BB2C20, 'context': SwishdotSite instance at 01C09950, 'container': SwishdotSite instance at 01C09950, 'traverse_subpath': []}, (), {}, None)) File Script (Python), line 5, in index_html_postings File E:\Zope\2379B4~1.2\lib\python\Products\PythonScripts\Guarded.py, line 204, in __careful_map__ (Object: lambda) File E:\Zope\2379B4~1.2\lib\python\Products\PythonScripts\Guarded.py, line 273, in __getattr__ File E:\Zope\2379B4~1.2\lib\python\Products\PythonScripts\Guarded.py, line 152, in __careful_getattr__ ...and yet the following code: objects = [] for brain in brains: objects.append(brain.getObject()) ...works fine. This is on Zope 2.3.2, is it a bug? cheers, Chris ___ 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 Script bug?
Chris Withers wrote: Hi, The following code: objects = map(lambda b: b.getObject,brains) try objects = map(lambda b: b.getObject(),brains) --- Hannu ___ 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 )
[Zope-dev] Python Script
Hi All, I must say that I have very hard time with both Scripts and Zclass. My problem is the context and the container proprties of a script inside a Zclass. If I understand well the context is an URL point of view, the object accessed through the web. The container is fixed, it's the object in the database, OK? Now what is the container in the case of a Zclass _instance_. When I test a script inside the zclass _definition_ the container.objectItems() returns correctly all the other methods of the definition. When I run the script inside an _instance_ of that zclass it returns nothing. So is an instance the same container of its zclass definition or something else? What I should want to do is to access the images inside a zclass definition from the script running in an _instance_ 'context' of that zclass. BTW some pointers explaining the hierarchy in both the URL point of view and the database point of view would be very welcomed :-) Thanks in advance, Cyril ___ 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 Script
Cyril Elkaim wrote: Hi All, I must say that I have very hard time with both Scripts and Zclass. My problem is the context and the container proprties of a script inside a Zclass. If I understand well the context is an URL point of view, the object accessed through the web. The container is fixed, it's the object in the database, OK? Now what is the container in the case of a Zclass _instance_. In this case, container is the ZClass instance. This is consistent with the object-oriented way of defining methods in a class definition, and using them bound to an instance of that class. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net ___ 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 Script
Thanks Steve, In this case, container is the ZClass instance. Understood, that was my conclusion and it's logical. One more question please :-) How can I access the methods definitions of the zclass from an instance ? I don't talk about calling them but getting an 'attribute' of the zclass knowing only its name at _runtime_ not _compile_ time? Thanks, Cyril ___ 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 Script
Cyril Elkaim wrote: How can I access the methods definitions of the zclass from an instance ? I don't talk about calling them but getting an 'attribute' of the zclass knowing only its name at _runtime_ not _compile_ time? I don't entirely understand what you want to do. Calling a method on a ZClass instance involves getting the attribute that represents that method, then calling it. Get the object that represents the method, and do what you want with it. Can you give me a concrete example? -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net ___ 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 Script
Hi Steve, In the zclass definition I have a bunch of Image objects together with the following script. SCRIPT s_center(width, height, image): import string result = None for item in container.objectItems(): if string.strip(item[0]) == image: image_width = int(item[1].getProperty("width")) image_height = int(item[1].getProperty("height")) left = (int(width) - image_width) / 2 top = (int(height) - image_height) /2 result = "left:" + str(left) + "px; top:" + str(top) + "px" return result /END_SCRIPT This script works fine if I test it inside the test tabs of the zclass. But if I run it from an instance 'container.objectItems()' returns nothing. I understand why but my problem is how to get access of the images from the instance. What I need is something giving a reference to the zclass definition from one of its instance. I think I can use the DOM model and walk through until I find it but it should be better to have a direct access from the instance itself, wrong? Thanks, Cyril ___ 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 Script
Cyril Elkaim wrote: This script works fine if I test it inside the test tabs of the zclass. But if I run it from an instance 'container.objectItems()' returns nothing. I understand why but my problem is how to get access of the images from the instance. What I need is something giving a reference to the zclass definition from one of its instance. I think I can use the DOM model and walk through until I find it but it should be better to have a direct access from the instance itself, wrong? From an external method, you can do dir(self.__class__) or dir(type(self)) to get the attributes of your class. From a PythonScript, you can use something like container.Control_Panel.Products.product_name.class_name to get a reference to the ZClass definition. You should also be able to use this: container.manage_addProduct['product_name'].class_name I suggest you make a PythonScript or external method in your ZClass definition called list_attributes, that returns a list of the attributes of the ZClass definiton. Your other methods can call that. That way, if you change the Product of your ZClass in the future, you only have one thing to alter (should you choose the PythonScript). I advise against using an external method for this, as (if you're not careful) it may return unwrapped objects, which is a security hazard. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net ___ 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 Script
Steve Alexander wrote: for name,object in container.objectItems(): if string.strip(name) == image: image_width = int(object.getProperty("width")) image_height = int(object.getProperty("height")) Thanks again :-), I passed too much time with Javascript and not enough with Python, but that will changed soon :-) Cyril ___ 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 Script
Thanks Steve, I will try... Cyril ___ 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 )
[Zope-dev] Python Script Wish
Hi, Python Scripts are great :-) I wish I could create them through FTP. Basically, if you try to save a something.py into Zope through FTP, it currently creates a file object with the MIME type set to x-python. It's be really great if it coudl create a Python Script instead. Is that hard to do? Are there any gotchas? cheers, Chris ___ 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 script
On Tue, 9 Jan 2001 [EMAIL PROTECTED] wrote: Damnnation, Chris, everyone knows that it is supposed to be spelled Python Thingy. "I recently released 'zopectl', a Python Thingy"... 'Please go wash your hands before your shake hands with me!' Hmm. All kidding aside, Chris is right. This *is* the problem with "python script" that was pointed out during the name discussion. My use of "python script" is the traditional Unix/OS one: "a [shell] script written in python". Oh, well...fortunately the users most likely to be confused are the ones least likely to be using scripts at the os level. --RDM ___ 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 script
Zope mailing lists wrote: I recently released 'zopectl', a python script ...gak... now is that a 'python script' or a 'Python Script'? ;-) *grinz* Chris ___ 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 )