473,326 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Zope/DTML Infuriating...

Hello Everyone.

I am relatively new to Zope(using it for a work project) and I was
wondering if someone here could help me out or at least refer me to a
decent documentationg for Zope/DTML/Python (at the detail level of
php.net or Java API reference). http://www.zope.org/Documentation/Bo...ok/2_6Edition/
isn't really detailed enough for my taste. if it doesn't contain a
exhautive description of all available base classes it's simply no
good as a reference resource.

Anyway I have the following problem. I'm using zope 2.9 and I would
expect the following dtml code to yield a list containing main1, main2
etc.

<dtml-let prefix="'main'">
<ul>
<dtml-in expr="_.range(1,10)">
<li><dtml-var expr="_['prefix'] + _['sequence-item']"></li>
</dtml-in>
</ul>
</dtml-let>

But it doesn't work(and yes i know that i could simply do "... <dtml-
var prefix><dtml-var sequence-item>...", but that's not what i need).
I've the checked that i'm referring to the variables correctly, so the
only explanation i can come up with, is that '+' doesn't result in a
string concatenation (with implicit typecast to string of the integer
variable(this is a interpreted language after all)). It apparently
works in other cases but for some reason not here. I get the following
cryptical error message which makes me none the wiser.

An error was encountered while publishing this resource.

Error Type: AttributeError
Error Value: 'NoneType' object has no attribute 'group'

I would appreciate any feedback you might have regarding this. Thanks
in Advance.
Jun 27 '08 #1
15 1161
Jens wrote:
I've the checked that i'm referring to the variables correctly, so the
only explanation i can come up with, is that '+' doesn't result in a
string concatenation (with implicit typecast to string of the integer
variable(this is a interpreted language after all)).
No, sorry. You really need to read the python tutorial at the very least.
You might have wrong assumptions from previous PHP experiences.
>>'x'+4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
>>>
Jun 27 '08 #2
On Apr 29, 1:59*pm, Marco Mariani <ma...@sferacarta.comwrote:
Jens wrote:
I've the checked that i'm referring to the variables correctly, so the
only explanation i can come up with, is that '+' doesn't result in a
string concatenation (with implicit typecast to string of the integer
variable(this is a interpreted language after all)).

No, sorry. You really need to read the python tutorial at the very least.
You might have wrong assumptions from previous PHP experiences.

*>>'x'+4
Traceback (most recent call last):
* *File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
*>
... and the non snobby answer would have been:

... <dtml-var expr="_['prefix'] + str(_['sequence-item'])">
Jun 27 '08 #3
On Apr 29, 1:59*pm, Marco Mariani <ma...@sferacarta.comwrote:
Jens wrote:
I've the checked that i'm referring to the variables correctly, so the
only explanation i can come up with, is that '+' doesn't result in a
string concatenation (with implicit typecast to string of the integer
variable(this is a interpreted language after all)).

No, sorry. You really need to read the python tutorial at the very least.
You might have wrong assumptions from previous PHP experiences.

*>>'x'+4
Traceback (most recent call last):
* *File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
*>
... and the non snobby answer would have been:

... <dtml-var expr="_['prefix'] + str(_['sequence-item'])">
Jun 27 '08 #4
Jens wrote:
>You might have wrong assumptions from previous PHP experiences.
> >>'x'+4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
> >
... and the non snobby answer would have been:

... <dtml-var expr="_['prefix'] + str(_['sequence-item'])">

Sorry. Not trying to be snobbish, only in a hurry.

That answer would have been less useful, because there are TONS of
details in the python tutorial, that set the language apart from its
"scripting cousins".
Reading the syntax and thinking "yeah, got it, boring, next chapter" is
a common mistake I've also made sometime, especially with python when
I've been deceived by its apparent simplicity.
Then, later, the same happened with Javascript, of course.
And it's bound to happen again, as much as I'll try to be careful :-(
Jun 27 '08 #5
On Apr 29, 2:45*pm, Marco Mariani <ma...@sferacarta.comwrote:
Jens wrote:
You might have wrong assumptions from previous PHP experiences.
*>>'x'+4
Traceback (most recent call last):
* *File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
... and the non snobby answer would have been:
... *<dtml-var expr="_['prefix'] + str(_['sequence-item'])">

Sorry. Not trying to be snobbish, only in a hurry.

That answer would have been less useful, because there are TONS of
details in the python tutorial, that set the language apart from its
"scripting cousins".
Reading the syntax and thinking "yeah, got it, boring, next chapter" is
a common mistake I've also made sometime, especially with python when
I've been deceived by its apparent simplicity.
Then, later, the same happened with Javascript, of course.
And it's bound to happen again, as much as I'll try to be careful :-(
Hey no worriest. Is this the tutorial you're referring to:

http://docs.python.org/lib/typesmapping.html

Is there anything better? I miss the discussion and examples that
accompany
most entries in php.net.
Jun 27 '08 #6
On Apr 29, 2:45*pm, Marco Mariani <ma...@sferacarta.comwrote:
Jens wrote:
You might have wrong assumptions from previous PHP experiences.
*>>'x'+4
Traceback (most recent call last):
* *File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
... and the non snobby answer would have been:
... *<dtml-var expr="_['prefix'] + str(_['sequence-item'])">

Sorry. Not trying to be snobbish, only in a hurry.

That answer would have been less useful, because there are TONS of
details in the python tutorial, that set the language apart from its
"scripting cousins".
Reading the syntax and thinking "yeah, got it, boring, next chapter" is
a common mistake I've also made sometime, especially with python when
I've been deceived by its apparent simplicity.
Then, later, the same happened with Javascript, of course.
And it's bound to happen again, as much as I'll try to be careful :-(
Hey no worriest. Is this the tutorial you're referring to:

http://docs.python.org/lib/typesmapping.html

Is there anything better? I miss the discussion and examples that
accompany
most entries in php.net.
Jun 27 '08 #7
On Apr 29, 2:45*pm, Marco Mariani <ma...@sferacarta.comwrote:
Jens wrote:
You might have wrong assumptions from previous PHP experiences.
*>>'x'+4
Traceback (most recent call last):
* *File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
... and the non snobby answer would have been:
... *<dtml-var expr="_['prefix'] + str(_['sequence-item'])">

Sorry. Not trying to be snobbish, only in a hurry.

That answer would have been less useful, because there are TONS of
details in the python tutorial, that set the language apart from its
"scripting cousins".
Reading the syntax and thinking "yeah, got it, boring, next chapter" is
a common mistake I've also made sometime, especially with python when
I've been deceived by its apparent simplicity.
Then, later, the same happened with Javascript, of course.
And it's bound to happen again, as much as I'll try to be careful :-(
Hey no worriest. Is this the tutorial you're referring to:

http://docs.python.org/lib/typesmapping.html

Is there anything better? I miss the discussion and examples that
accompany
most entries in php.net.
Jun 27 '08 #8
Jens wrote:
Hey no worriest. Is this the tutorial you're referring to:

http://docs.python.org/lib/typesmapping.html

Is there anything better?
That's the library reference - the one to keep under the pillow.
It also documents the core -- i.e. builtin objects.
As for the language semantics, I suggest the whole of

http://docs.python.org/tut/

then a bit of

http://docs.python.org/ref/ref.html

A good alternative could be the new edition of Python in a Nutshell.
The author has a very clear style and leaves no corners uncovered.

I miss the discussion and examples that accompany most entries in php.net.
This is a post + comments about strong/weak typing, although not an
in-depth analyses.

http://www.artima.com/forums/flat.js...06&thread=7590

Jun 27 '08 #9
Jens schrieb:
Hello Everyone.

I am relatively new to Zope(using it for a work project) and I was
wondering if someone here could help me out or at least refer me to a
decent documentationg for Zope/DTML/Python (at the detail level of
php.net or Java API reference). http://www.zope.org/Documentation/Bo...ok/2_6Edition/
isn't really detailed enough for my taste. if it doesn't contain a
exhautive description of all available base classes it's simply no
good as a reference resource.
Are you forced to use DTML for the job? ZPT are far superior and easier
to work with, if you have to output HTML.

Christian

Jun 27 '08 #10
On Tuesday 29 April 2008, Jens wrote:
Hello Everyone.
<dtml-let prefix="'main'">
<ul>
<dtml-in expr="_.range(1,10)">
<li><dtml-var expr="_['prefix'] + _['sequence-item']"></li>
</dtml-in>
</ul>
</dtml-let>

I think you are going to really regret doing things this way, it is only going
to make your life much harder regardless of if you are using zpt or dtml by
doing stuff like this inside the template. The most correct way in zope to do
this is to use a python script object and have the dtml call that.

For example your python script would have

return ['main%s' % i for i in range(1,10)]

and your dtml would have

<ul>
<dtml-in path.to.you.script()>
<li><dtml-var sequence-item></li>
</ul>
This leads to much cleaner and easier to maintain systems.
Jun 27 '08 #11
On Apr 29, 3:16*pm, Christian Heimes <li...@cheimes.dewrote:
Jens schrieb:
Hello Everyone.
I am relatively new to Zope(using it for a work project) and I was
wondering if someone here could help me out or at least refer me to a
decent documentationg for Zope/DTML/Python (at the detail level of
php.net or Java API reference). *http://www.zope.org/Documentation/Bo...ok/2_6Edition/
isn't really detailed enough for my taste. if it doesn't contain a
exhautive description of all available base classes it's simply no
good as a reference resource.

Are you forced to use DTML for the job? ZPT are far superior and easier
to work with, if you have to output HTML.

Christian
For now, I have to use DTML as I am building on an existing solution.
I might look into ZPT's but I have limited time and theres no to time
at this point to redo everything as ZPT. In the long run we're
probably
going in a completely different direction, but that a another story.

I like some aspects of zope but I find that it ends up sitting between
two chairs. On one hand it want's to be a templating language which is
easy to get into for novices, but on the other hand you really have be
familiar with python to be able to so stuff thats only slighty more
complicated
then standard SSI. And don't get me started on the whole security
philosophy.

@Marco:
Thanks for the links :-) Python may be one of those really elegant
languages, but the reference is really sub standard. Checkout the
layout
of php.net for comparison. Think what you will about php, but the
reference
is excellent. For that matter check out msdn section on old-school
asp, or
even the common-lisp documentation(http://www.lispworks.com/
documentation/HyperSpec/Front/Contents.htm)
It's accessibility like that i'm missing. It shouldn't take 10 min
and a usenet
post to figure to how to basic stuff like string concatenation. And
theres
still plenty of unanswered questions after checking the reference:

- What is the exact definition of the operator e.g. op + (<string>,
<string>) -<string>, op + (<int>, <int>) : <int>, op + (<float...
- What is the exact operator precedence
- Why is it, when primitive data types seem to be objects (similar to
javascript), that type casting is done through build-in functions
rather than methods, e.g. String.toInt('5') or '5'.toInt() or x =
Integer.fromString('5').

Jun 27 '08 #12
On Apr 29, 3:16*pm, Christian Heimes <li...@cheimes.dewrote:
Jens schrieb:
Hello Everyone.
I am relatively new to Zope(using it for a work project) and I was
wondering if someone here could help me out or at least refer me to a
decent documentationg for Zope/DTML/Python (at the detail level of
php.net or Java API reference). *http://www.zope.org/Documentation/Bo...ok/2_6Edition/
isn't really detailed enough for my taste. if it doesn't contain a
exhautive description of all available base classes it's simply no
good as a reference resource.

Are you forced to use DTML for the job? ZPT are far superior and easier
to work with, if you have to output HTML.

Christian
For now, I have to use DTML as I am building on an existing solution.
I might look into ZPT's but I have limited time and theres no to time
at this point to redo everything as ZPT. In the long run we're
probably
going in a completely different direction, but that a another story.

I like some aspects of zope but I find that it ends up sitting between
two chairs. On one hand it want's to be a templating language which is
easy to get into for novices, but on the other hand you really have be
familiar with python to be able to so stuff thats only slighty more
complicated
then standard SSI. And don't get me started on the whole security
philosophy.

@Marco:
Thanks for the links :-) Python may be one of those really elegant
languages, but the reference is really sub standard. Checkout the
layout
of php.net for comparison. Think what you will about php, but the
reference
is excellent. For that matter check out msdn section on old-school
asp, or
even the common-lisp documentation(http://www.lispworks.com/
documentation/HyperSpec/Front/Contents.htm)
It's accessibility like that i'm missing. It shouldn't take 10 min
and a usenet
post to figure to how to basic stuff like string concatenation. And
theres
still plenty of unanswered questions after checking the reference:

- What is the exact definition of the operator e.g. op + (<string>,
<string>) -<string>, op + (<int>, <int>) : <int>, op + (<float...
- What is the exact operator precedence
- Why is it, when primitive data types seem to be objects (similar to
javascript), that type casting is done through build-in functions
rather than methods, e.g. String.toInt('5') or '5'.toInt() or x =
Integer.fromString('5').

Jun 27 '08 #13
Jens <je**@aggergren.dkwrites:
[...]
@Marco: Thanks for the links :-) Python may be one of those really
elegant languages, but the reference is really sub
standard. Checkout the layout of php.net for comparison. Think what
you will about php, but the reference is excellent. For that matter
check out msdn section on old-school asp, or even the common-lisp
documentation(http://www.lispworks.com/
documentation/HyperSpec/Front/Contents.htm)
Beauty is in the eye of the beholder. I'm used to the python doc
layout, and I can find my way round it pretty fast. What I like about
it is that it is organised thematically, so it is usually possible to
think your way to where the relevant documentation is. Moreover,
Python has a very useful help functionality:

* at the interactive prompt:
>>help(someobject)
help(somemodule)
Will give you lots of useful information

* At the shell prompt:

$ pydoc <keyword>
--documentation about keyword
It's accessibility like that i'm missing. It shouldn't take 10 min
and a usenet post to figure to how to basic stuff like string
concatenation.
It takes time to learn a language, and that includes learning how the
documentation is organised.
And theres still plenty of unanswered questions after checking the
reference:

- What is the exact definition of the operator e.g. op + (<string>,
<string>) -<string>, op + (<int>, <int>) : <int>, op + (<float...
The answers are here (in the library reference you checked):
http://docs.python.org/lib/types.html
- What is the exact operator precedence
That's a language feature, so it's in the *language* reference.
http://docs.python.org/ref/summary.html
- Why is it, when primitive data types seem to be objects (similar to
javascript), that type casting is done through build-in functions
rather than methods, e.g. String.toInt('5') or '5'.toInt() or x =
Integer.fromString('5').
Because Python is not Javascript?

In fact some are methods, e.g. str(x) is shorthand for x.__str__().

--
Arnaud
Jun 27 '08 #14
Jens wrote:
- Why is it, when primitive data types seem to be objects (similar to
javascript), that type casting is done through build-in functions
rather than methods, e.g. String.toInt('5') or '5'.toInt() or x =
Integer.fromString('5').
Mainly because it's much cleaner to do it the python way (absolutely
explicit), and just as clear or clearer what you are intending to do.
Digging a little deeper, you'll find that the built-in function "str,"
for example, actually calls object.__str__(). This is nice because it
allows any object class to define that method and have it work with
str() in a manner consistent across python. It preserves some amount of
uniformity.

The second example, x = Integer.fromString('5') demonstrates a huge
weakness in Java. In python, rather than asking an integer object to
convert from a limited selection of other objects, python works the
other way, asking objects to convert themselves to integers (if they
can). We don't worry about the size of integers, since python's
integers are auto-sizing. So any object that implements the __int__()
method can be used with the classic "int()" built-in function. The same
goes for __float__ and float().

Little things like this really make me happy about how python does
things generally. I think much of how Java works with Integer and
String (as you describe above) is because Java has primitive types
(which aren't objects at all) and then boxed objects around the
primitive types. Python eliminates this idea, and makes everything,
even "simple" types objects.

Now sure python could just say always call the "int()" or "float()" or
"str()" method on objects to produce those respective conversions. But
using a combination of a built-in language function and a specialized,
reserved class method name, allows a lot of flexibility without
infringing on the programmer's need to use method names like "int,
float, or str" if he or she so desired.

Jun 27 '08 #15
Michael Torrie wrote:
The second example, x = Integer.fromString('5') demonstrates a huge
weakness in Java.
Ahem. Javascript. Sorry.
Jun 27 '08 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Holger Butschek | last post by:
Hy folks, I have a problem in Zope (DTML). I know, that it's a very simple problem, but I'm quite new to Zope. I want to check, if a sequence-item of a sql-statement is in a list called...
2
by: Junkmail | last post by:
I've been playing with Zope for about a year and took the plunge last week into making a product. To keep it simple I used a ZClass to wrap an external method. My ZClass works and returns the...
4
by: Avery Warren | last post by:
I am investigating converting a wiki site to plone. I am having a lot of difficulty finding good documentation programmatically accessing the ZODB API. A lot of the user feedback is centered on...
3
by: astarocean | last post by:
i'm using maildrophost to sendmail and wrote a script for it when the script is called directly from web request , a letter geneated with right things but when the script is called from...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.