[Zope-dev] Re: [Interested?] New use for Zope+CMF+Archetypes -- startup time improvements

2005-05-14 Thread Paul Everitt
This is really interesting!  A year ago I put Python + Zope on a USB 
key, just for fun.  It would barely fit so I looked at zip techniques, 
and never could figure out how to get ZPTs etc. to load from a ZIP.

How did you do that part?
--Paul
Dieter Maurer wrote:
Dear Zope developers,
we have used Zope+CMF+Archetypes in a new way -- not
as a Web Application framework but as a framework for
desktop applications that share a large part of their
functionality with online applications (implemented with Zope+CMF+Archetypes).
A major stumbling block has been Zope's incredibly high startup
time. We observerd times in the order of a minute on computers
with either slow CPU or slow IO. This may be acceptable for
a Web server but is prohibitive for a desktop application -- especially
as the predecessor application started within a few seconds.
To overcome this obstacle, we tweaked Zope and fixed Python's import
mechanism such that Zope now starts either out of a ZIP archive
or as a frozen application. These measures had the following results.
  Startup times on a mid range computer (AMD Athon 1.4 GHz; 512 MB memory)
  with a standard IDE disk.
Cold start  Warm start
(after computer startup)(most files in OS cache)
File system13s5s
ZIP archive 8s4s
Frozen  5s3s
In more details, we did:
  *  implement a package for a new kind of urls pypackage:
 for package relative access to resources.
 The package monkey patches Python's open, os.listdir,
 os.stat to provide transparent access to
 pypackage: identified resources.
 It currently support package relative access for
 packages loaded from the file system, from a ZIP
 archive and from the executable itself (i.e. frozen packages).
 In the last case, the resources are in a separate ZIP
 archive.
 This package might be interesting for Python as a whole
 as it is not Zope specific.
  *  implement a shared object importer to be used
 as a Python meta_path hook.
 This importer allows to load shared objects into the context
 of a parent package (such as e.g. ZODB.TimeStamp) although
 the shared object is not located inside the package's source
 (ZIP archive or executable).
  *  fix about 70 occurrences in Zope code where
 package relative access was implemented by dirname(__file__)
 to consistenty use package_home.
  *  modify about a dozen places in Zope+CMF to use
 pypackage: and cope with __path__ not being a list
 for frozen packages
  *  fix a few products (Archetypes and friends, TextIndexNG2,
 PlacelessTranslationService, ...) to use
 package_home (rather than dirname(__file__)) and
 not to change the current working directory (which obviously
 would fail for destinationsbe in a ZIP archive
 or the executable).
  *  implement lazy loading of ImageFiles to
 reduce the risk of recursive imports (and reduce startup time).
  *  support lazy product initialization
  *  support configuration from a pickle file (to avoid
 expensive parsing of the schema and configuration files).
 The pickle is used as a configuration cache.
  *  fixed Python's import mechanism not to treat ZIP
 archives as a directory when the archive could not
 find a module.
If you were *really* interested in these startup time improvements,
I could provide patches which might be integrated
in the Zope core for e.g. Zope 2.9.

___
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] [Interested?] New use for Zope+CMF+Archetypes -- startup time improvements

2005-05-14 Thread Andreas Jung

--On Freitag, 13. Mai 2005 19:26 Uhr +0200 Dieter Maurer 
[EMAIL PROTECTED] wrote:

If you were *really* interested in these startup time improvements,
I could provide patches which might be integrated
in the Zope core for e.g. Zope 2.9.
Although I already worked with pypackage my questions:  is it an optional
feature or will pypackage take control over all and everything? Products
using __path__ or changing the current directory need to be fixed, right?
I think 2.9 would be a good target. If there is common agreement that
it should go into the core (+1 from my side) then please wait with
submitting patches until we have cut a release branch for Zope 2.8...then
the trunk can be used for new features for Zope 2.9.
Andreas



pgpZj4jMgFUOw.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 )


[Zope-dev] inituser problem

2005-05-14 Thread Chris Withers
Hi,
I have a problem with the code in 
AccessControl.User.UserFolder._createInitialUser.

It creates a user under what I feel are fairly bizarre circumstances.
I feel it should simply use inituser if it's there and the user in it 
doesn't already exist in the root acl_users.

Either that, or it should overwrite any user if the inituser file exists.
The weird special case of one user being in the root acl_users seems 
extremely counterintuitive.

What do other people feel?
cheers,
Chris
--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
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] [Interested?] New use for Zope+CMF+Archetypes -- startup time improvements

2005-05-14 Thread Dieter Maurer
Andreas Jung wrote at 2005-5-14 11:00 +0200:
 ...
Although I already worked with pypackage my questions:  is it an optional
feature or will pypackage take control over all and everything?

Provided that any access to a package relative resource
is converted from dirname(__file__) to package_home
logic to use or not use pypackage could be localized in package_home
and (maybe) OFS.Application.get_products.

Products
using __path__ or changing the current directory need to be fixed, right?

__path__ is a string in a frozen application.
It is likely that any software part that uses __path__
currently asumes it to be a list.

Any product that tries the change the current directory to 
lie in a ZIP archive or execatable will observe that this
is impossible.

-- 
Dieter
___
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] dollars-and-cents display fails

2005-05-14 Thread Greg Fischer
http://dev.mysql.com/doc/mysql/en/numeric-type-overview.html
That's it right there!  Before 5.0.3, they were unpacked, meaning
saved like a char.  Now they are packed, fixed point numbers.  This is
screwing up the python functions for fmt.

Well, I was trying to NOT redo all that code, but looks like I will
have to if I want to run the new mysql.  I have tons of reports using
dtml and fmt.   I think I'll stick with 5.0.0 for now until I have
time for that. (spent it all trying to figure out where my problem
was!)

Though, I might just switch to Firebird if I have to do some code
changing on my app anyway.  It's a bit more mature than Mysql's new
stuff. (considering it's still in beta)  Mysql is just so easy.

-



On 5/13/05, Greg Fischer [EMAIL PROTECTED] wrote:
 ok, lots of testing, and I have found that this is related to Mysql 5.0.4.
 
 I compiled and installed Mysql 5.0.0 and the problem does not exist. I
 guess means that it started in 5.0.1 or higher.  I read through the
 change logs and saw a couple of items related to float values on 5.0.3
 and 5.0.4, but I dont have any idea if those are causing the issue.
 
 So, I dont know where to go next.  I can post this info on the mysql
 lists, but I only see the problem in Zope.  Python, or at least the
 MysqlDA, retrieves the value just fine.  I only get the problem if
 using a fmt option on Zope.
 Here's a recap:
 -- I can use Zope 2.7.4 with Mysql 5.0.4 on Windows (using Egenix ODBC
 DA) and there is no issue.
 -- I can use Zope 2.7.3 with Mysql 5.0.0 on Linux (Zmysqlda 2.0.9b3,
 Mysql-python1.2.0,Python 2.3.4) and there is no issue.
 -- When using Zope 2.7.3 with same setup as before, but with Mysql
 5.0.4, problem exists.
 -- Zope 2.7.6 has same issue.
 
 I tried doing a simple dtml:
 dtml-call REQUEST.set('dec',10.23)
 dtml-var decbr
 dtml-var dec fmt=dollars-and-centsbr
 
 This works just fine.  But when pulling 'dec' from Mysql, dtml wont
 render it if using fmt.
 
 I dont have to use Mysql 5.x.  It's just that I already have the app
 running on it, and I'd like to start testing the stored procedures and
 other useful features.
 
 Sorry for the long post.  I just want to give as much info as
 possible.  Thank you for any help!
 
 Greg
 
 
 On 5/12/05, Greg Fischer [EMAIL PROTECTED] wrote:
  Oh, it is a decimal(15,2) column.  (all of them are)  Just thought I'd
  mention everything too... Running Ubuntu 5.0.4, has the Python 2.4.1
  package installed, but I have Python 2.3.4 compiled and installed
  separately for Zope.  Zope is compiled with the --with-python flag.
 
  Just tried your suggestion, commenting the 'conv[FIELD_TYPE.DECIMAL] =
  float' line, restart Zope, still have the issue.
 
  So, I have the older Python, which I used to have.  I could try
  loading an older Zope, but what I might try is loading the MySQL
  5.0.0, which I had before.  At least I can hopefully find out which is
  causing my problem.  However, I have Zope 2.7.4 with MySQL 5.0.4 and
  it works fine, but on Windows using the Egenix adapter.  Now, I cant
  remember what I had for the mysql-python version, it's on the other
  server at my clients site. (cant get to it right now)
 
  I guess one of my main questions too is, would Zope be getting
  anything from the 2.4.1 Ubuntu packages that are installed if I
  compiled it with the 2.3.4 python?  (mysql-python is installed
  correctly on 2.3.4 too)
 
  On 5/12/05, Andy Dustman [EMAIL PROTECTED] wrote:
   On 5/12/05, Greg Fischer [EMAIL PROTECTED] wrote:
Thanks Andy.  I do have those versions.  But Python is 2.3.5 because I
didnt want to move to 2.4.x as I think I read something in the README
for Zope stating it was not tested for compatibility. (right?)  I
guess my thought is... Does 2.3.5 have the same issue as 2.4 regarding
the decimals?  For now, I am just going to setup 2.3.4 and run with
it.
  
   The Python decimal type is new in 2.4.
  
   I don't think you've actually said whether or not you are actually
   using a DECIMAL column.
  
   I had forgotten that ZMySQLDA-2.0.9b3 always returns DECIMAL columns
   as Python float. If you look in ZMySQLDA/db.py, you can see where it
   does this in the DB class. You could try commenting this line out,
   which will cause it to be returned as a string, and restarting Zope.
   It's something to try, at least.
   --
   Computer interfaces should never be made of meat.
   http://www.terrybisson.com/meat.html
   ___
   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 )
  
 
  --
  Greg Fischer
  1st Byte Solutions
  http://www.1stbyte.com
 
 
 --
 Greg Fischer
 1st Byte Solutions
 http://www.1stbyte.com
 


-- 
Greg Fischer
1st Byte Solutions
http://www.1stbyte.com

Re: [Zope] dollars-and-cents display fails

2005-05-14 Thread Greg Fischer
OK well, I fixed it. At least on My zope server.

The function for dollars-and-cents in DT_Var.py was like this:
def dollars_and_cents(v, name='(Unknown name)', md={}):
   try: return $%.2f % v
   except: return ''

I changed it to this:
def dollars_and_cents(v, name='(Unknown name)', md={}):
   try: return $%.2f % float(v)
   except: return ''

Problem solved.  I just tested it in Mysql 5.0.0 and 5.0.4, and it
works great.  I'll setup the rest of my app and test some more to make
sure I am not missing something. If there are any problems I'll post
more details.

Is this something that could be posted on the Zope Collector?  It
should probably be tested on lots of other Db's I bet.  But, one
question I have, should this be handled in the Mysql DA?

On 5/13/05, Greg Fischer [EMAIL PROTECTED] wrote:
 http://dev.mysql.com/doc/mysql/en/numeric-type-overview.html
 That's it right there!  Before 5.0.3, they were unpacked, meaning
 saved like a char.  Now they are packed, fixed point numbers.  This is
 screwing up the python functions for fmt.
 
 Well, I was trying to NOT redo all that code, but looks like I will
 have to if I want to run the new mysql.  I have tons of reports using
 dtml and fmt.   I think I'll stick with 5.0.0 for now until I have
 time for that. (spent it all trying to figure out where my problem
 was!)
 
 Though, I might just switch to Firebird if I have to do some code
 changing on my app anyway.  It's a bit more mature than Mysql's new
 stuff. (considering it's still in beta)  Mysql is just so easy.
 
 -
 
 
 On 5/13/05, Greg Fischer [EMAIL PROTECTED] wrote:
  ok, lots of testing, and I have found that this is related to Mysql 5.0.4.
 
  I compiled and installed Mysql 5.0.0 and the problem does not exist. I
  guess means that it started in 5.0.1 or higher.  I read through the
  change logs and saw a couple of items related to float values on 5.0.3
  and 5.0.4, but I dont have any idea if those are causing the issue.
 
  So, I dont know where to go next.  I can post this info on the mysql
  lists, but I only see the problem in Zope.  Python, or at least the
  MysqlDA, retrieves the value just fine.  I only get the problem if
  using a fmt option on Zope.
  Here's a recap:
  -- I can use Zope 2.7.4 with Mysql 5.0.4 on Windows (using Egenix ODBC
  DA) and there is no issue.
  -- I can use Zope 2.7.3 with Mysql 5.0.0 on Linux (Zmysqlda 2.0.9b3,
  Mysql-python1.2.0,Python 2.3.4) and there is no issue.
  -- When using Zope 2.7.3 with same setup as before, but with Mysql
  5.0.4, problem exists.
  -- Zope 2.7.6 has same issue.
 
  I tried doing a simple dtml:
  dtml-call REQUEST.set('dec',10.23)
  dtml-var decbr
  dtml-var dec fmt=dollars-and-centsbr
 
  This works just fine.  But when pulling 'dec' from Mysql, dtml wont
  render it if using fmt.
 
  I dont have to use Mysql 5.x.  It's just that I already have the app
  running on it, and I'd like to start testing the stored procedures and
  other useful features.
 
  Sorry for the long post.  I just want to give as much info as
  possible.  Thank you for any help!
 
  Greg
 
 
  On 5/12/05, Greg Fischer [EMAIL PROTECTED] wrote:
   Oh, it is a decimal(15,2) column.  (all of them are)  Just thought I'd
   mention everything too... Running Ubuntu 5.0.4, has the Python 2.4.1
   package installed, but I have Python 2.3.4 compiled and installed
   separately for Zope.  Zope is compiled with the --with-python flag.
  
   Just tried your suggestion, commenting the 'conv[FIELD_TYPE.DECIMAL] =
   float' line, restart Zope, still have the issue.
  
   So, I have the older Python, which I used to have.  I could try
   loading an older Zope, but what I might try is loading the MySQL
   5.0.0, which I had before.  At least I can hopefully find out which is
   causing my problem.  However, I have Zope 2.7.4 with MySQL 5.0.4 and
   it works fine, but on Windows using the Egenix adapter.  Now, I cant
   remember what I had for the mysql-python version, it's on the other
   server at my clients site. (cant get to it right now)
  
   I guess one of my main questions too is, would Zope be getting
   anything from the 2.4.1 Ubuntu packages that are installed if I
   compiled it with the 2.3.4 python?  (mysql-python is installed
   correctly on 2.3.4 too)
  
   On 5/12/05, Andy Dustman [EMAIL PROTECTED] wrote:
On 5/12/05, Greg Fischer [EMAIL PROTECTED] wrote:
 Thanks Andy.  I do have those versions.  But Python is 2.3.5 because I
 didnt want to move to 2.4.x as I think I read something in the README
 for Zope stating it was not tested for compatibility. (right?)  I
 guess my thought is... Does 2.3.5 have the same issue as 2.4 regarding
 the decimals?  For now, I am just going to setup 2.3.4 and run with
 it.
   
The Python decimal type is new in 2.4.
   
I don't think you've actually said whether or not you are actually
using a DECIMAL column.
   
I had forgotten that ZMySQLDA-2.0.9b3 always returns DECIMAL columns
 

Re[2]: [Zope] assertion error

2005-05-14 Thread Denis Mishunoff
Hello, Dieter.

You wrote 13  2005 ., 22:21:49:

 Looks as if your catalog were very old and still has entries
 with request relative resolution.

 Replace assert(obj) with

 if not obj:
# here the assert would fail
# determine its path for later analysis
path = brain.getPath()
# ensure, you can see path somehow
 else:
# here the assert would pass
...

 With this information, you can try to analyse the problem
 in an interactive Python interpreter.

Thanks, Dieter.
I tried your advice and made the following code:

 if not obj:
# here the assert would fail
# determine its path for later analysis
path = brain.getPath()
tagencies.append(path)
 else:
# here the assert would pass
...

To have either object or brain's path in output (tagencies list).
The most interesting is that accessing via name I've got objects and
paths, but accessing via IP I've got ONLY object - no paths...

Then I checked the paths I got for presence of objects on them.
Objects are there, so I decided to use

tagencies.append(portal.restrictedTraverse(path))

in code (portal variable was defined), but got the sign in screen :(
Maybe it's because I have not so usual structure of Instance? I have
ZOPE-ROOT
- Folder1
  - Plone site

I'm totally confused and don't know what to do with all this. Please
advise.



-- 
  Best regards,
 Denis Mishunoff  mailto:[EMAIL PROTECTED]
  http://plonetarium.objectis.net

___
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: How do I logout using DTML

2005-05-14 Thread Josef Meile
Dear Allen,
please post your replies to the newsgroup as well.
I tried both yours and the dtml-raise methods, but both of them didn't 
work.
With yours I redirect myself out but I still logged in.
With dtml-raise Unathorized, it popped out an password query box and 
kept ask me to input password for three time and went to an error page 
and I'm still logged in as well.

Did I do anything wrong??

The dtml-raise should work. I don't know why isn't workning for you.
Perhaps you stored the password in the browser or something like that,
try deleting the stored passwords. About the popup window and the error
message, as Jens post in the other message you started, this is the
normal behaviour and can't be avoided. One way I can think about solving
this behaviour is storing a hidden input field like go_to_logout, then
check the request in the standard_error_message when an unauthorized
exception occures and close the window with javascript if such variable
is found. I know that zope can access the variables on the request after
an error happens, but I'm not I'm not sure if this is going to work with
an UnauthorisedException.
For the second approach with the authorization cookies, you first have
to make sure that you have installed CookieCrumbler and that you have
created an instance of it. After doing this, the expiration cookies
method should work. Once you install CookieCrumbler, you can modify the
default login forms if you want.
Regards,
Josef
___
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] [ANN] TextIndexNG 3.0.0 final released

2005-05-14 Thread Andreas Jung
I am pleased to announce the final release of TextIndexNG V 3.0.0.
TextIndexNG V 3 is a complete new implementation based on Zope 3 
technologies
and can be used both in Zope 2.8 or 2.7 (with Five) or in Zope 3.

What's new?
- multi-field indexing and query support
- multi-lingual support
- configurable converters (through ZCML)
- new indexing API (allowing you to hook your custom content types with 
TextIndexNG
  through Zope 3 adapters).

Requirements:
 - Zope 2.8 or Zope 2.7 (+ Five) or Zope 3 (Zope 3 has nothing like 
catalogs yet)

 TextIndexNG V3 will *not* run with bare Zope 2.7 installations without 
Five
 (and this will not be changed in the future).

Download:
 http://sf.net/projects/textindexng
For installation and documentation issues refer to doc/README.txt from the 
archive.
It's basically the same procedure as with former versions except you *need* 
to
recompile the extension modules. Windows binaries of the required extension 
modules
are currently not available (any volunteers?).

TextIndexNG V 3 is published under the GPL.
Andreas Jung
   ---
  -   Andreas JungZOPYX Software Development and Consulting -
 -   E-mail: [EMAIL PROTECTED]   Web: www.zopyx.com   -
  ---   


pgprRd0SzJFu8.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] dollars-and-cents display fails

2005-05-14 Thread Tino Wildenhain
Am Freitag, den 13.05.2005, 23:42 -0700 schrieb Greg Fischer:
 http://dev.mysql.com/doc/mysql/en/numeric-type-overview.html
 That's it right there!  Before 5.0.3, they were unpacked, meaning
 saved like a char.  Now they are packed, fixed point numbers.  This is
 screwing up the python functions for fmt.
 
 Well, I was trying to NOT redo all that code, but looks like I will
 have to if I want to run the new mysql.  I have tons of reports using
 dtml and fmt.   I think I'll stick with 5.0.0 for now until I have
 time for that. (spent it all trying to figure out where my problem
 was!)
 
 Though, I might just switch to Firebird if I have to do some code
 changing on my app anyway.  It's a bit more mature than Mysql's new
 stuff. (considering it's still in beta)  Mysql is just so easy.

Maybe postgres is an option too? At least its a bit more
mature and doesnt have problems with high concurrency.



___
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] URL rewriting (VHM and browser Id manager)

2005-05-14 Thread Dieter Maurer
Victor Kolisinski wrote at 2005-5-13 10:31 -0700:
 ...
URL is generated with _ZopeId but when request come to

ZServer VHM mapping doesnt works correct. Maybe i
don't know to make correct mapping

BUT today I make simple example:
VHM mapping = localhost:8080/test/VirtualHostRoot/

In test folder i have index_html page :

html
  head   
  /head
  body
This is Page Template em
tal:content=template/idtemplate id/em.
a href= tal:attributes=href
here/absolute_urlVisit me again /a
  /body
/html

In this simple example BIM URL rewriting doesn't
works.
It works only if VHM mapping is empty.

Is it posible that VHM is buggy in this case.

It is possible as I explained in an earlier message
(conflict for BeforeTraverse hook).

At your place, I would use debugging to find out
what precisely goes on.

When you plan to use Zope for various projects,
you may be able to convince your boss that
the investment in a commercial Python IDE with
support for Zope debugging will be worth.
Colleagues of mine are quite satisfied with WingIDE.

Personally, I am using the archaic pdb (which comes with Python).

 ...
P.S Do I need to start new thread with example like
this.

No, as long as the subject still fits.

-- 
Dieter
___
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] Float object not callable (newbie question)

2005-05-14 Thread Tino Wildenhain
Am Freitag, den 13.05.2005, 16:06 +0100 schrieb Paul Hendrick:
 hi all,
 I'm trying to write a simple app which takes a name, bank balance,
 interest rate and returns the balance once 1 years interest has been
 added. I'm getting the error that float object is not callable. 
 i can't figure out where i'm going wrong :S
 
 my code is below(getDetails, showDetails,doStuff.py), thanks for any
 input!
 paul.
 
 html
 body
 
 form action=showDetails method=post
  input name=name:str NAMEbr
  input name=balance:float BALANCEbr
  input name=interestRate:float INTEREST RATEbr
  input type=submit value=calculate
 /form
 
 /body
 /html

This seems ok.
 --
 html
 body
 
 span tal:define=name request/name;
   balance request/balance;
   rate request/interestRate
  span tal:content=python: here.doStuff(name,balance,rate)/span
 /span
 
 /body
 /html

Why this? 1) your python script can read request just fine. No
 need for clumsy code in ZPT
  2) your code below returns a list, so all you get 
 is the string representation of a list. Works
 but does not look so fine ;)

 --
 years = 1
 newBal = balance( balance*(rate*years))

You call balance as function by using ().
Try your function in the interactive interpreter if 
unsure, e.g. 

balance = 5000
rate = 8 # in percent I assume? You should state that in the form
years = 4

newbalance = balance * (1+rate/100.0) ** years

if you output newbalance, you will see if it does what you want.

if you transfer it into the python script,
replace the assignments with 

balance = context.REQUEST.get(balance,0)
rate = context.REQUEST.get(rate,0)
years = context.REQUEST.get(years,0)

and 

return newbalance

at the end.
(You can also skip the variable and return the
 result of the expression directly)


I'd point the form to itself and make
the output just below it.

span tal:content=here/doStuff /

thats all.



___
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] URL rewriting (VHM and browser Id manager)

2005-05-14 Thread Victor Kolisinski
Dear Dieter

I am relativy new in the Zope community , so my firt
goal was to check am I doing something wrong in Zope
setup or in my code.

Regarding debuging , I am also using the pdb debuging
tool and for me it's works well.

I don't have enough time for now to correct bugs in
Zope but this bug is also related to bug BASE Tag is
generated without session information described at
http://www.zope.org/Collectors/Zope/885.

Both bugs are related to session machinery without
cookies , so in my case I can't using session data at
all.

Also my suggestion to Zope developers is that Browser
ID manager should rewrite URL only if cookies are
disabled on client side.

Thank very much for your effort.
 

--- Dieter Maurer [EMAIL PROTECTED] wrote:
 Victor Kolisinski wrote at 2005-5-13 10:31 -0700:
  ...
 URL is generated with _ZopeId but when request come
 to
 
 ZServer VHM mapping doesnt works correct. Maybe i
 don't know to make correct mapping
 
 BUT today I make simple example:
 VHM mapping = localhost:8080/test/VirtualHostRoot/
 
 In test folder i have index_html page :
 
 html
   head   
   /head
   body
 This is Page Template em
 tal:content=template/idtemplate id/em.
 a href= tal:attributes=href
 here/absolute_urlVisit me again /a
   /body
 /html
 
 In this simple example BIM URL rewriting doesn't
 works.
 It works only if VHM mapping is empty.
 
 Is it posible that VHM is buggy in this case.
 
 It is possible as I explained in an earlier message
 (conflict for BeforeTraverse hook).
 
 At your place, I would use debugging to find out
 what precisely goes on.
 
 When you plan to use Zope for various projects,
 you may be able to convince your boss that
 the investment in a commercial Python IDE with
 support for Zope debugging will be worth.
 Colleagues of mine are quite satisfied with WingIDE.
 
 Personally, I am using the archaic pdb (which
 comes with Python).
 
  ...
 P.S Do I need to start new thread with example like
 this.
 
 No, as long as the subject still fits.
 
 -- 
 Dieter
 



__ 
Do you Yahoo!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail
___
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] assertion error

2005-05-14 Thread Dieter Maurer

[Dieter]
 Looks as if your catalog were very old and still has entries
 with request relative resolution.
 ...
 With this information, you can try to analyse the problem
 in an interactive Python interpreter.

 ...

[Denis]
To have either object or brain's path in output (tagencies list).
The most interesting is that accessing via name I've got objects and
paths

[Dieter] this means that some paths could not be resolved (you
get them as paths and cannot get objects).

They probably form the old content still using
request relative access.

[Denis]
 but accessing via IP I've got ONLY object - no paths...

[Dieter]
In this case, all paths can be resolved into objects.

You should select one or two failing paths and
analyse them (this is done best in an interactive
interpreter; under *nix, such an interpreter can be
started with bin/zopectl debug).

[Denis]
Then I checked the paths I got for presence of objects on them.
Objects are there, so I decided to use

tagencies.append(portal.restrictedTraverse(path))

[Dieter] Try unrestrictedTraverse (will not work in untrusted code
-- use the interactive interpreter).

If unrestrictedTraverse can resolve the path,
this means that the problem is a permission problem:
the user is not allowed to access some object of path.

The catalog tries two ways to resolve a path:

  the modern one uses physical path related traversal,
  the old one uses request relative Url traversal.

  Due to a bug introduced in a recent Zope version
  (and I think fixed again in Zope 2.7.6), the modern
  approach performs too strict access controls.
  This may mean that the request relative Url traversal
  is used as a fallback.

  The request relative Url traversal is known to
  have severe problems with virtual hosting
  (also it is not yet known why host specification
  via name or IP should make a difference).

I (at your place) would debug brain.getObject()
for one of the failing brains.

Please search the mailing list archives for some notes
about debugging Plone/Zope.
  http://plonetarium.objectis.net

-- 
Dieter
___
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] dollars-and-cents display fails

2005-05-14 Thread Greg Fischer
I guess my quick fix wont work.  Well, it fixes the fmt for decimals,
but there's more to the issue.  Statistical summaries, total, sum dont
work either.
In my dtml-in I might have this:
dtml-var total-decimalcolumn
or
dtml-var sum-decimalcolumn

These dont work with Mysql 5.0.4.  So, what do we have to change in
the Mysql DA or maybe the Mysql-python to fix this?

If I find anything, I'll post more.

On 5/13/05, Greg Fischer [EMAIL PROTECTED] wrote:
 OK well, I fixed it. At least on My zope server.
 
 The function for dollars-and-cents in DT_Var.py was like this:
 def dollars_and_cents(v, name='(Unknown name)', md={}):
try: return $%.2f % v
except: return ''
 
 I changed it to this:
 def dollars_and_cents(v, name='(Unknown name)', md={}):
try: return $%.2f % float(v)
except: return ''
 
 Problem solved.  I just tested it in Mysql 5.0.0 and 5.0.4, and it
 works great.  I'll setup the rest of my app and test some more to make
 sure I am not missing something. If there are any problems I'll post
 more details.
 
 Is this something that could be posted on the Zope Collector?  It
 should probably be tested on lots of other Db's I bet.  But, one
 question I have, should this be handled in the Mysql DA?
 
 On 5/13/05, Greg Fischer [EMAIL PROTECTED] wrote:
  http://dev.mysql.com/doc/mysql/en/numeric-type-overview.html
  That's it right there!  Before 5.0.3, they were unpacked, meaning
  saved like a char.  Now they are packed, fixed point numbers.  This is
  screwing up the python functions for fmt.
 
  Well, I was trying to NOT redo all that code, but looks like I will
  have to if I want to run the new mysql.  I have tons of reports using
  dtml and fmt.   I think I'll stick with 5.0.0 for now until I have
  time for that. (spent it all trying to figure out where my problem
  was!)
 
  Though, I might just switch to Firebird if I have to do some code
  changing on my app anyway.  It's a bit more mature than Mysql's new
  stuff. (considering it's still in beta)  Mysql is just so easy.
 
  -
 
 
  On 5/13/05, Greg Fischer [EMAIL PROTECTED] wrote:
   ok, lots of testing, and I have found that this is related to Mysql 5.0.4.
  
   I compiled and installed Mysql 5.0.0 and the problem does not exist. I
   guess means that it started in 5.0.1 or higher.  I read through the
   change logs and saw a couple of items related to float values on 5.0.3
   and 5.0.4, but I dont have any idea if those are causing the issue.
  
   So, I dont know where to go next.  I can post this info on the mysql
   lists, but I only see the problem in Zope.  Python, or at least the
   MysqlDA, retrieves the value just fine.  I only get the problem if
   using a fmt option on Zope.
   Here's a recap:
   -- I can use Zope 2.7.4 with Mysql 5.0.4 on Windows (using Egenix ODBC
   DA) and there is no issue.
   -- I can use Zope 2.7.3 with Mysql 5.0.0 on Linux (Zmysqlda 2.0.9b3,
   Mysql-python1.2.0,Python 2.3.4) and there is no issue.
   -- When using Zope 2.7.3 with same setup as before, but with Mysql
   5.0.4, problem exists.
   -- Zope 2.7.6 has same issue.
  
   I tried doing a simple dtml:
   dtml-call REQUEST.set('dec',10.23)
   dtml-var decbr
   dtml-var dec fmt=dollars-and-centsbr
  
   This works just fine.  But when pulling 'dec' from Mysql, dtml wont
   render it if using fmt.
  
   I dont have to use Mysql 5.x.  It's just that I already have the app
   running on it, and I'd like to start testing the stored procedures and
   other useful features.
  
   Sorry for the long post.  I just want to give as much info as
   possible.  Thank you for any help!
  
   Greg
  
  
   On 5/12/05, Greg Fischer [EMAIL PROTECTED] wrote:
Oh, it is a decimal(15,2) column.  (all of them are)  Just thought I'd
mention everything too... Running Ubuntu 5.0.4, has the Python 2.4.1
package installed, but I have Python 2.3.4 compiled and installed
separately for Zope.  Zope is compiled with the --with-python flag.
   
Just tried your suggestion, commenting the 'conv[FIELD_TYPE.DECIMAL] =
float' line, restart Zope, still have the issue.
   
So, I have the older Python, which I used to have.  I could try
loading an older Zope, but what I might try is loading the MySQL
5.0.0, which I had before.  At least I can hopefully find out which is
causing my problem.  However, I have Zope 2.7.4 with MySQL 5.0.4 and
it works fine, but on Windows using the Egenix adapter.  Now, I cant
remember what I had for the mysql-python version, it's on the other
server at my clients site. (cant get to it right now)
   
I guess one of my main questions too is, would Zope be getting
anything from the 2.4.1 Ubuntu packages that are installed if I
compiled it with the 2.3.4 python?  (mysql-python is installed
correctly on 2.3.4 too)
   
On 5/12/05, Andy Dustman [EMAIL PROTECTED] wrote:
 On 5/12/05, Greg Fischer [EMAIL PROTECTED] wrote:
  Thanks Andy.  I do have those versions.  But 

Re: [Zope] dollars-and-cents display fails

2005-05-14 Thread David H
Greg Fischer wrote:
I guess my quick fix wont work.  Well, it fixes the fmt for decimals,
but there's more to the issue.  Statistical summaries, total, sum dont
work either.
In my dtml-in I might have this:
dtml-var total-decimalcolumn
or
dtml-var sum-decimalcolumn
These dont work with Mysql 5.0.4.  So, what do we have to change in
the Mysql DA or maybe the Mysql-python to fix this?
If I find anything, I'll post more.
On 5/13/05, Greg Fischer [EMAIL PROTECTED] wrote:
 

OK well, I fixed it. At least on My zope server.
The function for dollars-and-cents in DT_Var.py was like this:
def dollars_and_cents(v, name='(Unknown name)', md={}):
  try: return $%.2f % v
  except: return ''
I changed it to this:
def dollars_and_cents(v, name='(Unknown name)', md={}):
  try: return $%.2f % float(v)
  except: return ''
Problem solved.  I just tested it in Mysql 5.0.0 and 5.0.4, and it
works great.  I'll setup the rest of my app and test some more to make
sure I am not missing something. If there are any problems I'll post
more details.
Is this something that could be posted on the Zope Collector?  It
should probably be tested on lots of other Db's I bet.  But, one
question I have, should this be handled in the Mysql DA?
On 5/13/05, Greg Fischer [EMAIL PROTECTED] wrote:
   

http://dev.mysql.com/doc/mysql/en/numeric-type-overview.html
That's it right there!  Before 5.0.3, they were unpacked, meaning
saved like a char.  Now they are packed, fixed point numbers.  This is
screwing up the python functions for fmt.
Well, I was trying to NOT redo all that code, but looks like I will
have to if I want to run the new mysql.  I have tons of reports using
dtml and fmt.   I think I'll stick with 5.0.0 for now until I have
time for that. (spent it all trying to figure out where my problem
was!)
Though, I might just switch to Firebird if I have to do some code
changing on my app anyway.  It's a bit more mature than Mysql's new
stuff. (considering it's still in beta)  Mysql is just so easy.
-
On 5/13/05, Greg Fischer [EMAIL PROTECTED] wrote:
 

ok, lots of testing, and I have found that this is related to Mysql 5.0.4.
I compiled and installed Mysql 5.0.0 and the problem does not exist. I
guess means that it started in 5.0.1 or higher.  I read through the
change logs and saw a couple of items related to float values on 5.0.3
and 5.0.4, but I dont have any idea if those are causing the issue.
So, I dont know where to go next.  I can post this info on the mysql
lists, but I only see the problem in Zope.  Python, or at least the
MysqlDA, retrieves the value just fine.  I only get the problem if
using a fmt option on Zope.
Here's a recap:
-- I can use Zope 2.7.4 with Mysql 5.0.4 on Windows (using Egenix ODBC
DA) and there is no issue.
-- I can use Zope 2.7.3 with Mysql 5.0.0 on Linux (Zmysqlda 2.0.9b3,
Mysql-python1.2.0,Python 2.3.4) and there is no issue.
-- When using Zope 2.7.3 with same setup as before, but with Mysql
5.0.4, problem exists.
-- Zope 2.7.6 has same issue.
I tried doing a simple dtml:
dtml-call REQUEST.set('dec',10.23)
dtml-var decbr
dtml-var dec fmt=dollars-and-centsbr
This works just fine.  But when pulling 'dec' from Mysql, dtml wont
render it if using fmt.
I dont have to use Mysql 5.x.  It's just that I already have the app
running on it, and I'd like to start testing the stored procedures and
other useful features.
Sorry for the long post.  I just want to give as much info as
possible.  Thank you for any help!
Greg
On 5/12/05, Greg Fischer [EMAIL PROTECTED] wrote:
   

Oh, it is a decimal(15,2) column.  (all of them are)  Just thought I'd
mention everything too... Running Ubuntu 5.0.4, has the Python 2.4.1
package installed, but I have Python 2.3.4 compiled and installed
separately for Zope.  Zope is compiled with the --with-python flag.
Just tried your suggestion, commenting the 'conv[FIELD_TYPE.DECIMAL] =
float' line, restart Zope, still have the issue.
So, I have the older Python, which I used to have.  I could try
loading an older Zope, but what I might try is loading the MySQL
5.0.0, which I had before.  At least I can hopefully find out which is
causing my problem.  However, I have Zope 2.7.4 with MySQL 5.0.4 and
it works fine, but on Windows using the Egenix adapter.  Now, I cant
remember what I had for the mysql-python version, it's on the other
server at my clients site. (cant get to it right now)
I guess one of my main questions too is, would Zope be getting
anything from the 2.4.1 Ubuntu packages that are installed if I
compiled it with the 2.3.4 python?  (mysql-python is installed
correctly on 2.3.4 too)
On 5/12/05, Andy Dustman [EMAIL PROTECTED] wrote:
 

On 5/12/05, Greg Fischer [EMAIL PROTECTED] wrote:
   

Thanks Andy.  I do have those versions.  But Python is 2.3.5 because I
didnt want to move to 2.4.x as I think I read something in the README
for Zope stating it was not tested for compatibility. (right?)  I
guess my thought is... Does 2.3.5 have the same issue as 2.4 

Re: [Zope] dollars-and-cents display fails

2005-05-14 Thread Andy Dustman
On 5/14/05, David H [EMAIL PROTECTED] wrote:
 Greg,
 Have you contacted the mySQL product maintainer?  This is not a Zope
 community issue.  Which is to say, many of us have the instinct to help
 but simply do not use mySQL and therefore have nothing to suggest.
 Other than what is obvious:
 a) contact the maintainer
 b) consider changing to a well-maintained data adapater.

Ouch. But I guess if you'd followed the thread, you'd know the answer
to your question...

-- 
Computer interfaces should never be made of meat.
http://www.terrybisson.com/meat.html
___
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 )