Create object from path
Hello, I want to build an object from its path (string). In pseudo-code, it would be something like that: obj = makeObject('/mySite/news/news06172003') print obj.getId() ... assuming that news06172003 is a document located in /mySite/news. How do I achieve that in Python, DTML and/or ZPT? Your help is much appreciated, Robert __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
Do you want to create an object or retrieve an object by path. Your idea below is odd since you do not specify what what kind of object to be created. In general you need to create an object and add this object to a container using container._setOb() or container._setObject(). There is also another approach using factories. Google for details. -aj --On Dienstag, 17. Juni 2003 12:17 Uhr -0700 Robert Jean <robertjean2@yahoo.com> wrote:
Hello,
I want to build an object from its path (string). In pseudo-code, it would be something like that:
obj = makeObject('/mySite/news/news06172003') print obj.getId()
... assuming that news06172003 is a document located in /mySite/news.
How do I achieve that in Python, DTML and/or ZPT?
Your help is much appreciated, Robert
__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Do you want to create an object or retrieve an object by path. Your idea below is odd since you do not specify what what kind of object to be created. In general you need to create an object and add this object to a container using container._setOb() or container._setObject(). There is also another approach using factories. Google for details. -aj --On Dienstag, 17. Juni 2003 12:17 Uhr -0700 Robert Jean <robertjean2@yahoo.com> wrote:
Hello,
I want to build an object from its path (string). In pseudo-code, it would be something like that:
obj = makeObject('/mySite/news/news06172003') print obj.getId()
... assuming that news06172003 is a document located in /mySite/news.
How do I achieve that in Python, DTML and/or ZPT?
Your help is much appreciated, Robert
__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
On Tue, Jun 17, 2003 at 09:26:34PM +0200, Andreas Jung wrote:
Do you want to create an object or retrieve an object by path.
I interpreted it as the latter... if so, in a python script you could do obj = container.restrictedTraverse('/path/to/my/object') -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's TOWNSMAN THING! (random hero from isometric.spaceninja.com)
participants (3)
-
Andreas Jung -
Paul Winkler -
Robert Jean