Mailing List Archive

Iterating over objects in ZODB
When iterating over dtml objects, the contents of those scripts can be returned:

e.g.

for item in context.objectValues():
if item.meta_type=='DTML Method’:
print item


But when iterating over Python Scripts, only:

<PythonScript at handleday>

is returned. How can I access the actual contents of the Python Script?

Thanks
Rich
_______________________________________________
Zope maillist - Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )
Re: Iterating over objects in ZODB [ In reply to ]
Am Mittwoch, 13. Mai 2015, 11:36:03 schrieb Rich Harley:
> is returned. How can I access the actual contents of the Python Script?
The python script object seems a bit more complex then a DTML-Method object -
means you have to access the script content of the python script object
directly (not shure if it's "params" and "body" - have to look into Zope help
(PythonScript.py) or Zope sources for the exact "field").

regarduing the object docs it shoudl work with .read() directly (if it IS a
PythonScript object) or "document_src":

def read():
"""

Return the body of the Python Script, with a special comment
block prepended. This block contains meta-data in the form of
comment lines as expected by the 'write' method.

"""
def document_src(REQUEST=None, RESPONSE=None):
"""

Return the text of the 'read' method, with content type
'text/plain' set on the RESPONSE.

"""


hth a bit and works,


Niels.
--
---
Niels Dettenbach
Syndicat IT & Internet
http://www.syndicat.com
PGP: https://syndicat.com/pub_key.asc
---
Re: Iterating over objects in ZODB [ In reply to ]
obj.body()


On 13 May 2015, Niels Dettenbach <nd@syndicat.com> wrote:
> Am Mittwoch, 13. Mai 2015, 11:36:03 schrieb Rich Harley:
> > is returned. How can I access the actual contents of the Python Script?
> > The python script object seems a bit more complex then a DTML-Method object -
> means you have to access the script content of the python script object
> directly (not shure if it's "params" and "body" - have to look into Zope help
> (PythonScript.py) or Zope sources for the exact "field").
>
> regarduing the object docs it shoudl work with .read() directly (if it IS a
> PythonScript object) or "document_src":
>
> def read():
> """
>
> Return the body of the Python Script, with a special comment
> block prepended. This block contains meta-data in the form of
> comment lines as expected by the 'write' method.
>
> """
> def document_src(REQUEST=None, RESPONSE=None):
> """
>
> Return the text of the 'read' method, with content type
> 'text/plain' set on the RESPONSE.
>
> """
>
>
> hth a bit and works,
>
>
> Niels.
> --
> ---
> Niels Dettenbach
> Syndicat IT & Internet
> <http://www.syndicat.com>
> PGP: <https://syndicat.com/pub_key.asc>
> ---
>
>
>
>
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> <https://mail.zope.org/mailman/listinfo/zope>
> ** No cross posts or HTML encoding! **
> (Related lists -
> <https://mail.zope.org/mailman/listinfo/zope-announce>
> <https://mail.zope.org/mailman/listinfo/zope-dev> )
>
Re: Iterating over objects in ZODB [ In reply to ]
give this a try:

if item.meta_type == 'Script (Python)':
print(item.document_src())

-Flip

On 05/13/2015 07:36 AM, Rich Harley wrote:
> When iterating over dtml objects, the contents of those scripts can be returned:
>
> e.g.
>
> for item in context.objectValues():
> if item.meta_type=='DTML Method’:
> print item
>
>
> But when iterating over Python Scripts, only:
>
> <PythonScript at handleday>
>
> is returned. How can I access the actual contents of the Python Script?
>
> Thanks
> Rich
> _______________________________________________
> Zope maillist - Zope@zope.org
> https://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> https://mail.zope.org/mailman/listinfo/zope-announce
> https://mail.zope.org/mailman/listinfo/zope-dev )


--
Mike McFadden
Radio Free Asia
Technical Operations Division
2025 M Street NW
Washington DC 20036 USA

This e-mail message is intended only for the use of the addressee and may contain information that is privileged and confidential. Any unauthorized dissemination, distribution or copying is strictly prohibited. If you receive this transmission in error, please contact network@rfa.org.


_______________________________________________
Zope maillist - Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )