[Zope] Creating a DTM Document in a variable folder.

J Cameron Cooper zope-l at jcameroncooper.com
Wed Nov 30 15:52:26 EST 2005


Jonathan Cyr wrote:
> You might want to use index_html rather than index.html in this 
> example.  The dot means other things in Python, and index.html is a 
> carryover from filesystem webservers.  My impression is that the 
> acquisition mechanism doesn't like ids with a dot, in some circumstances.
> 
> Not trying to nit-pick, just got hung-up on that item myself once before.
> 
> ...or maybe that's not true anymore and has been allowed for...

That just means you can't traverse to it with attribute notation. For 
instance::

  self.plone.index.html

will not look for 'index.html' but rather the 'html' inside 'index'.

Same goes for dashes::

  self.plone.try-me

will try to subtract the value of the 'me' variable from the value of 
'self.plone.try'. But usually it will fail in trying to look up the 
first value.

In such cases, you can use "subscript" notation::

  self.plone['try-me']

or getattr (which doesn't use acquisition.)

		--jcc

> Peter Bengtsson wrote:
> 
>>folder = getattr(context, 'b')
>>adder = folder.manage_addProduct['OFSP'].methodAdd
>>adder('index.html', 'Some title')
>>
>>That creates it with default content. To change it you'll have to call
>>dtmlm = getattr(context, 'index.html')
>>dtmlm.manage_edit("bla bla bla bla bla", 'Same title')
>># or
>>f = open('/tmp/foobar.html')
>>dtmlm.manage_upload(f)
>>
>>
>>
>>
>>On 11/25/05, Martin Koekenberg <martin at digital-adventures.nl> wrote:
>>  
>>
>>> Hello,
>>>
>>>I don't have any Python experience yet, so who has a solution for this
>>>'problem'.
>>>
>>> Example:
>>>
>>>I 've 3 folders a, b & c.
>>>I want to create a dtml document in a folder by a form. The folder is a
>>>variable in my form.
>>> The formis no problem, the form action is no problem. The python script to
>>>craete that document is my problem.
>>>
>>> How can I create a DTM Document in a variable container ?
>>>
>>> Regards,
>>>
>>> Martin Koekenberg
>>>
>>>_______________________________________________
>>>Zope maillist  -  Zope at 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 )
>>>
>>>
>>>
>>>    
>>>
>>
>>
>>--
>>Peter Bengtsson,
>>work www.fry-it.com
>>home www.peterbe.com
>>hobby www.issuetrackerproduct.com
>>_______________________________________________
>>Zope maillist  -  Zope at 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 )
>>
>>  
>>
> 
> -- 
> Jonathan Cyr
> http://www.cyr.info
> http://www.weddingweblog.com
> cyrj at cyr.info
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Zope maillist  -  Zope at 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 )


-- 
"Building Websites with Plone"
http://plonebook.packtpub.com/

Enfold Systems, LLC
http://www.enfoldsystems.com


More information about the Zope mailing list