Re: [Zope-dev] Should PageTemplate._text be a unicode or an encoded string in Zope 2.9.3?

2006-07-22 Thread Stefan H. Holek
zope.pagetemplate.pagetemplatefile.PageTemplateFile reads an eventual  
meta http-equiv=Content-Type ... header, or defaults to UTF-8.


Stefan


On 21. Jul 2006, at 16:53, Chris Withers wrote:


I wonder how Zope 3's filesystem-based ZPT's deal with this?


--
Anything that, in happening, causes something else to happen,
causes something else to happen.  --Douglas Adams


___
Zope-Dev maillist  -  Zope-Dev@zope.org
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 )


Re: [Zope-dev] Should PageTemplate._text be a unicode or an encoded string in Zope 2.9.3?

2006-07-22 Thread Tino Wildenhain
Stefan H. Holek wrote:

 On 21. Jul 2006, at 16:53, Chris Withers wrote:
 
 I wonder how Zope 3's filesystem-based ZPT's deal with this?
 

 zope.pagetemplate.pagetemplatefile.PageTemplateFile reads an eventual
 meta http-equiv=Content-Type ... header, or defaults to UTF-8.

Well, pagetemplate files are another thing. They have to deal with
the lack of charset information of a filesystem file and what they
do once they load the data is even another thing.

Even filesystem pagetemplates should work with unicode internal,
making it easy to recode them for output and combine with other
potentially unicode stuff.

Tino
___
Zope-Dev maillist  -  Zope-Dev@zope.org
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 )


Re: [Zope-dev] Should PageTemplate._text be a unicode or an encoded string in Zope 2.9.3?

2006-07-22 Thread Andreas Jung



--On 22. Juli 2006 15:34:01 +0200 Tino Wildenhain [EMAIL PROTECTED] 
wrote:

Well, pagetemplate files are another thing. They have to deal with
the lack of charset information of a filesystem file and what they
do once they load the data is even another thing.

Even filesystem pagetemplates should work with unicode internal,
making it easy to recode them for output and combine with other
potentially unicode stuff.



huh?..even on the file system a pt file is encoded using some encoding.
For an XML pagetemplate file the encoding is clearly defined through the 
BOM (if available) and/or the XML preamble. So the most reliable solution 
would be to use XML PTs only.


-aj

pgpk47LXu3Abb.pgp
Description: PGP signature
___
Zope-Dev maillist  -  Zope-Dev@zope.org
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 )


Re: [Zope-dev] Should PageTemplate._text be a unicode or an encoded string in Zope 2.9.3?

2006-07-22 Thread Tino Wildenhain

Andreas Jung schrieb:




--On 22. Juli 2006 15:34:01 +0200 Tino Wildenhain [EMAIL PROTECTED] 
wrote:



Well, pagetemplate files are another thing. They have to deal with
the lack of charset information of a filesystem file and what they
do once they load the data is even another thing.

Even filesystem pagetemplates should work with unicode internal,
making it easy to recode them for output and combine with other
potentially unicode stuff.




huh?..even on the file system a pt file is encoded using some encoding.
For an XML pagetemplate file the encoding is clearly defined through 
the BOM (if available) and/or the XML preamble. So the most reliable 
solution would be to use XML PTs only.


Yes but you have to explicitely store that information somehow in the
file - zope objects can use other methods to transfer encoding information
while they create the internal representation.
meta-tags for charset are quite ugly but you basically have no other
choice with filesystem stuff.
Problem here if the various encoding notifications collide (XML header 
vs. XHTML meta-tag vs. BOM) so better have as few as possible - even 
better none when

we deal with HTTP-Servers which can nicely handle this all out of band
and on demand.

webdav or put can send charset data, zmi would use 
default-zpublisher-encoding

etc. If you store the internal object in unicode you can safely combine
different souces of encoded data instead of having a weird mesh of
decoding and encoding going on.

So I would not care how to find out about the intended encoding - once the
object is instantiated.

Regards
Tino
___
Zope-Dev maillist  -  Zope-Dev@zope.org
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 )


Re: [Zope-dev] Should PageTemplate._text be a unicode or an encoded string in Zope 2.9.3?

2006-07-22 Thread Andreas Jung



--On 22. Juli 2006 16:17:09 +0200 Tino Wildenhain [EMAIL PROTECTED] 
wrote:

huh?..even on the file system a pt file is encoded using some encoding.
For an XML pagetemplate file the encoding is clearly defined through
the BOM (if available) and/or the XML preamble. So the most reliable
solution would be to use XML PTs only.


Yes but you have to explicitely store that information somehow in the
file - zope objects can use other methods to transfer encoding information
while they create the internal representation.
meta-tags for charset are quite ugly but you basically have no other
choice with filesystem stuff.
Problem here if the various encoding notifications collide (XML header
vs. XHTML meta-tag vs. BOM) so better have as few as possible - even
better none when


I am only talking of XML. And the encoding is clearly and unambiguously 
defined through the BOM (if available) and the XML preamble. So any 
application reading an XML file is able to detect the encoding and produce
a unicode string from the file. According to a discussion with Dieter the 
Python XML parsers don't deal with the BOM and leave it up to the 
application to interpret the BOM correctly.


-aj 

pgpHsujepZPLt.pgp
Description: PGP signature
___
Zope-Dev maillist  -  Zope-Dev@zope.org
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 )


Re: [Zope-dev] Should PageTemplate._text be a unicode or an encoded string in Zope 2.9.3?

2006-07-22 Thread Tino Wildenhain
Andreas Jung wrote:
 
 
 --On 22. Juli 2006 16:17:09 +0200 Tino Wildenhain [EMAIL PROTECTED]
 wrote:
 huh?..even on the file system a pt file is encoded using some encoding.
 For an XML pagetemplate file the encoding is clearly defined through
 the BOM (if available) and/or the XML preamble. So the most reliable
 solution would be to use XML PTs only.

 Yes but you have to explicitely store that information somehow in the
 file - zope objects can use other methods to transfer encoding
 information
 while they create the internal representation.
 meta-tags for charset are quite ugly but you basically have no other
 choice with filesystem stuff.
 Problem here if the various encoding notifications collide (XML header
 vs. XHTML meta-tag vs. BOM) so better have as few as possible - even
 better none when
 
 I am only talking of XML. And the encoding is clearly and unambiguously
 defined through the BOM (if available) and the XML preamble. So any

Pardon, thats nonsense. BOM means byte oder mark and not encoding mark
(It would read EM instead, wouldnt it? ;) Its only used with some 16 bit
encodings to tell the byte order of the two bytes (obviously).
And XML only via its XML preambel, which is just another place to put
encoding information in band. (In fact we should have publishing engine
to fix this preamble as well as the infamous meta-tag (if available)
to reflect the encoding currently in use.


 application reading an XML file is able to detect the encoding and produce
 a unicode string from the file. According to a discussion with Dieter

Yes, and in case of the filesystempagetemplates and friends, the
template is that application which reads and should produce the unicode
string.


Regards
Tino
___
Zope-Dev maillist  -  Zope-Dev@zope.org
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] restarted zope and now not answering port 8080

2006-07-22 Thread Noah





Hi there,

zope-2.8.8
freebsd-4.11

so I just installed plone and stopped and restarted zope and found that
it no longer answers port 8080. there is nothing in the logs that
shows something is wrong. 

I see the zope daemon running it is not quitting.

I see a python2.3 process run by nobody that tacks up to 99% CPU about
every 10 seconds. 

any clues how I can go about troubleshooting this?

Cheer,s
Noah




___
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 )


Re: [Zope] restarted zope and now not answering port 8080

2006-07-22 Thread Andreas Jung



--On 22. Juli 2006 00:34:24 -0700 Noah [EMAIL PROTECTED] wrote:



Hi there,

zope-2.8.8
freebsd-4.11

so I just installed plone and stopped and restarted zope and found that
it no longer answers port 8080.  there is nothing in the logs that shows
something is wrong.

I see the zope daemon running it is not quitting.

I see a python2.3 process run by nobody that tacks up to  99% CPU about
every 10 seconds.



Kill the remaining process manually and restart again.

-aj

pgprq5XI8GOl0.pgp
Description: PGP signature
___
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 )


Re: [Zope] restarted zope and now not answering port 8080

2006-07-22 Thread Noah

Andreas Jung wrote:



--On 22. Juli 2006 00:34:24 -0700 Noah [EMAIL PROTECTED] wrote:



Hi there,

zope-2.8.8
freebsd-4.11

so I just installed plone and stopped and restarted zope and found that
it no longer answers port 8080.  there is nothing in the logs that shows
something is wrong.

I see the zope daemon running it is not quitting.

I see a python2.3 process run by nobody that tacks up to  99% CPU about
every 10 seconds.



Kill the remaining process manually and restart again.




Andreas,

that didnt completely work.

---s nip ---

# /usr/local/etc/rc.d/zope.sh start
Starting Zope
  Instance /a/www/Zope - . Unlinking stale socket 
/a/www/Zope-2.8/var/zopectlsock; sleep 1

No handlers could be found for logger root
. daemon process started, pid=24796

--- snip ---

still port 8080 eventually just closes without any pages being sent.

cheers,
Noah




-aj


___
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 )


Re: [Zope] restarted zope and now not answering port 8080

2006-07-22 Thread Andreas Jung



--On 22. Juli 2006 00:42:05 -0700 Noah [EMAIL PROTECTED] wrote:





Kill the remaining process manually and restart again.




Andreas,

that didnt completely work.

---s nip ---

# /usr/local/etc/rc.d/zope.sh start
Starting Zope
   Instance /a/www/Zope - . Unlinking stale socket
/a/www/Zope-2.8/var/zopectlsock; sleep 1
No handlers could be found for logger root
. daemon process started, pid=24796

--- snip ---

still port 8080 eventually just closes without any pages being sent.



I don't believe that! There is usually at least *something* in your 
event.log in case of a failuretrible check your logs.


-aj

pgpXP2dmONHMf.pgp
Description: PGP signature
___
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 )


Re: [Zope] restarted zope and now not answering port 8080 [solved]

2006-07-22 Thread Noah

Andreas Jung wrote:



--On 22. Juli 2006 00:42:05 -0700 Noah [EMAIL PROTECTED] wrote:





Kill the remaining process manually and restart again.




Andreas,

that didnt completely work.

---s nip ---

# /usr/local/etc/rc.d/zope.sh start
Starting Zope
   Instance /a/www/Zope - . Unlinking stale socket
/a/www/Zope-2.8/var/zopectlsock; sleep 1
No handlers could be found for logger root
. daemon process started, pid=24796

--- snip ---

still port 8080 eventually just closes without any pages being sent.



I don't believe that! There is usually at least *something* in your 
event.log in case of a failuretrible check your logs.


thanks for pushing me to dig deeper.  although I did not find anything 
in the event.log . I did start zope with zopectl this time.  and while 
viewing the output I could clearly see that my  
TextIndexNG3/adapters/configure.zcml file was having some difficulties.


this has since been fixed and zope is running fine.

thanks Andreas.

Cheers,
Noah


___
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 )


[Zope] How to prevent subobjects to catalog a parents attribute

2006-07-22 Thread Mohsen Moeeni

Hi;

My folder (which extends ATFolder from ATContentTypes) has
a `catagory` attribute (field) which I want to be present in the
catalog both as index and metadata. So I have added the
`category` FiledIndex and metadata to my catalog object.
Everything is fine when I look at my indexed custom folder in the
catalog. However, the problem is that the subobjects of this
folder will also have the same value as their parent for the category
index and metadata because of the acquisition. Can I prevent this?

On workaround is to prevent `category' from being acquired by
subobjects by using some mechanism (like changing the name
to _category which I do not like). Is it *the* way to go? I'd like to
know people's idea about this problem.

Cheers,
Mohsen,
___
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 )


Re: [Zope] How to prevent subobjects to catalog a parents attribute

2006-07-22 Thread Andreas Jung



--On 22. Juli 2006 17:08:43 +0330 Mohsen Moeeni [EMAIL PROTECTED] wrote:


Hi;

My folder (which extends ATFolder from ATContentTypes) has
a `catagory` attribute (field) which I want to be present in the
catalog both as index and metadata. So I have added the
`category` FiledIndex and metadata to my catalog object.
Everything is fine when I look at my indexed custom folder in the
catalog. However, the problem is that the subobjects of this
folder will also have the same value as their parent for the category
index and metadata because of the acquisition. Can I prevent this?


Look at ManageableIndexes...they provide control over acquistion while 
indexing.


-aj


pgppJLOe28W9p.pgp
Description: PGP signature
___
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 )


Re: [Zope] How to prevent subobjects to catalog a parents attribute

2006-07-22 Thread Mohsen Moeeni

On 7/22/06, Andreas Jung [EMAIL PROTECTED] wrote:



--On 22. Juli 2006 17:08:43 +0330 Mohsen Moeeni [EMAIL PROTECTED] wrote:

 Hi;
 [snip]
 . However, the problem is that the subobjects of this
 folder will also have the same value as their parent for the category
 index and metadata because of the acquisition. Can I prevent this?

Look at ManageableIndexes...they provide control over acquistion while
indexing.


Thanks. I wish I could do it without installing a new product.
Actually I could get the same effect but with a little bit of
hackiness. I added a `category` index which indexed
`_getCategoryForCatalog` method which can not be acquired
by subobjects because it start with `_`.

At any rate, either of these approaches solve half of the problem.
The other half is to do the same thing for a metadata. I doubt
it's easy to do that because unlike an index, metadata is not
plugable.

Mohsen,
___
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 )


[Zope] Acquisition and self arguements of methods

2006-07-22 Thread Mohsen Moeeni

Hello;

As far as I see, the `self` argument, when a method
is called, is not dependent on how the method was
acquired.

Consider I have an instance of class B which is named
b and has a method named `method_b`. In either of
these calls:

a.b.c.method_b()
a.b.method_b()

`self` argument will be `a.b` if I am not wrong. Is there
any way to get the acquisition context where a
method is called inside that method? In the other
words, how to get `a.b.c` within `method_b` when I
call `a.b.c.method_b` and `a.b` when I call
`a.b.method_b`?

Regards,
M. Moeini
___
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 )


[Zope] accessing object from a list constructed in __init__.py

2006-07-22 Thread kevin7kal

I'm doing some work with Five and have an aquisition related issue.
first, zope is zope 2.9.3
The trouble is with accessing the attributes of objects stored in the
number property in class2.
accessing class1.number via class2.method1a is no problem, the problem
seems to stem from constructing a list of objects ala class2.__init__,
if I try to append obj.__of__  in attribute1a I recieve an error that I
can not pickle a wrapped class.  Is there some other trick with
acquisition to be able to access the attributes of an object which is
stored in a list of object constructed in the __init__ function of a class?

--myClass.py
import Acquisition

class class1(Acquisition.Explicit):
 ''' a simple class with some attributes and methods'''
 attribute1 = 'attribute 1'
 attribute2 = 'attribute 2'
 _number = ''
 def __init__(self,number2):
 '''simple init for the class'''
 self._number=number2*3

 def method1(self):
 '''return a string methd1'''
 mthd1 =  'methd1'
 return mthd1
 def method2(self):
 ''' return a string methd2'''
 mthd2 = 'method2'
 return mthd2
 def _get_number(self):
 return self._number
 number = property(fget=_get_number)

class class2(object):
 ''' a second simple class with some attributes and methods'''
 attribute1a = []
 attribute2a = []
 def __init__(self):
 '''create a list of class1 objects in attribute1a'''
 i=1
 while i  5:
 obj = class1(i)
 self.attribute1a.append(obj)
 i=i+1

 def method1a(self):
 '''instantiate class1 as object and return object usable by 
zope'''

 obj = class1(5)
 return obj.__of__(self)
 def method2a(self):
 '''returns class1.method1()'''
 c1m1 = class1.method1()
 return c1m1
 attribute1b = property(fget=method1a)
 attribute2b = property(fget=method2a)



___
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 )


[Zope] Python/TAL Problem

2006-07-22 Thread beno

Hi;
I'm trying to tweak someone else' script to get it to do what I want. 
The script reads from and writes to the Properties tab of pages and 
folders, enabling one to change the titles of many pages/folders from 
one single script-generated page. I want to be able to do the same thing 
with another field I created called KW1 (string) in the Properties 
tab. The following is a snip of the code that needs to be altered (the 
only code where title appears):


 input type=text name=rows.title:records size=50
tal:attributes=value python:item['title'] /
 input type=hidden name=prev_rows.title:records
tal:attributes=value item/title /

If I alter line #2 and change title to KW1 I get the following error 
snippet:


   * Module Products.PageTemplates.ZRPythonExpr, line 47, in __call__
 __traceback_info__: item['KW1']
   * Module Python expression item['KW1'], line 1, in expression
   * Module AccessControl.ZopeGuards, line 67, in guarded_getitem

If I alter line #4 and change title to KW1 I get this error snippet:

   * Module Products.PageTemplates.Expressions, line 174, in __call__
   * Module Products.PageTemplates.Expressions, line 162, in _eval
   * Module Products.PageTemplates.Expressions, line 116, in _eval
 __traceback_info__: item
   * Module Products.PageTemplates.Expressions, line 320, in
 restrictedTraverse
 __traceback_info__: {'path': ['KW1'], 'TraversalRequestNameStack': []}

I have added KW1 as a string property to many of the pages in the target 
folder. What am I doing wrong? Complete code and complete errors follow.

Thanks.








COMPLETE SCRIPT

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
   http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;
html tal:condition=here/formHandler

!--
script type=text/javascript src=main.js/script
--

body

h1Manage Hierarchy/h1


form action= method=post name=form id=form
 tal:define=root python:request.fields['root'];
 items python:root['value'] and 
sequence.sort(here.getEntries(root['value'], all=1), (('id', 'cmp', 
'desc'),))



div id=filter
 select name=root
 tal:define=items python:here.getEntries('en-us', 2)
 
   option value=#8212;#8212;Select Folder#8212;#8212;/option

   option tal:repeat=item items
   tal:content=structure python:'%s\--%s' % 
('nbsp;'*5*item['level'], item['id'])

   tal:attributes=value python:item['url'];
   selected python:item['url'] == root['value']
   /option
 /select
 input type=submit name=onOk value=Ok /
/div



div id=resultSet
 table cellspacing=0 cellpadding=3 border=1
tal:condition=items
 tr
   thID/th
   thKW1/th
 /tr
 tr valign=top
 tal:repeat=item items
   td
 span tal:replace=structure python:'nbsp;' * (8 * item['level']) 
+ item['id']ID/span

 input type=hidden name=rows.id:records
tal:attributes=value python:item['url'] /
   /td
   td
 input type=text name=rows.title:records size=50
tal:attributes=value python:item['title'] /
 input type=hidden name=prev_rows.title:records
tal:attributes=value item/title /
   /td
 /tr
 /table

 div tal:condition=python:not items
   Sorry... no items to manage.br /
 /div
/div




div id=buttons
 input type=submit name=onSaveChanges value= Save Changes 
tal:condition=items /
/div

/form


/body
/html





FIRST ERROR MESSAGE
from changing  tal:attributes=value python:item['title'] 
/  total:attributes=value python:item['KW1'] /



   Site Error

An error was encountered while publishing this resource.

*KeyError*

Sorry, a site error occurred.

Traceback (innermost last):

   * Module ZPublisher.Publish, line 175, in publish_module_standard
   * Module ZPublisher.Publish, line 132, in publish
   * Module Zope.App.startup, line 204, in zpublisher_exception_hook
   * Module ZPublisher.Publish, line 101, in publish
   * Module ZPublisher.mapply, line 88, in mapply
   * Module ZPublisher.Publish, line 39, in call_object
   * Module Shared.DC.Scripts.Bindings, line 306, in __call__
   * Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
   * Module Products.PageTemplates.ZopePageTemplate, line 222, in _exec
   * Module Products.PageTemplates.PageTemplate, line 96, in pt_render
 *ZopePageTemplate at /footprints.2012.vi/test_kw/main/index_html*
   * Module TAL.TALInterpreter, line 190, in __call__
   * Module TAL.TALInterpreter, line 234, in interpret
   * Module TAL.TALInterpreter, line 637, in do_condition
   * Module TAL.TALInterpreter, line 234, in interpret
   * Module TAL.TALInterpreter, line 637, in do_condition
   * Module TAL.TALInterpreter, line 234, in interpret
   * Module TAL.TALInterpreter, line 613, in do_loop_tal
   * Module TAL.TALInterpreter, line 234, in interpret
   * Module TAL.TALInterpreter, line 263, in do_startEndTag
   * Module TAL.TALInterpreter, line 291, in do_startTag
   * Module TAL.TALInterpreter, line 357, 

Re: [Zope] accessing object from a list constructed in __init__.py

2006-07-22 Thread Alexis Roda

En/na kevin7kal ha escrit:

I'm doing some work with Five and have an aquisition related issue.
first, zope is zope 2.9.3
The trouble is with accessing the attributes of objects stored in the
number property in class2.


class2 must inherit from ExtensionClass.Base (or some subclass, like 
Acquisition.Explicit) in order to be acquisition aware.






HTH
___
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 )


Re: [Zope] accessing object from a list constructed in __init__.py

2006-07-22 Thread kevin7kal

Ok, thank you for that.
I can create the list of objects from the __of__(self) attribute without 
the wrapper error now,

but I still cannot access that attribute through zope.
Here is my code again, along with my zope content.

---myClass.py---
import Acquisition

class class1(Acquisition.Explicit):
   ''' a simple class with some attributes and methods'''
   attribute1 = 'attribute 1'
   attribute2 = 'attribute 2'
   _number = ''
   def __init__(self,number2):
   '''simple init for the class'''
   self._number=number2*3
  
   def method1(self):

   '''return a string methd1'''
   mthd1 =  'methd1'
   return mthd1
   def method2(self):
   ''' return a string methd2'''
   mthd2 = 'method2'
   return mthd2
   def _get_number(self):
   return self._number
   number = property(fget=_get_number)

class class2(Acquisition.Explicit):

   ''' a second simple class with some attributes and methods'''
   attribute1a = []
   attribute2a = []
   def __init__(self):
   '''create a list of class1 objects in attribute1a'''
   i=1
   while i  5:
   obj = class1(i)
   self.attribute1a.append(obj.__of__(self))
   i=i+1
  
   def method1a(self):

   '''instantiate class1 as object and return object usable by zope'''
   obj = class1(5)
   return obj.__of__(self)
   def method2a(self):
   '''returns class1.method1()'''
   c1m1 = class1.method1()
   return c1m1
   attribute1b = property(fget=method1a)
   attribute2b = property(fget=method2a)

myZclass.py-
from zope.interface import implements
from zope.schema.fieldproperty import FieldProperty
from OFS.SimpleItem import Item, SimpleItem
from persistent import Persistent
import myClass
from interfaces import *
import Acquisition

class Zclass2(SimpleItem,myClass.class2,Acquisition.Explicit):
   '''a simple zope class that inherits from my class'''
   implements(Izclass2)
   def __init__(self,tmpID='',tmpTITLE=''):
   '''non empty docstring'''
   cm = myClass.class2.__init__(self)
   return cm.__of__(self)

   def myZclass(self):
   cm = myClass.class2()
   return cm.__of__(self)


Alexis Roda wrote:

En/na kevin7kal ha escrit:

I'm doing some work with Five and have an aquisition related issue.
first, zope is zope 2.9.3
The trouble is with accessing the attributes of objects stored in the
number property in class2.


class2 must inherit from ExtensionClass.Base (or some subclass, like 
Acquisition.Explicit) in order to be acquisition aware.






HTH
___
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 )


___
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 )


Re: [Zope] accessing object from a list constructed in __init__.py

2006-07-22 Thread Alexis Roda

En/na kevin7kal ha escrit:

Ok, thank you for that.
I can create the list of objects from the __of__(self) attribute without 
the wrapper error now,

but I still cannot access that attribute through zope.


Your description is vague. A traceback could be useful.

Maybe the problem is security related. Not sure, I'm still not 
acquainted with zope + new style classes + five. To test it add:


__allow_access_to_unprotected_attributes__ = 1

to class1, class2 and Zclass2 definitions.

OTOH Zclass2.myZclass() lacks a docstring


Some unrelated notes:

Zclass2.__init__ shouldn't return anything

SimpleItem inherits from Acquisition.Implicit, and class2 inherits from 
Acquisition.Explicit. Making Zclass2 inherit from Acquisition.Explicit 
is both redundant and useless.





HTH
___
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 )