Re: [Zope] How to get nice traceback like from old versions?

2008-03-03 Thread Robert (Jamie) Munro

Dieter Maurer wrote:

Jaroslav Lukesh wrote at 2008-2-6 00:08 +0100:

Once more, correction of misformatted text for better readability.
...
  - __traceback_info__: REQUEST
 Module string, line 1, in expression
NameError: name 'kalendar_titulni_pouze_akce_str' is not defined

Line 313 where is the error looks:
dtml-call REQUEST.set('akce', kalendar_titulni_pouze_akce_str)

Is somewhere some extra product or patch to show partial code where is 
error?


You are right: DTML is only rarely used nowadays and its support
deteriorates.

I do not know of a product or patch to improve on this
(also I modified our local Zope to at least report which
DTMLObject caused a problem).

You can improve it by adding __traceback_info__
or __traceback_supplement__ definitions at strategic places
in the DMTL implementation.


If anyone has done this, can I have a copy of your patch - I'm debugging
on an old DTML product, and it is impossible to debug without line
numbers of exceptions.

Otherwise I might have to downgrade zope to 2.5 - thanks for that tip
from Jaroslav Lukesh - I had no idea that it used to be better.

Thanks,

Robert (Jamie) Munro

___
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] Managing Zope objects in Subversion

2008-03-03 Thread Robert (Jamie) Munro

Peter Sabaini wrote:

On Sunday 02 March 2008 14:17:31 [EMAIL PROTECTED] wrote:

Dear all

We use Zope for the  user interface part of our software product.
We currently export the whole folder hierarchy into a .zexp file and
maintain this file in Subversion.

I'm looking for a way to manage a folder structure as individual
Zope objects in Subversion.


If read-only access is enough, maybe this is for you:

http://www.infrae.com/download/FileSystemSite


And to initially populate File System site with something you have
developed in the Zope DB, you need FSDump.

http://www.zope.org/Members/tseaver/FSDump

Although compatibility between the 2 is not perfect - not everything you
dump is usable in File System Site unmodified, they do make a good
combination.

Robert (Jamie) Munro

___
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] cpu load 99 percent a lot in plone evinironment

2007-02-15 Thread Robert (Jamie) Munro
Philip Kilner wrote:
 Hi Robert (Jamie?),

Most people call me Jamie, but Robert is fine, and it's what it says on
all my official documents.

 AHAH does not seem to be much discussed here - it's worth reading: -
 
   http://microformats.org/wiki/rest/ahah
 
   http://www.gizax.it/ahahsection/
 
   (I have based my work on the script in the second link)
 
 Short version: uses AJAX-like technique of rewriting the HTML using
 JavaScript, but returns pure HTML as opposed to XML or JSON, so trivial
 to implement, and can degrade gracefully.

Very useful. I've based my system on the first link because I didn't
need to use POSTs, I just add ?foo=bar to the end of the URL and get it
as normal. I added the ability to load a list of urls and element ids
one after the other, then only activate the submit button at the bottom
of the page when the whole form was loaded.  This means the top of the
page loads quickly, and the rest loads section by section before people
scroll down to it.

I was thinking I would have to do something like this, and your links
made it really easy.

Robert (Jamie) Munro

___
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] cpu load 99 percent a lot in plone evinironment

2007-02-13 Thread Robert (Jamie) Munro
Jens Vagelpohl wrote:
 
 On 9 Feb 2007, at 09:29, Marko Kruijer wrote:
 I do notice that my suspected page is slow, but that's a page
 template, and there is not very much out of the ordinary going on
 there. Just a loop in tal over a sql result set.
 
 Just a loop in tal over a sql result set can be extremely slow,
 depending on the size of your result set. You may not realize that every
 time you touch one of those resultset record objects the security
 machinery gets in the game to ensure the executing user is allowed to
 see the rendered result. This is true for every single field you're
 trying to show on the page.

I've been having similar speed problems with a page that loops through a
lot of SQL records. From what I can tell from the profiler, it is the
security machinery that is at fault.

 Workarounds I have used in this situation (eons ago) involved retrieving
 the resultset in trusted code (inside a filesystem product or an
 External Method) and converting it to a sequence of simple types, like a
 sequence of dictionaries, before handing it back to the page template.
 Those simple types don't cause security assertions and the rendering is
 sped up immensely.

There seems to be a built in method - .dictionaries() that does exactly
this. Unfortunatley, neither it, nor a simple external method I wrote to
 call my ZSQL methods seemed to help me.

Robert (Jamie) Munro

___
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: PAS and md5 or crypt passwords

2006-10-16 Thread Robert (Jamie) Munro
Piotr Furman wrote:
 
 I've edited GMailAuthPlugin, renamed it MD5AuthPlugin, added that code
 and removed the google specific code. It doesn't give any errors, but it
 also doesn't let me log in. I've tried adding a line to log things, but
 that doesn't seem to be working either.

 
 Maybe You should take a look at SQLPASPlugin -
 http://plone.org/products/sqlpasplugin - there are some SHA encryption
 possibilities, however they are commented by default.
 So You would have to modify it's code little bit.

That's what I was using before. I had no idea that it supported SHA, or
that it was so easy to add MD5. That has solved my problem - Thanks

It's a pretty silly implementation, though. The point of hashing
passwords with MD5 or SHA1 is that if an attacker can read the password
files due to some kind of security leak, he still doesn't have the
passwords themselves, so he still can't login. Unfortunately, the way it
is implemented in SQLPASPlugin, the fact that he doesn't have the
password doesn't matter because if you put the hash itself in the
password field, you are allowed into the site.

It doesn't matter too much for my application, but it's something that
should probably be fixed.

Thanks for everyone's advice, though.

Robert (Jamie) Munro

___
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: PAS and md5 or crypt passwords

2006-10-12 Thread Robert (Jamie) Munro
Tres Seaver wrote:
 Robert (Jamie) Munro wrote:
 How do you use md5 passwords in PAS?

 I've got an SQL database already populated with usernames and md5
 passwords from an old system that I am replacing - I don't have the
 cleartext passwords.
 
 You write an authentication plugin which takes the credentials as keys
 in a dict (e.g., 'login_name', 'password'), encrypts the password using
 the same algorithm as your old system, and then compares them.  E.g.,
 (untested)::
 
   import md5
   PASSWORD_TEST_SQL = (select * from users where login_name = '%s' 
and encrypted_pw = '%s')
   def authenticateCredentials(self, credentials):
   login = credentials['login']
   clear = credentials['password']
   encrypted = md5.new(clear).hexdigest() # or whatever
   matched = self._execSQL(PASSWORD_TEST_SQL % (login, encrypted))
   if matched:
  return matched[0]['userid'], login
   return {}

I've edited GMailAuthPlugin, renamed it MD5AuthPlugin, added that code
and removed the google specific code. It doesn't give any errors, but it
also doesn't let me log in. I've tried adding a line to log things, but
that doesn't seem to be working either.

  LOG(MD5AuthPlugin, INFO, Login attempt: login: %s, clear: %s,
encrypted: %s % (login,clear,encrypted))

Any ideas?

Thanks,

Robert (Jamie) Munro

___
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] PAS and md5 or crypt passwords

2006-10-10 Thread Robert (Jamie) Munro
How do you use md5 passwords in PAS?

I've got an SQL database already populated with usernames and md5
passwords from an old system that I am replacing - I don't have the
cleartext passwords.

Thanks,

Robert (Jamie) Munro
___
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] Generic SQL insert

2006-04-13 Thread Robert (Jamie) Munro
Whenever I'm using SQL databases in zope, I always seem to have to make
a ZSQL instance for inserting into every table in my database, and they
are all nearly the same - they just have a list of all the fields in the
database in the parameters, then they say:

insert into [table] ([list of fields]) values ([list of dtml-sqlvars])

I'd much rather have a dictionary of fields and values, and just throw
it at the DB, not having to make those queries for every table. I have
acheived it like so:

mydict = {field1:value1 , field2:value2 ,...}
(fields,values)=zip(*myDict.items())
context.genericInsert(table='table name',fields=fields,values=values)

Where generic insert is the following ZSQL method:
insert into dtml-var table
 (dtml-in expr=fieldsdtml-var sequence-itemdtml-if
sequence-enddtml-else,/dtml-if/dtml-in)
 values (dtml-in expr=valuesdtml-sqlvar sequence-item
type=stringdtml-if sequence-enddtml-else,/dtml-if/dtml-in);

with parameters:
* table - table name
* fields - list of fieldnames
* values - list of values in the same order

What do other people think of this? Is it a really bad idea?

Robert Munro
___
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] TAL page whitespace removal

2006-04-12 Thread Robert (Jamie) Munro
Dieter Maurer wrote:
 Robert (Jamie) Munro wrote at 2006-4-10 13:14 +0100:
 
 For example, I downloaded the www.plone.org home page and it was 47704
 bytes. I removed all whitespace from the beginning and end of lines, and
 then removed blank lines, and it was down to 35087 bytes - that's a more
 than 25% saving, and the output renders exactly the same in web
 browsers.
 
 A much more efficient way is to activate gzip compression
 for your pages. It not only handles white space efficiently
 (and correct for e.g. pages with pre tags or similar CSS directives)
 it also compresses other text. You not only gain 25 % but about 70 %
 (in the size of requests).

gzip will add enormous processing overhead to the server. Striping
spaces will add negligible overhead, likely less overhead than it saves.

 You will not save RAM on the server side (of course), but
 hopefully (and very likely) the scripts are not the major
 user of RAM on your site.

I have written TAL that produces very large dumps of XML data in the
past, even whole sites. It's a really nice way to dump data from a
database (SQL or Zope DB), but Zope has to build the whole output in RAM
before sending any of it, so it can cause the site to crash. I would
hope in this kind of case that the TAL is the major user of RAM on the
site, so any saving would be really good, but it all cases (except pre
tags, which I would never use) it seems like a possibly significant gain.

Robert Munro

___
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] TAL page whitespace removal

2006-04-10 Thread Robert (Jamie) Munro
Due to the structure of TAL, the output of TAL pages often includes a
lot of whitespace that are added to make the source readable, but once
processed the lines they are on can disappear completely. It would be
nice if the TAL parser had an option that could remove all whitespace at
the beginning and end of lines, and remove all blank lines.

For example, I downloaded the www.plone.org home page and it was 47704
bytes. I removed all whitespace from the beginning and end of lines, and
then removed blank lines, and it was down to 35087 bytes - that's a more
than 25% saving, and the output renders exactly the same in web
browsers. This saving will improve load times for the end user, both by
being less to download and less for their browser to hold in memory. For
the server, the improvements are huge. Obviously less bandwidth is
required, but also less space will be needed in the various caches
meaning the caches will expire less, and/or be equally functional will
less RAM or disc space.

The ability to switch off this feature and leave whitespace in for
debugging may be useful, but not very, because you can always use an XML
indenting tool to get readable output from TAL.

Robert (Jamie) Munro
___
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] Storing things in the session from ZPT

2006-02-24 Thread Robert (Jamie) Munro
How can I put something in a session from ZPT?

I've tried:

div tal:define=session/foo request/foo
div tal:define=foo python:session['foo']=request['foo']

Do I really have to write a python method just to assign a single value?

Robert (Jamie) Munro
___
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] Saving a Rendered DTML Document

2005-12-08 Thread Robert (Jamie) Munro

Asad Habib wrote:

Hello. The PHP script that I use relies on a path to locate the HTML 
file on the file system and since the DTML document is a Zope object, 
it does not have access to that. I also tried using a Zope File object 
as well as a DTML document that is part of a Local File System. Using 
a Zope File object does not work since the ouput of a rendered DTML 
document is text and providing the PHP script a Zope File filled with 
plain text does not work. The same goes for a DTML document that is 
part of a Local File System, once the document is rendered it is plain 
text.


Normally in PHP if you replace the file path with a URL starting http:// 
(or ftp:// etc.) it will fetch the file from the web instead of the file 
system, no problem.


Robert Munro

___
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] Epoz and Tidy

2005-04-29 Thread Robert (Jamie) Munro
How do I control tidy options when using Epoz and uTidyLib? I'd like it 
to output xhtml, but it is currently outputting uppercase tag names etc.

Robert (Jamie) Munro
___
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 )