I have a DTML method, category_list_cookie, which returns a string of colon-separated values I use elsewhere. I would like to split this into a list so I can use something like phred.count('whatever') to see if this value is present. However, when I do something like: <dtml-with "_.namespace(var1=_.string.split(category_list_cookie, ':'))"> I get this error: Error Type: TypeError Error Value: argument 1: expected read-only character buffer, ImplicitAcquirerWrapper found Even with something like this: <dtml-with "_.namespace(var1=category_list_cookie)"> <dtml-call "REQUEST.set('var2', _.string.split(var1, ':'))"> the split method gives the same error. Is var1 in the second example merely a reference to category_list_cookie, so that I get the same error? Whether or not this is the case, what does the error mean and how do I fix it? Cheers, Jim
Try this, I think it should work: <dtml-with "_.namespace(var1=_.string.split(_['category_list_cookie'], ':'))"> Often replacing name_of_my_variable by _['name_of_my_variable'] produce better results. I even don't know why in this case and I gave up trying to find the reasons until I can get a good documentation explaning how and why things work in Zope. An idea: there are about 1500 members in zope.org. If everyone gives $200 the total is $300 000. For that amount I think we could find a good team of writers that could quickly write real good and complete documentation not only targeted to top gun programmers in Zope. What do you think about that? If DC could also give its opinion. For my part I would give up to $400 just for that. Open source doesn't mean poor documentation. Look at Python. I know that everybody involved in Zope development does the best he can as I can see when I receive answers to my questions. At 21:04 99-10-09 -0400, Jim Cain wrote:
I have a DTML method, category_list_cookie, which returns a string of colon-separated values I use elsewhere. I would like to split this into a list so I can use something like phred.count('whatever') to see if this value is present.
However, when I do something like:
<dtml-with "_.namespace(var1=_.string.split(category_list_cookie, ':'))">
I get this error:
Error Type: TypeError Error Value: argument 1: expected read-only character buffer, ImplicitAcquirerWrapper found
Even with something like this:
<dtml-with "_.namespace(var1=category_list_cookie)"> <dtml-call "REQUEST.set('var2', _.string.split(var1, ':'))">
the split method gives the same error. Is var1 in the second example merely a reference to category_list_cookie, so that I get the same error? Whether or not this is the case, what does the error mean and how do I fix it?
Cheers, Jim
****************************************************** Oscar Picasso picasso@videotron.ca ******************************************************
--On Sat, Oct 9, 1999 23:28 -0400 Oscar Picasso <picasso@videotron.ca> wrote:
Try this, I think it should work: <dtml-with "_.namespace(var1=_.string.split(_['category_list_cookie'], ':'))">
Wish I had thought of that. :-) Thanks very much; it worked. Jim
At 21:04 99-10-09 -0400, Jim Cain wrote:
I have a DTML method, category_list_cookie, which returns a string of colon-separated values I use elsewhere. I would like to split this into a list so I can use something like phred.count('whatever') to see if this value is present.
However, when I do something like:
<dtml-with "_.namespace(var1=_.string.split(category_list_cookie, ':'))">
I get this error:
Error Type: TypeError Error Value: argument 1: expected read-only character buffer, ImplicitAcquirerWrapper found
Even with something like this:
<dtml-with "_.namespace(var1=category_list_cookie)"> <dtml-call "REQUEST.set('var2', _.string.split(var1, ':'))">
the split method gives the same error. Is var1 in the second example merely a reference to category_list_cookie, so that I get the same error? Whether or not this is the case, what does the error mean and how do I fix it?
Cheers, Jim
****************************************************** Oscar Picasso picasso@videotron.ca ******************************************************
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(Related lists - please, no cross posts or HTML encoding!
To receive general Zope announcements, see: http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
____________ Jim Cain, System Administrator ___ / ________ \ http://jec.mgmt-inc.com / / / / ______ \ \ _________ _______ _________ __/ /__ / / / __ \ \ \ / _ _ \ / ___ \ / _ _ \/_ ___/ / / / /_/ / / // // // // /__/ // // // / / /___ \ \ \___,_ \/ //__//__//__/ \____ //__//__//__/ \_____/, inc. \ \______\____/ _____/ / \_______/ \______/ http://www.mgmt-inc.com
Oscar Picasso wrote:
Try this, I think it should work: <dtml-with "_.namespace(var1=_.string.split(_['category_list_cookie'], ':'))">
Often replacing name_of_my_variable by _['name_of_my_variable'] produce better results.
Did that work? I don't understand it either, so I'm interested in why/how it would, if anyone has insight...
I even don't know why in this case and I gave up trying to find the reasons until I can get a good documentation explaning how and why things work in Zope.
I would love to see some developer code for Zope. Reading through implementations of objects is educational, but it is hard to keep an eye on the big picture and find all of the implications of the various tricks used while you are trying to sort out code at the same time.
An idea: there are about 1500 members in zope.org. If everyone gives $200 the total is $300 000. For that amount I think we could find a good team of writers that could quickly write real good and complete documentation not only targeted to top gun programmers in Zope.
How would DC feel about someone outside their company writing a book on the subject? Would they support such a project?
What do you think about that? If DC could also give its opinion. For my part I would give up to $400 just for that.
I was able to convince my company to buy support for Zope from DC. We decided that if we had problems, we wanted the safety net and the rates were quite reasonable. I have been very impressed with the support I have received, even from the sales reps! I don't mean that as a slight to sales reps in general, but the ones from DC stood out as very knowledgeable about their product.
At 21:04 99-10-09 -0400, Jim Cain wrote:
I have a DTML method, category_list_cookie, which returns a string of colon-separated values I use elsewhere. I would like to split this into a list so I can use something like phred.count('whatever') to see if this value is present.
However, when I do something like:
<dtml-with "_.namespace(var1=_.string.split(category_list_cookie, ':'))">
If category_list_cookie is a DTML method, then you don't want to split it, you want to split its return value. The <dtml-var> tag lets you cheat by figuring out for you that category_list_output is callable, calling it, and returning the representation of the output instead of the method object itself. However, when you start dealing with expressions in quotes, you are moving out of DTML and into Python.
I get this error:
Error Type: TypeError Error Value: argument 1: expected read-only character buffer, ImplicitAcquirerWrapper found
Python is reporting its confusion as a TypeError exception, telling you that the parameter you passed to string.split() is not a "read-only character buffer" as required by the split function, but is instead an "ImplicitAcquirerWrapper." I haven't actually seen that object type before, but it sounds like something from Zope (rather than any kind of object from the Python standard library) created to handle the fact that category_list_cookie is not a property of the current object, but was Acquired from the object hierarchy in your server. To get the output of the method, the real value you want to work with, you have to call the method by adding () after category_list_cookie: <dtml-with "_.namespace(var1=_.string.split(category_list_cookie(), ':'))"> ^^^^ You could also (re)write category_list_cookies as an ExternalMethod which returns a Python list object. Then, since the result would be a sequence over which you could iterate, you could use it with <dtml-in>: <ul> <dtml-in category_list_cookie_as_eternal_method> <li><dtml-var sequence-item> </dtml-in> </ul> Or take the length of the result directly (without splitting the results): <dtml-var "len(category_list_cookie_as_external_method())"> Doug
Jim Cain wrote:
I have a DTML method, category_list_cookie, which returns a string of colon-separated values I use elsewhere. I would like to split this into a list so I can use something like phred.count('whatever') to see if this value is present.
However, when I do something like:
<dtml-with "_.namespace(var1=_.string.split(category_list_cookie, ':'))">
I get this error:
Error Type: TypeError Error Value: argument 1: expected read-only character buffer, ImplicitAcquirerWrapper found
So category_list_cookie is not a string. I'm not sure if cookies are meant to be strings, or if your variable is actually a cookie. Try: <dtml-var "_.repr(category_list_cookie)"> to find out what it is. Sounds alot from your traceback like it's a Zope object. In that case: <dtml-with category_list_cookie> <dtml-var absolute_url> </dtml-with> Will tell you what it is. This could point out any possible logic errors in your assignment. -Michel
participants (4)
-
Doug Hellmann -
Jim Cain -
Michel Pelletier -
Oscar Picasso