Re: [Zope] DTML Call Fails

2006-10-24 Thread Tino Wildenhain

[EMAIL PROTECTED] schrieb:
Changing the dash to an underscore in the variable name solved the 
problem.


I'm quite sure you could solve it even better - if we would know
where these variables come from and what their meaning is.

I suspect some kind of form?

Regards
Tino Wildenhain
___
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] DTML Call Fails

2006-10-24 Thread Tino Wildenhain

[EMAIL PROTECTED] schrieb:
Hi Tino.  Yes, that is correct. This application has variables named 
like:


'AR-DA-08'


Not very clever.


This also fails in a Page Template:


   


you still have to quote if you mean the variable with that
weird name. Otherwise its an expression in python.

_['AR-DA-08'] could work in DTML... but lets better forget
that ;) Where does your variable live? In Request maybe?




With the error:

Compilation failed
TAL.TALDefs.TALError: Python expression error:
invalid token (Python expression "data.set('AR-DA-08',AR-DA-08)", 
line 1) in expression "python: data.set('AR


TAL??



Yet this works:


   


So you are saying the interpreter is seeing the '-' as a minus? Why 
would it work in one case and not the other?


See Andrew's note on ocal numbers.



Could the minus be escaped somehow?


No, but see above.

Could you please escape the horribly code + template
mixing with DTML? ;) See the zope book for python scripts.
(After all in DTML "expressions" its already python code,
so why not write just python code and skip all that
 stuff around it you dont need anyway?

Regards
Tino Wildenhain
___
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] DTML Call Fails

2006-10-24 Thread hpinson
Changing the dash to an underscore in the variable name solved the 
problem.


-- 
Harlow Pinson
Indepth Learning
Email: [EMAIL PROTECTED]
Phone: 505 994-2135
Fax: 505 994-3603

___
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] DTML Call Fails

2006-10-24 Thread hpinson
Yep, changing to a underscore from a dash does the trick.

Thanks to everyone who helped me understand this.


-- 
Harlow Pinson
Indepth Learning
Email: [EMAIL PROTECTED]
Phone: 505 994-2135
Fax: 505 994-3603

___
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] DTML Call Fails

2006-10-24 Thread David H

[EMAIL PROTECTED] wrote:


A little bit of legacy DTML fun here... Zope 2.9.3

On save of a DTML Method, why would this dtml-call fail:


 


With the error: 


"Expression (Python) Syntax error: invalid token"

Whereas this works fine:


 


Any insight is appreciated.



 


hpinson,

Maybe you can get away with something like _['AR-DA-07']  or maybe 
_.getitem('AR_DA-07')?


David
___
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] DTML Call Fails

2006-10-24 Thread Jonathan


- Original Message - 
From: <[EMAIL PROTECTED]>

To: 
Sent: Tuesday, October 24, 2006 1:04 PM
Subject: Re: [Zope] DTML Call Fails



Hi Tino.  Yes, that is correct. This application has variables named
like:

'AR-DA-08'

This also fails in a Page Template:


  


With the error:

Compilation failed
TAL.TALDefs.TALError: Python expression error:
invalid token (Python expression "data.set('AR-DA-08',AR-DA-08)",
line 1) in expression "python: data.set('AR

Yet this works:


  


So you are saying the interpreter is seeing the '-' as a minus? Why
would it work in one case and not the other?



Two possibilities that I can think of:

1) you have a variable called AR-DA-08 and do not have a variable called 
AR-DA-07


2) you have a variable called AR (and possibly another variable called DA), 
which when evaluated as a mathematical expression (AR minus DA - 08) 
provides a result, but when 07 is subtracted, an invalid result is obtained.


But, as others have noted, this does not appear to be what you are looking 
to accomplish!



Jonathan


___
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] DTML Call Fails

2006-10-24 Thread hpinson
Hi Tino.  Yes, that is correct. This application has variables named 
like:

'AR-DA-08'

This also fails in a Page Template:


   


With the error:

Compilation failed
TAL.TALDefs.TALError: Python expression error:
invalid token (Python expression "data.set('AR-DA-08',AR-DA-08)", 
line 1) in expression "python: data.set('AR

Yet this works:


   


So you are saying the interpreter is seeing the '-' as a minus? Why 
would it work in one case and not the other?

Could the minus be escaped somehow?




-- 
Harlow Pinson
Indepth Learning
Email: [EMAIL PROTECTED]
Phone: 505 994-2135
Fax: 505 994-3603

___
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] DTML Call Fails

2006-10-24 Thread Andrew Milton
+---[ Tino Wildenhain ]--
| [EMAIL PROTECTED] schrieb:
| >A little bit of legacy DTML fun here... Zope 2.9.3
| >
| >On save of a DTML Method, why would this dtml-call fail:
| >
| >
| >  
| >
| >
| >With the error: 
| >
| >"Expression (Python) Syntax error: invalid token"
| >
| >Whereas this works fine:
| >
| >
| >  
| >
| >
| I doubt any of that really "works". So you happen
| to have the variables named "AR" and "DA" defined
| as numerical values somewhere? Otherwise the expression
| makes no sense at all. The leading 0 in 08 and 07 indicates
| you might have a completely other illusion on what's going on.

Apart from all of that;

A leading 0 indicates an octal number. 08 is not a valid octal number, but,
I'll just agree with Tino here, I don't think you know what you're trying to
do. I don't think you want.. AR minus DA minus 8 as the value.

-- 
Andrew Milton
[EMAIL PROTECTED]
___
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] DTML Call Fails

2006-10-24 Thread Alexis Roda

En/na [EMAIL PROTECTED] ha escrit:

A little bit of legacy DTML fun here... Zope 2.9.3

On save of a DTML Method, why would this dtml-call fail:


  



AR - DA - 08
   ^ octal literal


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] DTML Call Fails

2006-10-24 Thread Tino Wildenhain

[EMAIL PROTECTED] schrieb:

A little bit of legacy DTML fun here... Zope 2.9.3

On save of a DTML Method, why would this dtml-call fail:


  


With the error: 


"Expression (Python) Syntax error: invalid token"

Whereas this works fine:


  



I doubt any of that really "works". So you happen
to have the variables named "AR" and "DA" defined
as numerical values somewhere? Otherwise the expression
makes no sense at all. The leading 0 in 08 and 07 indicates
you might have a completely other illusion on what's going on.

Any reason you cannot write in a python script something like:

REQUEST.SESSION.set('some_resonable_named_variable','AR-DA-07') ?

Could you explain in plain english what your final goal
of your construction is?

Regards
Tino Wildenhain
___
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] DTML Call Fails

2006-10-24 Thread hpinson
A little bit of legacy DTML fun here... Zope 2.9.3

On save of a DTML Method, why would this dtml-call fail:


  


With the error: 

"Expression (Python) Syntax error: invalid token"

Whereas this works fine:


  


Any insight is appreciated.



-- 
Harlow Pinson
Indepth Learning
Email: [EMAIL PROTECTED]
Phone: 505 994-2135
Fax: 505 994-3603

___
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] Re: Accessing ZPT properties from another page

2006-10-24 Thread Michael Haubenwallner

Dyyryath wrote:

I've got a page template that I'd like to display some information
contained in the properties of another page. Can I do this?

I'd like to do something like:

 

Though that obviously doesn't work. :)



 

should work without problems.

Hth,
Michael

--
http://zope.org/Members/d2m
http://planetzope.org

___
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 ZPT properties from another page

2006-10-24 Thread Dyyryath

I've got a page template that I'd like to display some information
contained in the properties of another page. Can I do this?

I'd like to do something like:

 

Though that obviously doesn't work. :)

Does anyone know if something along these lines is possible?
___
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] Re: Uploading photos into newly created objects

2006-10-24 Thread Peter Bengtsson



Tres Seaver wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Peter Bengtsson wrote:

I'm trying to upload a Photo into a newly create object in my product
class. The code looks something like this::

def manage_addSomething(dispatcher, id, title, photofile):
destination = dispatcher.Destination()
instance = Something(id, title)
destination._setObject(id, instance)
obj = destination._getOb(id)
# at this point, is 'obj' wrapped in aq stuff???

_adder = obj.manage_addProduct['Photo'].manage_addPhoto
_adder(id='', title='', file=photofile)

class Something(Folder):
def __init__(self, id, title):
self.id = id
self.title = title


The error I get is:
  File "/home/peterbe/zope/zope285/Products/Photo/Photo.py", line 664,
in manage_addPhoto
dest._setObject(id, photo)
AttributeError: _setObject

I'm using Photo product 1.2.3 but I don't think it matters if it's a
Photo I'm trying to add or any other product.

If I add the photo after the transaction has been completed in a
separate request it works fine to add the photo to the recently created
object.

Any idea?


I don't actually use the 'Destination' bit, ever (in fact, I don't
remember ever even seeing it used).  By inspection (in
'App.FacdtoryDispatcher'), it looks as though the metho returns an
unwrapped object, which would be a Bad Thing.



Using just the dispatcher instead of dispatcher.Destination() didn't 
help but if you recommend, I'll stop using the Destination() thing from 
now on.


The reason _setObject() didn't work was really silly and even embarrasing.
The base class I used was NOT FOLDERISH! :)
In my example I used "Folder" as the base class. In reality I used a 
more oddly named class which confused me.
This happened because it was decided later to add photos into these kind 
of objects.


Thanks for the help Tres!

--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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 )


[Zope] Re: Uploading photos into newly created objects

2006-10-24 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Peter Bengtsson wrote:
> I'm trying to upload a Photo into a newly create object in my product
> class. The code looks something like this::
> 
> def manage_addSomething(dispatcher, id, title, photofile):
> destination = dispatcher.Destination()
> instance = Something(id, title)
> destination._setObject(id, instance)
> obj = destination._getOb(id)
> # at this point, is 'obj' wrapped in aq stuff???
> 
> _adder = obj.manage_addProduct['Photo'].manage_addPhoto
> _adder(id='', title='', file=photofile)
> 
> class Something(Folder):
> def __init__(self, id, title):
> self.id = id
> self.title = title
> 
> 
> The error I get is:
>   File "/home/peterbe/zope/zope285/Products/Photo/Photo.py", line 664,
> in manage_addPhoto
> dest._setObject(id, photo)
> AttributeError: _setObject
> 
> I'm using Photo product 1.2.3 but I don't think it matters if it's a
> Photo I'm trying to add or any other product.
> 
> If I add the photo after the transaction has been completed in a
> separate request it works fine to add the photo to the recently created
> object.
> 
> Any idea?

I don't actually use the 'Destination' bit, ever (in fact, I don't
remember ever even seeing it used).  By inspection (in
'App.FacdtoryDispatcher'), it looks as though the metho returns an
unwrapped object, which would be a Bad Thing.

Can you modify the factory to just call '._setObject' on the dispatcher?
Also, I would probably just import the Photo class directly, rather than
setting up another dispatcher layer.  E.g., ::

 def manage_addSomething(dispatcher, id, title, photofile):
 from Products.whatever.photo import Photo
 instance = Something(id, title)
 dispatcher._setObject(id, instance)
 obj = dispatcher._getOb(id)

 photo = Photo(id='photo', title='', file=photofile)
 ob._setObject('photo', photo)



Tres.
- --
===
Tres Seaver  +1 202-558-7113  [EMAIL PROTECTED]
Palladion Software   "Excellence by Design"http://palladion.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFPfVK+gerLs4ltQ4RApPbAJ9rUVyhfFJqMdh1s6eaBTWSYHPUkACfUT3v
hK6ZaweTGFwrfKgtmuB3F3Y=
=6GIq
-END 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 )


[Zope] Uploading photos into newly created objects

2006-10-24 Thread Peter Bengtsson
I'm trying to upload a Photo into a newly create object in my product 
class. The code looks something like this::


def manage_addSomething(dispatcher, id, title, photofile):
destination = dispatcher.Destination()
instance = Something(id, title)
destination._setObject(id, instance)
obj = destination._getOb(id)
# at this point, is 'obj' wrapped in aq stuff???

_adder = obj.manage_addProduct['Photo'].manage_addPhoto
_adder(id='', title='', file=photofile)

class Something(Folder):
def __init__(self, id, title):
self.id = id
self.title = title


The error I get is:
  File "/home/peterbe/zope/zope285/Products/Photo/Photo.py", line 664, 
in manage_addPhoto

dest._setObject(id, photo)
AttributeError: _setObject

I'm using Photo product 1.2.3 but I don't think it matters if it's a 
Photo I'm trying to add or any other product.


If I add the photo after the transaction has been completed in a 
separate request it works fine to add the photo to the recently created 
object.


Any idea?

--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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 )


Re: [Zope] ZSQL Method's Precision

2006-10-24 Thread Tino Wildenhain

Maciej Wisniowski schrieb:



In a PostgreSQL DB I have a Numeric data type with a precision of two
decimal places. If I have 1.33 in as the result from my query, it's
everything is good. However, if I have 1.30 it reduces the precision
to one decimal place and I get 1.3. Not so good when dealing with
currency ( I don't want to use the money data dype ).

Any ideas on how I can get my ZSQL method to keep two decimal places?

As others said it's a matter of displaying. You say that you don't want
to use money datatype but keep in mind that postgre adapter
is able to use Python's Decimal datatype for money values (in python2.3
you need additional module decimal.py from Python 2.4 to enable it)
which may give you necessary precision for financial operations and is
able to store really big numbers.


The adaptor should use it for numeric data as well (hey, hence the name 
;) Use of the deprecated money datatype in postgres isnt recommended.

(And its superceeded by numeric anyway)

Regards
Tino Wildenhain

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