Re: [Zope3-Users] Problems with (understanding?) the pluggable authenticator utility

2009-05-13 Thread Hermann Himmelbauer
Am Dienstag 12 Mai 2009 22:04:13 schrieb legok...@aol.com:
 Hello,
 i created the permissions in my permissions.zcml, mapped them to roles
 in roles.zcml, and included the files in the configure.zcml. But after
 restarting zope, i still cant see anything interesting on the grants
 page. What am i missing?
 Additionally i dont understand how to use the pau. After setting it up,
 i have no idea, how i can use it to log in and out. When i click the
 login link, i only can log in as manager.
 Could you please give me a hint, where i can continue learning? (in
 which file is the pau documented?)
 thanks for answering my (probably) quite nooby questions. Kai

I would recommend you to have a look at the doctests, which describe the PAU 
in detail: zope.app.authentication, README.txt and other .txt files.

What will also help you is Philipps book, as the basics, (what is a principal 
etc.) is explained there.

Best Regards,
Hermann

-- 
herm...@qwer.tk
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Pluggable Authentication with stock user/manager principals?

2009-01-08 Thread Hermann Himmelbauer
Am Donnerstag 08 Januar 2009 01:46:04 schrieb Sebastian Bartos:
 Hello there Zope3 folks,

 I'm kind of new to Zope 3. Was playing around with Zope 2 and Plone for
 a while before I settled with Zope 3 a few months ago. Starting to get
 the hang out of it (well, slowly).

 Anyway, still have some issues. Right now I'm working on the user
 registration and authentication system for a community site project.
 Managed to get the PAU with sessions and the form authenticator into the
 system, but got a bit stuck on how to combine it with the stock
 principals like the admin user and the zcml files. The security and
 authentication system of Zope 3 still makes me wonder. Anybody got some
 good reference and/or tutorial I may have missed with google there? (Was
 already searching quite a bit, turning in circles now).

For learning Zope3, I'd recommend Phillip von Weitershausens book Web 
Component Development with Zope 3. Moreover, I find the doctests of the 
various packages (especially that one of the PAU) very enlightening.

 --- NOTE: My view of Zope 3 after only a very few month of experience
 with it is following. More philosophical, stop reading if not
 interested! ---

It is, and it should be, as Zope3 introduces something which is new to many 
programmers: The component architecture.

 Anyway, just to cheer up the mood on the list. Now that I start to
 understand Zope 3 I really love it. I basically did the crash course
 coming from C/C++ to Zope 3 without the general Python part. Now I try
 to do some other projects in Python not related to Zope and they are
 just somehow painful. Miss the schema based data structures, the object
 database and a bunch of other things.

You can use the object database outside of Zope 3. ZODB is available as an 
extra package - even more: Most packages are available as seperate eggs, 
meaning, that you can integrate them into your Python programs.

 Side question: is there an easy way to take small parts of Zope 3, like
 for example the schema system to another project without taking the
 whole Zope server?

Yep, just install zope.interfaces, zope.schema etc.

 What also quite annoyed me with the 'normal' python crowd is that they
 just mean to use .INI based configuration (which I don't like coming
 from a Linux based environment). Of course the zcml system does a lot of
 magic that is quite hard to gasp, but I understood it's purpose
 (refactoring) and it's quite nice.

That comes, I think, from the multi platform compatibility. I like the 
Linux-style config files more, too, but I don't see that much of a 
difference.

 Also read the book of Philipp von Weisenhausen. It has some nice
 sections (especially the first 2/3-rd of the book), but somehow I get
 the feeling that he lost the thread in the last section. I mean, most of
 the things there are just hinted with a the rest is up to you and it
 has some inconsistencies too. Also the examples in the last part (with
 the login form for example) are broken on my system. Maybe that is just
 local to me. Still for a book of this magnitude (especially if it is one
 of only two books) would do much better with a support forum (just a
 place for people to meet and throw in ideas, discuss questions that may
 arise). Now doing a some searching on the web it seems that Weisenhausen
 is not into the topic too much since more than a year.

My personal critic on the book is that it often does not explain what's 
happening under the hood, or, more specific, Philipp does it between the 
lines. Moreover, he concentrates on Zope 3 plus the Rotterdam skin, which I 
find very limiting and painful. For that reason, I abandoned Rotterdam and 
now concentrate on the z3c - packages (z3c.pagelet / z3c.form etc.), which 
are not covered at all in the book, so you don't really know how to do things 
without Rotterdam, e.g. registering objects, indexing, setting up PAU etc. 
For that reason, I recommend the doctests of the various packages.

 I know Zope 3 is alive and well, but it really seems to me that most of
 the communication is going on the source level and it is really hard for
 newcomers to get the entry to this wonderful system.

True. My impression is, that a lot of excellent people are working on and with 
Zope3, but most are deeply involved in their projects and have thus limited 
time to contribute. And people, who do have time, seem to concentrate on 
other related projects, such as Grok.

 Maybe things can be done better. I may also be able to contribute to the
 documentation having a little experience on writing if there were a few
 people interested in a bit of this kind of activity maybe as a group.

I think, the most urgent need is the Web page. AFAIK, there are efforts to set 
up something new, but it's still not ready. Moreover, I read various posts 
like yours, and quite some documentation fragments over time, but it seems to 
be hard to unify these efforts. Maybe some central Web page with a Wiki etc., 
as most projects 

Re: [Zope3-Users] Zope3 and SQLAlchemy

2008-11-18 Thread Hermann Himmelbauer
Am Dienstag 18 November 2008 13:06:31 schrieb Thierry Florac:
 Hi,

 I currently have to integrate an SQL database (PostgreSQL, with PostGIS
 extensions) into my Zope3 application.
 I'd like to use SQLAlchemy to handle this, and I've seen that several
 packages are available : z3c.zalchemy, z3c.sqlalchemy,
 zope.sqlalchemy...

 So my questions are simple :
  - what package is the best to plug into my Zope (3.3.1) application ?
  - do all these packages handle the same features ??

I personally use zope.sqlalchemy, beforehand I used z3c.zalchemy. I do not use 
any extra features such as automatic interface creation, automatic storage of 
Zope objects into the RDB and such.

In my case I'm integrating an existing relational database into my Zope 
application, whereas I wanted to use the Power of an ORM machinery.

And for that, zope.sqlalchemy works very well.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] programming concept help needed

2008-11-14 Thread Hermann Himmelbauer
Am Freitag 14 November 2008 22:55:33 schrieb Jim Pharis:
 Zope3'ers,

 I'm struggling with one particular concept in Zope3 and I'm hoping
 someone can provide me with some insight into this.

 Let me stage an example to explain the concept I'm struggling with. I
 have 2 content types, a car and an orange (completely different with
 no similarities besides that they are objects). I've written classes,
 declared interfaces, provided browser views and page templates for
 each type. I'm able to view, edit, and add these types. Now here is
 where I get confused. What if I need these 2 content types to be
 viewable and be modifiable on a single page? For example, say I have a
 use case where I need to change the oranges cost and the cars cost on
 a single edit page. Or what if I need to view attributes from the
 orange and the car on a single page. So far, in all the examples I
 have seen, they only ever deal with a single content type at a time.
 Making a content type to meld these types into single type wouldn't
 make sense. How would I accomplish this.

Issues like that led me to z3c.form, which implements subforms that can be 
used to do things like that and much more.

Although it's complicated - and I tell you - it's really complicated - it's 
absolutely worth it. If you are interested, I recommend to have a look at 
z3c.formdemo which points out several applications.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Smarter values for values = [] in Choice schema fields?

2008-11-06 Thread Hermann Himmelbauer
Hi,
I quite often have Choice schema fields in my applications. In many cases, 
these choice fields should have fixed values, thus I do it like this:

color = Choice( title=uColor, values=['red', 'green', 'yellow'])

My application then uses the these values for further processing, e.g.:

if color == 'red': stop_traffic()

The problem is, that often it is more appropriate to have one value for 
display, and another for internal processing (e.g. when msgid strings are 
involved, when the program needs specific values etc.)

The only way I found is to set up a vocabulary and use 
SimpleVocabulary.createTerm(key, n, name), however, that's quite tedious, as 
I need to write quite some code, register the vocabulary etc.

So, perhaps there's a simpler solution? I'd favour something like this:

color = Choice(titel=uColor, values = [('red', 0, uRed), ('green', 1, 
uGreen)])

Is that possible?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Smarter values for values = [ ] in Choice schema fields?

2008-11-06 Thread Hermann Himmelbauer
Am Donnerstag 06 November 2008 17:30:27 schrieb Marius Gedminas:
 On Thu, Nov 06, 2008 at 02:13:56PM +0100, Hermann Himmelbauer wrote:
  I quite often have Choice schema fields in my applications. In many
  cases, these choice fields should have fixed values, thus I do it like
  this:
 
  color = Choice( title=uColor, values=['red', 'green', 'yellow'])
 
  My application then uses the these values for further processing, e.g.:
 
  if color == 'red': stop_traffic()
 
  The problem is, that often it is more appropriate to have one value for
  display, and another for internal processing (e.g. when msgid strings are
  involved, when the program needs specific values etc.)
 
  The only way I found is to set up a vocabulary and use
  SimpleVocabulary.createTerm(key, n, name), however, that's quite tedious,
  as I need to write quite some code, register the vocabulary etc.

 Not really.

  So, perhaps there's a simpler solution? I'd favour something like this:
 
  color = Choice(titel=uColor, values = [('red', 0, uRed), ('green', 1,
  uGreen)])
 
  Is that possible?

 Define a helper function

 def vocabulary(*terms):
 return SimpleVocabulary([SimpleTerm(value, token, title)
  for value, token, title in terms])

 and use it

 color = Choice(title=uColor,
vocabulary=vocabulary(
(0, 'red', u'Red'),
(1, 'green', u'Green'),
))

Ah, that's nice! I did not know that I can actually use a vocabulary object as 
parameter! Thanks!

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Zope 3 tutorial

2008-11-04 Thread Hermann Himmelbauer
Am Dienstag 04 November 2008 07:05:05 schrieb Jaideep Das:
 I am looking for a good tutorial for latest zope 3. I was following the
 tutorial http://www.benjiyork.com/quick_start/  but its not working with
 new version  of zope3(3.3.1). So was looking for something latest and up to
 date.

I personally prefer Philipps book, although at least for me it left quite some 
questions open.

What I can also recommend is to study the doctests in the various Zope 
packages, this helped me a lot.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] i18nextract.py issue

2008-10-31 Thread Hermann Himmelbauer
Am Donnerstag 30 Oktober 2008 15:39:03 schrieb hass:
 Hi,

 I have been struggling to extract messageIDs out of my application and
 list save them into a .POT file.
 I only know that this used to be a relatively straightforward process
 untill 3.2 when zope was installed from the source code but what about now?

Yep, I was also stunned when switching from the tar.gz to the buildout 
process. What I personally did, was to create the following parts in my 
buildout.cfg (my product is called zbsp):

---
[i18nzbsp]
recipe = lovely.recipe:i18n
eggs = bsp
   pysqlite==2.4.1
   sqlalchemy==0.4.7
   sdecstr
   sa_tools
   ibanlib
   zbsp
   pybktools
package = zbsp
domain = zbsp
location = ..
output = locales
--

Don't forget to add your eggs and reference the i18n-section in the [parts] 
section!

Then, I created in my package src directory a subdir called locale, which 
contains the file update_locales.sh with the following contents:

---
#!/bin/sh

# Message Catalog Template extrahieren
i18nzbspextract

# Copy for english
msgfmt zbsp.pot -o en/LC_MESSAGES/zbsp.mo

# Merge for other languages
cp de/LC_MESSAGES/zbsp.po de/LC_MESSAGES/zbsp.po.backup
msgmerge -U de/LC_MESSAGES/zbsp.po zbsp.pot
---

Extraction works well this way, with the minor issue that the i18n_domain 
attribute in the ZCML-configure element is ignored, instead all message-ids 
are extracted from ZCML files.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Buildout seems to be broken due to missing back35.py in zope.app.component.

2008-10-15 Thread Hermann Himmelbauer
Am Mittwoch 15 Oktober 2008 16:46:06 schrieb Hermann Himmelbauer:
 Hi,
 It seems that buildout is broken:

 A bin/buildout fetched some new packages, especially:
 zope.app.component-3.5.0

 The previous version was:
 zope.app.component-3.4.1

 The problem is, that a file, called back35 is missing in
 zope.app.component-3.5.0 which is, however, imported/needed in several
 other files, e.g. in zope.app.form.browser.metadirectives.py:

 from zope.app.component.back35 import LayerField

Hmmm, just tried a fresh buildout again, now I get this:

src/zope/app/container/_zope_proxy_proxy.c:746: warning: initialization from 
incompatible pointer type
error: Setup script exited with error: command 'gcc' failed with exit status 1
An error occured when trying to install zope.app.container 3.6.1.Look above 
this message for any errors thatwere output by easy_install.
While:
  Installing app.
  Getting distribution for 'zope.app.container'.
Error: Couldn't install: zope.app.container 3.6.1

What's happening here? Is somebody updating the packages?

Is there perhaps a way to switch to an older release that works?

Best Regards,
Hermann



-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Buildout seems to be broken due to missing back35.py in zope.app.component.

2008-10-15 Thread Hermann Himmelbauer
Am Mittwoch 15 Oktober 2008 16:59:24 schrieb Benji York:
 On Wed, Oct 15, 2008 at 10:46 AM, Hermann Himmelbauer [EMAIL PROTECTED] 
 wrote:
  Hi,
  It seems that buildout is broken:

 Are you referring to the Zope 3 trunk buildout?

Well, Stephan Richter cleared things up a bit, I thought I was using the KGS, 
as I had the following in my buildout:

[buildout]
extends = http://download.zope.org/zope3.4/versions-3.4.0c2.cfg

However, what I did not have was the versions = versions directive, thus the 
KGS was probably not used. I still don't really understand what's happening 
here.

I now have the versions=versions directive, and things look better now.

Many thanks to all for help!

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Buildout seems to be broken due to missin g back35.py in zope.app.component.

2008-10-15 Thread Hermann Himmelbauer
Am Mittwoch 15 Oktober 2008 19:28:55 schrieb Christophe Combelles:
 Hermann Himmelbauer a écrit :
  Am Mittwoch 15 Oktober 2008 16:59:24 schrieb Benji York:
  On Wed, Oct 15, 2008 at 10:46 AM, Hermann Himmelbauer [EMAIL PROTECTED] 
wrote:
  Hi,
  It seems that buildout is broken:
 
  Are you referring to the Zope 3 trunk buildout?
 
  Well, Stephan Richter cleared things up a bit, I thought I was using the
  KGS, as I had the following in my buildout:
 
  [buildout]
  extends = http://download.zope.org/zope3.4/versions-3.4.0c2.cfg
 
  However, what I did not have was the versions = versions directive,
  thus the KGS was probably not used. I still don't really understand
  what's happening here.

 The versions-3.4.0c2.cfg only contains a [versions] section. This section
 must be pointed in the main [buildout] section with version = section_name
 (here the section_name is also 'versions', which is a bit confusing)

Ah, now I get it, thanks!

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] thoughts about z3c.form-package

2008-10-09 Thread Hermann Himmelbauer
Am Donnerstag 09 Oktober 2008 04:24:25 schrieb garz:
 thx for your replies! now i have new stuff to think about. :)


 Can you give an example what you can't do with z3c.form?
 i think z3c.form is in respect of what can be done with it general enough.
 i can realize what i want to do with it plus i know how to do it. it isnt
 that i dont understand z3c.form, i even think i nearly fully understand it.
 the issue is, that i cant do it in a nice way and i think if z3c.form would
 be structured differently, this shouldnt be a problem... at least i think
 that. but maybe this will change after thinking about what you guys wrote.
 then i will probably be back with new stuff to discuss, when i try to
 realize my list- and dict-forms further on. :)

I think, an outcome of your thoughts could very well be some additional 
z3.form-based package, or some recipe that covers your use case and eases its 
implementation.

I personally have some patterns in my application that repeat over and over, 
hence I wrote some classes that inherit from z3c.form.Form, added some helper 
methods, modified e.g. the update method, so that the result is e.g. 
a SearchForm, or CustomEditForm class which can be used in my 
application.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] thoughts about z3c.form-package

2008-10-09 Thread Hermann Himmelbauer
Am Mittwoch 08 Oktober 2008 17:14:35 schrieb Tim Cook:
 (Thanks Roger and Adam for your earlier replies.)

 On Wed, 2008-10-08 at 16:59 +0200, Hermann Himmelbauer wrote:
  Moreover, z3c.form is complex, but it isn't hard if one knows what to
  do/how to do - which leads me back to my WIKI idea...

 Hermann,

 This is a very good point.  For those of us just trying to get a handle
 on how to use z3c.form, in the best and most efficient way, a Wiki is a
 great way to collect patterns.

 I think (feel?) that z3c.form is a very powerful package and the
 documentation isn't bad either.  Some of us learn better by seeing
 actual use cases though in order to adapt them to our own needs.

Yes, that's true. However, the documentation does not cover, hmmm, I'd 
say, the very basic concepts, which helps the user understand why z3c.form 
was designed in this specific way.

For instance, Roger enlightened me yestereday that z3c.form could also be 
used for creating PDF documents - I never thought about that, but he is of 
course right.

So, I have the impression that a lot of experience combined with a good 
knowledge of advanced patterns (e.g. adapters) led to the design concepts of 
z3c.form, while the documentation (e.g. in form.txt) covers only quite basic 
things, which may lead people to the misconception that z3c.form has a 
limited usage.

Therefore, a better documentation approach would be to first present quite 
some theory about web-frameworks, HTML-Forms etc., which leads to a bigger 
picture and thus to a higher acceptance of the complexity in z3c.form. If 
this is then combined with a WIKI-Style pattern-receipe section, most 
understandability issues may be solved.

To me, this problem can be applied for many parts of Zope3: Geniality is due 
to limited knowledge interpreted as useless complexity. And the answer to 
this issue should, to my mind, not be to hide complexity, but to explain the 
big picture, which lets people understand the geniality.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] thoughts about z3c.form-package

2008-10-08 Thread Hermann Himmelbauer
Am Mittwoch 08 Oktober 2008 01:11:24 schrieb garz:
 hey,

 while using z3c.form-package i reach its limits here and there. thats why i
 started to think about how a more general implemention should look like. my
 intention of writing this is that i want to know what you are thinking
 about it and i want to know the design-decisions that led to the different
 aspects of z3c.form.

 in the first part i try to give definitions of the concepts of z3c.form as
 would understand them.
 summary:

 z3c.form is all about this one use-case where the user describes a context
 with the help of a schema. you define fields, those fields are used to
 create fieldwidgets and those are rendered in the standard-forms from
 z3c.formui. its very nice to have this use-case well supported, but this
 support should be based on more general implementations. this would enable
 the user to create any kind of form.

Yes, that's the obvious use-case. However, there's much more you can do with 
z3c.form, I often use z3c.form for context-less patterns, or use a session as 
context. In my scenario here, I sparely use ZODB, instead, I have 
SQLAlchemy-based functions that I call in the button handlers. Thus I have 
already interfaces/schemas for all RDB objects, and what I do is to define 
interfaces for those forms and copy those schemas I need into this 
form-interface. Then I can use this interface in my form via 
field.Fields(IMyForm).

But I have to admit, it took me quite a long time to implement certain 
patterns, and very often, the solution I tried was not possible due to some 
complicated z3c.form internals, meaning, I often tried to violate some 
concepts (as I did not understand them).

I think I'm not the only one here, I read quite often about similar problems 
in this list here, so this is my resumee:

- z3c.form is complex
- It's not obvious how to implement certain form-patterns
- People are often overwhelmed by that and don't look through

So, I think two solutions to that could be:

- Improve the documentation (however, I'm unsure in what way, though).
- Create a WIKI or something similar where people can find suggestions how to 
implement certain patterns with z3c.form.
- Do some voting machinery where people can choose which patterns they 
really use. This information may be valuable to find out what people expect  
from a form package and which concepts people actually understand and use.
- If we find patterns that can not be implemented with z3c.form in a viable 
way, try to extend z3c.form so that it is possible.

For me, this looks like the better approach than to trying to implement 
a better form package that may lead to the very same problems as z3c.form 
in the end.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] thoughts about z3c.form-package

2008-10-08 Thread Hermann Himmelbauer
Am Mittwoch 08 Oktober 2008 16:28:07 schrieb Roger Ineichen:
 Hi Hermann

  Betreff: Re: [Zope3-Users] thoughts about z3c.form-package

 [...]
  So, I think two solutions to that could be:
 
  - Improve the documentation (however, I'm unsure in what way, though).
  - Create a WIKI or something similar where people can find
  suggestions how to implement certain patterns with z3c.form.

 That's a very good idea

 [...]

  - If we find patterns that can not be implemented with
  z3c.form in a viable way, try to extend z3c.form so that it
  is possible.

 Yes, we should implement more things, e.g. the ObjectWidget
 and better sub forms. Anything else?

Well, that looks like the major points. What I specifically need, are lists of 
ObjectWidgets (representing relations in an RDB).

  For me, this looks like the better approach than to trying to
  implement a better form package that may lead to the very
  same problems as z3c.form in the end.

 I think it's an illusion ot write a simpler form package which
 does a better job and is simpler at the same time. Every concept
 will ha ve it own edges and limitations. But I whould agree that
 it's possible to write a simpler form package which only has the
 goal to generate schema field based HTML widgets. But the problem is
 if you are using such a package and you need to write a PDF generator
 you can't probably use that simpler framwork and you have to find
 another way do to the same again.

Exactly.

 Probably we can add another API for z3c.form and write a
 z3c.formzcml package which offers the same editForm and addForm
 ZCML directives  which zope.app.form offers. This whould probably
 make things simpler if you start using z3c.form.

Hmmm, well, I'm not so sure about that. I personally have minor usage for such 
vanilla-implementations. At first, such things may suffice, but later on, I 
always needed some specific form behaviour that is not covered out of the 
box.

Moreover, z3c.form is complex, but it isn't hard if one knows what to do/how 
to do - which leads me back to my WIKI idea...

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] [Zope-dev] Problems with schema Date field - year is truncated

2008-08-28 Thread Hermann Himmelbauer
Am Donnerstag 28 August 2008 11:41:54 schrieb Markus Kemmerling:
 Hi Hermann,

 The z3c.form.converter.CalendarDataConverter, on which the
 DateDataConverter is based, explicitely sets the date format to
 'short'.  Overriding the latter with a 'length' attribute set  to
 'medium' will handle german dates as dd.MM..

Ah, yes, many thanks, that did the trick!

Nevertheless, the validator does not check if someone enters a string that is 
too long, e.g. someone can enter 19.02.1999892839, whereas the trailing 
characters are truncated. Is there a way to prevent this, for instance by 
throwing an error? Or is there any reason for this?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form: Data Manager - getting value via dm.query() instead of dm.get()

2008-08-14 Thread Hermann Himmelbauer

 Hi Herman

 Betreff: Re: AW: [Zope3-Users] z3c.form: Data Manager -
 getting value via dm.query() instead of dm.get()

 [...]

 But I would nevertheless suggest to implement some kind of
 switch that decides if an error is raised or NOVALUE is
 returned in case a value is missing in the underlying object.

 I don't understand that.

 Why whould you like to store a default value if a value
 is missing. That's just a write access for storing
 what default returns anyway.

Hmmm, perhaps I have to explain my case better:

Normally, z3c.forms are used to edit/display content objects, which is
e.g. a person object with attributes such as name, etc., which are
then mapped to fields/widgets. In case the underlying data object is a
dictionary, this dictionary has to provide all key/value pairs as
specified in the field.fields().

In my case, I'm creating a search form. This search form does not store
any data into a content object, it just calls a specific search function.
However, the values in the search form should be remembered, so that if
the user comes back to the form, it is already prefilled. Therefore, I
simply store the data dictionary of the button handler into the session
and (mis)use this object as content object:

def getContent():
return session.get('searchformkey', {})

def handle_search(self, action):
data, errors = self.extractData()
if errors:
self.searched = None
self.status = self.formErrorsMessage
return
self.do_search(data)
self.session['searchformkey'] = data

So, it may happen, that not all fields are filled out, therefore key/value
pairs may be missing. If that happens, the widget routine throws an error.
If I manage to overcome this error (e.g. by replacing the get() through
query() routine in z3c.form.widget), my form works.

Maybe, there's a better way to accomplish the above, but I could not think
of one...

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7


___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form: Data Manager - getting value via dm.query() instead of dm.get()

2008-08-14 Thread Hermann Himmelbauer

 Hi Hermann
 So, it may happen, that not all fields are filled out,
 therefore key/value pairs may be missing. If that happens,
 the widget routine throws an error.
 If I manage to overcome this error (e.g. by replacing the
 get() through
 query() routine in z3c.form.widget), my form works.

 I understand. Ther must be something wrong.
 Take a look at the AddForm implementation this one uses
 ignoreContext = True. This forces to not store the values
 to the object. Because it doesn't use applyChanges like
 the EditForm does.

 For a SearchForm, you can use extractData offered from
 the form and do what every you need to do with the extracted
 form values. e.g. store them into a session. You can setup
 the widgets with this values later.

Yes, I already did something similar - I developed a custom form class
that inherits from form.Form and sets ignoreContext=True.
The problem is how to setup widgets with their default values. In
form.widget, there seem to be the following possibilities:

1) From request (Not applicable here)
2) From the data manger (As I tried)
3) From the default field value (Not possible here, as the value is not
static)
4) Via an adapter providing IValue (Possible, but very complicated)

So, only (3) seems to be the way to go, which confronts me with the above
problems.

 Or even better you can define a custom ISession object
 which provides what you need. e.g. with useful default
 values from the schema field definition. Such a custom
 session object can be used within the EditForm and
 you don't have to use the AddForm concept.


 Such a search session object could look like:

 class ISearchSession(ISession):
 Message filter session.

 searchText = zope.schema.TextLine(
 title=Search text',
 description=u'The search text',
 default=u'',
 required=False)

 class SearchSessioon(Session):
 _spd = None

 @Lazy
 def spd(self):
 return self.__getitem__('SEARCH_SESSION_KEY')

 @apply
 def searchText():
 def get(self):
 return self.spd.get('searchText', u'')
 def set(self, searchText):
 self.spd['searchText'] = searchText
 return property(get, set)

Is the parent object Session/ISession the one from zope.session? How does
it connect to the persistent Session object? And what is @Lazy?

Yes, that's a possibility, but it would force me to write:

- An property for every field.
- A class for every search view.

All in all that's around ~ 200 lines of code for 5 search forms with appr.
5 fields each, compared to appr. 10 lines of code in my solution.

 I allways use such a session implementation because it
 abstracts what you need, uses schema fields, offers
 built in defaults and works well with z3c.form.

Yes, thanks for the code snippet, it's interesting and a clean solution.

 Note; I'm still not 100% sure if the get() or query()
 usage in applyChanges is right or wrong. I hope to
 find time to deep into that in the near future.

 But I think nobody will understand the concept if we
 implement a form property for use get or query in
 applyChanges.

Yes, that may be true. Hmmm...

 Hope the session concept works for you till someone
 agrees/checks the get/query useage.

Well, I have two more possibilities until this is sorted out entirely:

1) Monkey patch z3c.form.DictionaryField.get() and let it return
interfaces.NOVALUE
2) Write an register my own data manager to overcome this.

Thanks again for help,
Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7


___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] z3c.form: Data Manager - getting value via dm.query() instead of dm.get()

2008-08-13 Thread Hermann Himmelbauer
Hi,
I'm developing a z3c.form based form, which should store it's form values
in the session. To accomplish that, the form needs to retrieve it's values
from the session.

My idea was to simply store the form data in the button handler method
into the session as a dictionary. z3c.form then offers the getContent()
method, which would simply retrieve the dictionary from the session.

The problem is, that if the dictionary does not contain all fields, an
error is raised. The reason for this error lies in line 97 in
z3c.form.widget: The value is retrieved via the get() function (which does
a dict.get()) and thus fails.

The solution for this problem would be to replace the datamanager.get() by
datamanager.query(), as this would return the default field value.
However, this may break other projects, therefore I would suggest to:

- Introduce some form option such as ContextQuery=True/False
- Either use dm.get() or .query() regarding to this option

What's your opinion on this? Would this be a decent solution?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7


___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form: Data Manager - getting value via dm.query() instead of dm.get()

2008-08-13 Thread Hermann Himmelbauer

 Hi Herman, Stephan

 Betreff: [Zope3-Users] z3c.form: Data Manager - getting value
 via dm.query() instead of dm.get()

 Hi,
 I'm developing a z3c.form based form, which should store it's
 form values in the session. To accomplish that, the form
 needs to retrieve it's values from the session.

 My idea was to simply store the form data in the button
 handler method into the session as a dictionary. z3c.form
 then offers the getContent()
 method, which would simply retrieve the dictionary from the session.

 The problem is, that if the dictionary does not contain all
 fields, an error is raised. The reason for this error lies in
 line 97 in
 z3c.form.widget: The value is retrieved via the get()
 function (which does a dict.get()) and thus fails.

 The solution for this problem would be to replace the
 datamanager.get() by datamanager.query(), as this would
 return the default field value.

 No the datamanager doesn't know the default value. Or at least
 the data manger is not responsible for that part.

Hmmm, that makes sense, but in my use case I need a datamanger that
returns None / NOVALUE / whatever_that_indicates_that_there_is_no_value.

 The data converter is responsible to return a default value.

I see, so there would a possibility to let the datamanager return NOVALUE
and let the data converter return None, I assume?

 This means the data converter convert values from the form
 and the (applyChanges) within the data manager stores them if
 different. And only if they are different.

In my case, I have a dictionary that may - not yet - provide the value.

 However, this may break other projects, therefore I would suggest to:

 - Introduce some form option such as ContextQuery=True/False
 - Either use dm.get() or .query() regarding to this option

 What's your opinion on this? Would this be a decent solution?

 This means it's important to setup any field in the data manager
 and the values for them. There is no support for widget which
 didn't get setup it's value correct.
 But,
 as far as I can see there is a problem with the interface.
 the *query* method isn't declared in the IDataManager interface
 at all and the *get* method provides a default value like:

 The ``get`` method is defined as:
 def get(default=NOVALUE):
 Get the value.

 If no value can be found, return the default value.
 

Ah, I see - so that would denote, that the get() method would return
NOVALUE as default? This would also solve my problem.

But I would nevertheless suggest to implement some kind of switch that
decides if an error is raised or NOVALUE is returned in case a value is
missing in the underlying object.

Many thanks for help!

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7


___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Software developer for a Zope3 project needed

2008-05-13 Thread Hermann Himmelbauer
Hi,
We are currently looking out for a Zope3/Python developer for an interesting 
project lasting approx. 30 to 35 days. I can't give exact details yet, but 
the following profile should be met:

- High Zope3 skills - the project is 100% based on Zope3 technology, moreover, 
the project may include Zope3 enhancements that should find it's way into the 
Zope3 SVN, therefore involvement in the Zope3 community is a clear advantage.
- Good Python and HTML knowledge

The following points would be an advantage:

- z3c.form/pagelet knowhow as our project is based on these packages
- Knowledge about mobile-phone development (XHTML MP) and CSS
- German speaking
- The project can probably not be done from remote, personal presence will be 
required. Our location is near Vienna (Austria/Europe), so if you are located 
near us, things are a lot simpler. 

The exact schedule is not yet planned, but will be somewhere in june to 
august.

Please contact me, if you interested or want to know further details!

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.zalchemy - which version to use?

2008-05-08 Thread Hermann Himmelbauer
Am Mittwoch, 7. Mai 2008 17:43 schrieb Christian Theune:
 On Wed, May 07, 2008 at 03:41:11PM +0200, Hermann Himmelbauer wrote:
  Hi,
  I'd like to know if / which SVN version/branch of z3c.zalchemy works with
  a current SQLAlchemy distribution.
 
  If none does, what about z3c.sqlalchemy?

 In addition to what Andreas said: zalchemy is going to be abandoned.
 zope.sqlalchemy will be the common base implementation of transaction
 integration with SQLAlchemy. Other packages like z3c.sqlalchemy will
 implement higher level functions in addition to that.

Ah, interesting, I was not aware of the existence of zope.sqlalchemy. Thanks 
to everyone who created the package, this simplifies things a lot. Will the 
package be contributed with Zope3 itself in the future, as it is in 
the zope. namespace?

I just have a look at it and it looks fairly simple. What I don't understand 
ist, how/when the Session class should be created:

 Session = scoped_session(sessionmaker(
... bind=engine,  
... twophase=TEST_TWOPHASE, 
... transactional=True, autoflush=True,
... extension=ZopeTransactionExtension()))

Can I simply put this statement in one of my modules and import the Session 
class from other modules? This would create the Session class once during 
Zope startup. Does this mean that I don't need a utility anymore, such as in 
z3c.zalchemy?
Or do I have to create the Session class in each thread, e.g. in my code?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] z3c.zalchemy - which version to use?

2008-05-07 Thread Hermann Himmelbauer
Hi,
I'd like to know if / which SVN version/branch of z3c.zalchemy works with a 
current SQLAlchemy distribution.

If none does, what about z3c.sqlalchemy?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] raise Redir(newurl) not working - can someone confirm this?

2008-04-19 Thread Hermann Himmelbauer
Hi,
In my application, namely for URL-Rewriting for session handling, I need to 
stop the current request and redirect to another url (including the session 
key).

For that reason, I issue the following statement:

from zope.publisher.interfaces import Redirect
raise Redirect('http://my.new.url')

Theoretically, this exception should be caught by the publisher and a redirect 
should be done, unfortunately not in my case:

-
Traceback (most recent call last):
  File /local/home/dusty/Zope-3.4.0c1/lib/python/zope/publisher/publish.py, 
line 130, in publish
obj = request.traverse(obj)

  File /home/dusty/prog/zope3-inst/lib/python/my_app/session.py, line 72, in 
getClientId
raise Redirect(redir_url)
Redirect: 
Location: 
/++session++VLdODjCYl90YmQwdNG6hvdiT11UZS3oly5kXonWYLHdGHloxvTshQs/favicon.ico
--

I don't know why this happens, *maybe* that's due to inclusion of some 3rd 
party packages, e.g. z3c.layer.pagelet?

To confirm this, I'd like to know if this scenario is only happening for me, 
so, can you please simply insert the above statement in some arbitrary view 
and tell me if it works?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: AW: [Zope3-Users] raise Redir(newurl) not working - can someoneconfirm this?

2008-04-19 Thread Hermann Himmelbauer
Am Samstag, 19. April 2008 14:05 schrieb Roger Ineichen:
 Hi Hermann

  Betreff: [Zope3-Users] raise Redir(newurl) not working -
  can someoneconfirm this?
 
  Hi,
  In my application, namely for URL-Rewriting for session
  handling, I need to stop the current request and redirect to
  another url (including the session key).
 
  For that reason, I issue the following statement:
 
  from zope.publisher.interfaces import Redirect raise
  Redirect('http://my.new.url')

 I always use self.request.response.redirect(url)

I normally do, too. But in this special case, it must not happen that some 
later code calls self.request.response.redirect() and therefore overwrites my 
redirect.

Due to the problems with the Render exception, I experimented with 
self.request.response.redirect() and it seems to be overwritten, which leads 
in some way I don't fully understand to endless recursions/redirecting.

However, this endless recursion has something to do with virtual hosts; 
Something smells fishy there, too, as application names are not added to 
request._app_names if ++vh++ is specified at the URL, instead, namespaces 
like ++lang++ etc. remain in request._traversed_names.

One can easily see this by inserting something like this in his view code:

print request.getTraversalStack()
print request._traversed_names
print request._app_names

And then by accessing a site directly and via a virtual host (e.g. Zope3 
behind Apache) and comparing the values. (Something 
like ++skin++ / ++lang++ should be in the URL to see it.)

Either there is something buggy in Zope3/virtual hosts or things happen which 
I don't understand...

  /++session++VLdODjCYl90YmQwdNG6hvdiT11UZS3oly5kXonWYLHdGHloxvT
  shQs/favicon.ico
  --

 Are you trying to redirect to the favicon.ico?

No, my case is quite simple: Mobile phones have only limited/buggy cookie 
support, therefore I rewrite the URL and store a session key there (as shown 
above). What I did is to simply create my ClientIdManager, which inherits 
from CookieClientIdManager, where I overwrote the getClientId() method.

  I don't know why this happens, *maybe* that's due to
  inclusion of some 3rd party packages, e.g. z3c.layer.pagelet?
 
  To confirm this, I'd like to know if this scenario is only
  happening for me, so, can you please simply insert the above
  statement in some arbitrary view and tell me if it works?

 I'm not 100% sure but,

 Note, if you use redirect you have to take care when you
 are doing this. You can only do this in the view call
 but not if the pagelet renders the template, because that's
 too late. This is not pagelet specific, that's also the case
 if you render a template in a BrowserPage?

Well, I do this very early, namely in the ClientIdManager, that's I think 
before pages are rendered. But, perhaps, that's too early?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] raise Redir(newurl) not working - can someone confirm this?

2008-04-19 Thread Hermann Himmelbauer
Am Samstag, 19. April 2008 15:43 schrieb Jim Fulton:
 On Apr 19, 2008, at 6:20 AM, Hermann Himmelbauer wrote:
  To confirm this, I'd like to know if this scenario is only happening
  for me,
  so, can you please simply insert the above statement in some
  arbitrary view
  and tell me if it works?

 This may be a bug in Zope 3.  I suspect that there needs to be an
 error view or Redirect that actually does the redirect.

 I think you are going to have to register a page for the redirect
 exception that calls response.redirect.

 See zope.app.exception.browser for other examples of exception views.

Ah, yes, thanks. I managed to register a page for this exception, which is 
called in this case, however, what I don't know is how to extract the 
exception string (which is the URL I want to redirect to) in my view. Any 
suggestions?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] raise Redir(newurl) not working - can someone confirm this?

2008-04-19 Thread Hermann Himmelbauer
Am Samstag, 19. April 2008 19:38 schrieb Hermann Himmelbauer:
 Am Samstag, 19. April 2008 15:43 schrieb Jim Fulton:
  On Apr 19, 2008, at 6:20 AM, Hermann Himmelbauer wrote:
   To confirm this, I'd like to know if this scenario is only happening
   for me,
   so, can you please simply insert the above statement in some
   arbitrary view
   and tell me if it works?
 
  This may be a bug in Zope 3.  I suspect that there needs to be an
  error view or Redirect that actually does the redirect.
 
  I think you are going to have to register a page for the redirect
  exception that calls response.redirect.
 
  See zope.app.exception.browser for other examples of exception views.

 Ah, yes, thanks. I managed to register a page for this exception, which is
 called in this case, however, what I don't know is how to extract the
 exception string (which is the URL I want to redirect to) in my view. Any
 suggestions?

Ah, ok, simple, got it by myself: The error is simply self.context in my view.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Authentication without cookies

2008-04-15 Thread Hermann Himmelbauer
Am Montag, 14. April 2008 19:17 schrieb Jonathan:
 - Original Message -
 From: Peter Bengtsson [EMAIL PROTECTED]
 To: Hermann Himmelbauer [EMAIL PROTECTED]
 Cc: zope3-users@zope.org
 Sent: Monday, April 14, 2008 12:55 PM
 Subject: Re: [Zope3-Users] Authentication without cookies

  Slightly off-topic: What mobile browsers that support XHTML don't
  support cookies these days? Don't need an accurate answer but I'm
  curious about rough numbers.

 Here is an interesting read on mobile web site authoring
 http://www.passani.it/gap/.  It indicates that '80%' of devices have some
 level/form of cookie support.

Thanks, that's an interesting read! It's astonishing, how bad standards are 
implemented in mobile browsers. The summary seems to be to either use 
adaptation, which means to optimize the code to a variety of browsers/phone 
models (recommended way) or to use a very limited subset, a least common 
denomiator. Things that are not recommended to use for mobile pages are such 
simple things such as:

- Use only simple inline-CSS or none
- Do not try to colour links
- Cookies are not reliable
- Page caching may lead to problems

 Hermann, as a test you could try setting a cookie, do an http redirect and
 see if your cookie is accessible.

Yes that's an option, thanks. However, it seems, the better praxis is to 
entirely avoid cookies for mobile clients and store a session key in the URL.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Authentication without cookies

2008-04-15 Thread Hermann Himmelbauer
Am Montag, 14. April 2008 20:07 schrieb Jim Fulton:
 All you need to do is to get non-cookie based sessions, and then you
 can use the existing session-authentication machinery.

 Look at the client id framework in zope.session,
 http://svn.zope.org/zope.session/trunk/src/zope/session/http.py?view=auto

 I assume you just need to implement a URL client id manager.  (BTW,
 I would leverage the namespace machinery, so you'd end up with URLs
 with http://foo.com/++session++42/foo/bar.)

Ah, that's a very good idea! Let's see if I can manage to implement this.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Authentication without cookies

2008-04-14 Thread Hermann Himmelbauer
Hi,
I'm developing a Zope3-based application which is used on mobile phones. The 
problem here is that cookies don't always work with mobile browsers. 
Therefore it seems, the way to go is to put a session key in the URL.

Therefore I need some authentication system that first tries to set a cookie, 
and if it does not work, inserts somehow a key into every URL, whereas a 
credentials plugin retrieves this key.

However, I assume I'm not the only one with such a scenario, therefore I'd 
like to know if somebody solved this problem already?

If not, is there some suggested scenario how to find out if the browser 
supports cookies?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Authentication without cookies

2008-04-14 Thread Hermann Himmelbauer
Am Montag, 14. April 2008 18:55 schrieb Peter Bengtsson:
 Slightly off-topic: What mobile browsers that support XHTML don't
 support cookies these days? Don't need an accurate answer but I'm
 curious about rough numbers.

Well, I have a SonyEricsson K750i which seems not to support cookies. It does 
have some options for cookies, but they don't work.

And the SonyEricsson K550i does support cookies, but - even worse - sometimes 
does not send the cookie, which *may* have something to do with the cookie 
path and bugs in the mobile browser. In this case, the user loses his 
authentication and has to login.

So, if even such recent models have severe cookie-problems, I deduce that 
things will be at least the same if not worse in older models. But I can only 
speak about SonyEricsson models as I had not yet time to test other brands.

Moreover, WAP seems not to support cookies by design, at least in another, 
incompatible fashion, which I'm unsure how this works.

If I install OperaMini, cookies work perfectly, however, with Opera, the 
Internet connection is built up/torn down for every request, which results in 
a slw browsing. (Every requests lasts approx. 30 seconds to one minute). 

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: [Zope-dev] Zope 3.4.0 candidate 1 Released

2008-03-28 Thread Hermann Himmelbauer
Am Donnerstag, 27. März 2008 18:26 schrieb Kurt Zitze:
 if you want to raise the userbase of zope, the first and most obvious thing
 to do is, get a forum running! mailing lists are bu*** and completly
 out of date. it is max cumbersome to login into your email account to do a
 post and so on, i think i dont need to enumerate all the disadvantages of a
 mailing list compared to a forum. i am even not aware of how to replay to a

Well, all I can say to this is: Please do not split up the userbase by opening 
some extra web forum. I personally dislike forums, they are often cumbersome 
to use, therefore I prefer mailing lists a lot.

Although I don't like forums that much, it is true that newbies and specific 
users tend to use them. To satisfy both sides, I can think of a forum that 
has a gateway to this mailing list. If I remember it right, Plone has such a 
thing (perhaps it could be used somehow?). This forum would then also serve 
as a pretty looking archive, which is also a good thing.

 and if you finaly have one, put it on the start site, not like this mailing
 list that is so to say hidden!

It's true, that Zope3 and Zope3 support ist somehow hidden in the Zope 
website. But AFAIK a new Zope website is currently under development, which 
will probably solve all these issues.

 everything in zope is not obvious, at least not to me. everything has to be
 found out in hours of studying the sources! reading the books, using google
 to find sources that arent linked nowhere. i stumbled over nabble, i
 stumbled over nearly everythink i essentialy have to know!

Well, the learning curve is really steep, that's true. I personally also did 
have to study the sources quite often. Phillips book did help, but often only 
after a personal advice from himself or after studying the sources.

The real problem for me was that Zope 3 is all about a new software 
development concept, namely, the component design with interfaces / 
adapters / utilities etc. This is something that the Joe Average programmer 
is not used to, so he does not really know how to map his ideas to a 
componentized architecture. I don't know how to deal with this problem, 
perhaps a theoretical book about componentized software design could help; On 
the other hand newbies like to start right away and don't want to study a 
complicated design book beforehand.

Another issue is the ZMI. Most people, who begin Zope3, start out with 
Phillips book or similar documentation which uses and adapts the ZMI. 
However, many people sooner or later come to the conclusion that the ZMI can 
not be configured to their needs, things get very complicated and people are 
frustrated. Many people, such like me, then have a look at a ZMI-less design 
(e.g. z3.pagelet, z3c.form etc.), which works better for many projects.

Anyway, after approx. 1 year of Zope 3 development, I can say that going 
through these hassles and problems was definitely worth it. Moreover, I 
think, Zope 3 is very much work in progress and I'm expecting many things 
to come that will solve the issues above and make the entry step easier.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] I18N: Recursive Translations / translations of mappings - how?

2008-03-05 Thread Hermann Himmelbauer
Hi,
I have the quite generic problem that I need to translate strings that contain 
strings which also should be translated, for instance:

--- snip 
from zope.component import provideUtility
from zope.i18n import translate
from zope.i18n.simpletranslationdomain import SimpleTranslationDomain
from zope.i18nmessageid import Message, MessageFactory
_ = MessageFactory('xyz')

messages = {
('en', u'pink'): u'pink',
('de', u'pink'): u'rosa',
('en', u'colour'): u'The colour is $pink',
('de', u'colour'): u'Die Farbe ist $pink'}

xyz = SimpleTranslationDomain('xyz', messages)
provideUtility(xyz, name=u'xyz')

pink = _(u'pink', u'pink')
pink = Message(pink)
print translate(pink, target_language='en')
print translate(pink, target_language='de')

colour = _(u'colour', u'The colour is $pink')
colour = Message(colour, mapping={'pink' : pink})
print translate(colour, target_language='en')
print translate(colour, target_language='de')
 snip -

The output of the above program is:

--
pink
rosa
The colour is pink
Die Farbe ist pink
--

It can be seen that the string pink is not translated if used as mapping in 
another string to be translated.

One very helpful guy on Freenode suggested to solve this the following way:

colour = Message(colour, mapping={'pink' : translate=(pink, context=request)})

This works, however my problem is that the code is in another module that is 
and should not be aware of the context as it's not really zope-related, so 
It's somehow unclean to use the context/request in that module.

So I was wondering if it is possible to tell the translate() function to 
recursively translate the string, hence look at the mappings, check if they 
are of the type zope.i18nmessageid.message.Message and if yes, either descend 
into it and it's mappings and translate it until every mapping is translated, 
too.

What do you think?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] How to store objects with multiple owners in the ZODB

2008-02-28 Thread Hermann Himmelbauer
Am Sonntag, 27. Januar 2008 18:25 schrieb Stephan Richter:
 On Tuesday 08 January 2008, Hermann Himmelbauer wrote:
  My question is: How would I store these documents in the ZODB? If I
  create a container object for each user and store the document there, how
  would then other users get a link to their own folder? Moreover, what
  happens if the original owner abandons the document?

 You clearly thought about the problem, since you already provided
 solutions. :-) It all depends how you identify an owner. I do this by
 checking whether a user has been granted the Owner role locally.

 Okay, so now we know how to retrieve the information. Next, how can we
 efficiently extract a list of all the documents a user owns. The answer is
 a catalog. You can create an index that records the owners of each
 document. (That should be about 5-10 lines of code.) When you provide the
 list, you simply return catalog query results, instead of iterating through
 all items in a folder.

 What to do when someone abandons a document depends really on your decision
 where to locate it and how you implement other views.

 1. If you have one large container, the solution is simple. You write a
 subscriber that checks whether the changed object still has an owner. If
 not, it is deleted. There is not need for more info tracking.

 2. If you store the documents locally, and the removed owner matches the
 location user, I would move the documents either to a global abandoned
 folder or to the user folder of the next user on the list.

 Which way you want to go, depends on your other design goals.

I just wanted to give you feedback about this:
I first decided to go my way and store the documents in the user folder, while 
storing copies of these documents in other user folders (in case there are 
other owners). However, This did NOT work out in the end:

The problem with copies of objects in multiple containers is that these 
objects have the wrong __parent__ atribute, therefore traversing etc. does 
not work properly - that was something I did not think about beforehand.

Therefore I redesigned my app to your way where all documents are kept in a 
large folder and the owner role is assigned to them. Moreover I have 
a owners property that lists all owners (=Principals) for this role. This 
property can then be indexed.

  If I have one huge container that holds all documents, how would then
  list users their documents?

 Use a catalog query. Seriously; it is efficient.

That's somehow the drawback about the above solution: Retrieving documents via 
indexes is very efficient, however, I need to order them after some object 
attribute, which seems to be quite painful and slow unless there isn't some 
trick with another index. But let's see - for now it's ok, but in case it has 
to be scaled upwards I have to think about this issue.

Many thanks for help!

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Efficiently retrieving objects from an index ordered after an object attribute.

2008-02-25 Thread Hermann Himmelbauer
Hi,
I have a class looking similar to this:

class person
  birthdate = None   # Some date
  name = None # First name
  gender = None # Male/Femail
  
Objects of this class are then added to a catalog, for which I defined an 
index (zc.catalog - ValueIndex) for each attribute.

What I want to do now is to retrieve e.g. all male persons but ordered by age 
(birthday), while the order should be choosable between ascending/descending. 
Moreover, I have to take in mind that my database may hold a massive amount 
of person objects, so the solution should be somehow efficient.

I thought about two solutions:

1) Simply do a catalog.searchResults(gender = {'any_of' : ('male, )}, then put 
the results in some list of tuples, where the tuple consists of (birthdate, 
personObject) and do a list.sort().
This solution is, however not very efficient

2) In the birthdate-index, persons are already correctly sorted into a BTree. 
So I thought about using this index somehow, e.g. by adding the index to my 
query, e.g.:

catalog.searchResults(birthdate={'any' : None}, gender={'any_of':('male,)}

However, this seems not to work due to the code in zope.app.catalog.catalog, 
class Catalog, function apply() (~ line 135):

 snip -
results.sort() # order from smallest to largest

_, result = results.pop(0)
for _, r in results:
_, result = self.family.IF.weightedIntersection(result, r)

return result
- snip -

First of all, I don't know what exactly weightedIntersection() does, moreover, 
it seems, that the smaller set is regarded first, which means that 
the birthdate-index is more or less not regarded.

So maybe, I should create an own catalog class that inherits from Catalog, 
which overrides the apply() function and maybe implements a custom 
searchResults() function which implements ordering?

3) Just use the birthdate index for ordering and do the rest of the 
filtering manually. This may be even faster than (1) as sorting the results 
will be quite costly.

Another issue is that I want to batch the results in my HTML-page, so I'd 
favour a solution where I can select e.g. the first 50 results, or, even 
better, a result set (e.g. 150-200).

Any ideas on an effective solution to this problem?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Cloning interfaces/interface fields - how?

2008-02-21 Thread Hermann Himmelbauer
Am Donnerstag, 21. Februar 2008 17:34 schrieb Marius Gedminas:
 On Wed, Feb 20, 2008 at 01:12:18PM -0500, Stephan Richter wrote:
  On Wednesday 20 February 2008, Hermann Himmelbauer wrote:
   Yes, I also use z3c.form, but my problem is that the field has the
   required flag set to True, which is appropriate for an add/edit
   form but may not be appropriate for a search form.
  
   If I change the required flag on the field level, e.g. in the
   update() method, the change is permanent in the interface, which is not
   appropriate. And changing it on the widget level seems to be very
   complicated, at least, I found no way to do it.
 
  Mhh, I think that form fields should support this. Let me look at the
  code briefly.
 
  So yes, you need to change it on the widget level; here is what you have
  to do in your form:
 
  class MyForm(Form):
 
def updateWidgets(self):
  super(MyForm, self).updateWidgets()
  self.widgets['prefix.myfield'].required = False
 
  Is that too difficult still?

 Does that actually work?  I vaguely seem to remember that I tried this
 approach once (making the widget not required when the field was
 required), but some code from the field itself raised validation errors.

Heh, this was also my first reaction on this as I also received such an error 
some time ago but could not really remember if it was my fault or not, but as 
you mention it, too, there seems to be some problem. ;-)

Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] z3c.form - how to set single default values from another object?

2008-02-20 Thread Hermann Himmelbauer
Hi,
Hi, I have here an add form which is based on an interface like this:

class IMyObj(Interface):
  value1 = TextLine()
  value2 = TextLine()
  
In my add form, I need to display a default value for value2. This default 
value is stored in another object, however, no default value should be given 
for value1.

I'm desperatingly trying to implement this via z3c.form through various ways, 
but none seems to work. I had a look at widget.py, line 73 (the update 
method where the value is retrieved) and found the following:

1.1) From Request: I could solve my problem like the following in my update() 
method:

self.request.form['form.widgets.value2'] = 'mydefault'

However, I don't think it's a nice solution to modify the request for a 
default value.

1.2.1) Via a datamanger: Seems to be not possible as I can't explicitly 
set ignoreContext = False for a single widget. Therefore this fails as I 
don't have a datamanager for value1. Moreover it seems the datamanger is not 
a named adapter:

value = zope.component.getMultiAdapter(
(self.context, self.field), interfaces.IDataManager).get()

Therefore in my case, where value1/value2 are both TextLines and have the same 
widget, it's not possible to register the datamanager for value2 only.

1.2.2) Via the field default value: Maybe possible by cloning the field in the 
update() method of my form and setting a default value there, however, this 
looks lie a _very_ bad style to me.

1.3) From an object attribute (don't really understand what this Step is for): 
Seems also not possible as there's once again no way to register a named 
adapter here and therefore the absence of value1 as object attribute will 
lead to an error:

adapter = zope.component.queryMultiAdapter(
(self.context, self.request, self.form, self.field, self),
interfaces.IValue, name='default')

So, either I missed somehow a good solution, or my pattern is not addressed in 
z3c.form. In this case, I'd suggest to handle this case in two ways:

1) Add e.g. Step 1.2.3, which queries after a named adapter where the name is 
the field name. This way, I'd be able to register an adapter that retrieves 
the default value from somewhere else.

2) Provide a way to tell single widgets (and not only the widget manager) to 
ignore/not ignore the context. This way, I could simply use the getContent() 
method in my view, although there's once again the same problem if the 
default values don't come from a single object (as my getContent routine 
cannot decide which object to return).

I don't know if these two solutions would conflict with other parts of the 
framework, maybe there's an even better solution?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: AW: AW: [Zope3-Users] z3c.form - howto ignore the context for singlewidgets in an Edit form?

2008-02-20 Thread Hermann Himmelbauer
Am Donnerstag, 21. Februar 2008 04:41 schrieb Stephan Richter:
 On Monday 18 February 2008, Hermann Himmelbauer wrote:
  - Only widgets?
  - Combinations of schemas and widgets?
  - Also schemas without widgets (like an Email schema that inherits from a
  TextLine and thus uses a TextWidget)?

 These are good questions. We started already collecting the schema fields
 in z3c.schema. So I think z3c.formwidget should only contain the widgets
 and converters.

Ah, ok, I was not aware of the z3c.schema package.
Anyway, Roger suggested to solve this in another style by creating an egg for 
each schema and widget, e.g. z3c.schema.email, z3c.formwidget.email, 
z3c.schema.telephone, z3c.formwidget.telephone etc. He made some good points 
there, so I'm unsure which way to go?

I think this leads to an eggsplosion, but Roger stated that this is exactly 
what the concept of eggs is all about. However, I'm still unsure that 
handling hundreds of eggs is really a viable way.

For instance, I use z3c.form from the SVN repository, this way I always have 
the newest release via a simple checkout. However, it was quite some work to 
checkout/configure all other packages z3c.form needs, such as z3c.pagelet, 
z3c.formui etc. etc. So, in case of an eggsplosion, where a package has e.g. 
50 dependencies, using an SVN version is a mess, especially when a SVN 
version depends on code available only in the SVN and not as Egg. Are such 
cases all really thought out?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Cloning interfaces/interface fields - how?

2008-02-19 Thread Hermann Himmelbauer
Hi,
I'm over and over confronted with a simple pattern, where I need to clone 
interface field. For instance, I have the content object, which has an 
interface, e.g.:

class IPerson(Interface):
  name = TextLine()
  address = TextLine()

Then, I have for instance a search form, which consists of fields of other 
interfaces, therefore I tried this:

class IPersonSearch(Interface):
  name = IPerson['name']

The above interface has the problem that the field is referenced, thus 
changing attributes (e.g. name.required=False) changes also the attributes of 
the original field.

Therefore I now copy the field, which seems to work (but I'm not 100% 
certain):

class IPersonSearch(Interface):
  name = copy.deepcopy(IPerson['name'])

Another idea is to entirley skip the IPersonSearch interface and create the 
interface on the fly, like this:

class SearchFrom(z3c.form.EditForm):
   fields = z3c.form.field.Fields(copy.deepcopy(IPerson).select('name'))

However, this does not seem to work as still some things are referenced 
instead of copied, so copy.deepcopy seems to fail on interfaces.

What's your opinion on this, how do you apply this pattern?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Cloning interfaces/interface fields - how?

2008-02-19 Thread Hermann Himmelbauer
Am Dienstag, 19. Februar 2008 20:13 schrieb Marius Gedminas:
 On Tue, Feb 19, 2008 at 04:46:29PM +0100, Hermann Himmelbauer wrote:
  class SearchFrom(z3c.form.EditForm):
 fields = z3c.form.field.Fields(copy.deepcopy(IPerson).select('name'))

 Strike out the deepcopy and you've got the correct solution:

   class SearchFrom(z3c.form.EditForm):
  fields = z3c.form.field.Fields(IPerson).select('name')

  However, this does not seem to work as still some things are referenced
  instead of copied, so copy.deepcopy seems to fail on interfaces.

 What are you trying to achieve?

 Zope 3 schema fields ought to be treated as immutable objects.

  What's your opinion on this, how do you apply this pattern?

 We don't modify fields, ever.  We use the power of zope.formlib (or
 z3c.form) to get dynamic forms.

Yes, I also use z3c.form, but my problem is that the field has the required 
flag set to True, which is appropriate for an add/edit form but may not be 
appropriate for a search form.

If I change the required flag on the field level, e.g. in the update() 
method, the change is permanent in the interface, which is not appropriate. 
And changing it on the widget level seems to be very complicated, at least, I 
found no way to do it.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] How do you develop in zope 3?

2008-02-19 Thread Hermann Himmelbauer
Am Dienstag, 19. Februar 2008 16:22 schrieb [EMAIL PROTECTED]:
 Hello, *

 How do you develop in zope 3?

 *) Is it the way the experienced zope developers work? How do you set the
 environment for a site or a package development?

I personally do it the old fashioned way: I downloaded the tarball, 
decompressed it and created a zope instance. This has some advantages, e.g. 
you have the Zope source code (which you urgently need to do Zope3 
development), you can put multiple applications on one instance and it's very 
simple to install (untar, make install, create instance).

I still have no deployment schema for my application, though, which is a major 
drawback.

 *) I'm working in more than a package. I'm developing a blog, a user
 manager, etc. Should I create a new project for each package? How do I
 include in my site (under development) my packages (under development)?

Good question - I don't use zopeproject, but I'd recommend to split up your 
packages if it is possible. This way, you may easily reuse packages in other 
projects. For including your packages, there are two ways:

1) You create eggs out of your packages and install them.
2) You simply link them into your zope instance, as described below.

 *) What recipe do you use to fetch a package via svn?

I simply check out the required package and link it in the lib/python 
directory of my zope instance and add the required zcml-files in the 
package-includes directory. I do this the same for my packages.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: AW: [Zope3-Users] How to check access on a view?

2008-02-18 Thread Hermann Himmelbauer
Am Sonntag, 17. Februar 2008 12:41 schrieb Roger Ineichen:
 Hi Hermann

  Betreff: Re: [Zope3-Users] How to check access on a view?

 [...]

   Hi,
   For a simple menu, I need to check if the current principal has
   permissions to access a view. I understand that I can use the
   canAccess()/canWrite() function on object attributes but
 
  how could I
 
   do this for views?

 import zope.security
 zope.security.canAccess(myView, '__call__') should work.
 Or if the view provides a render method, you can check
 zope.security.canAccess(myView, 'render').

Yes, many thanks, this did the trick!

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: AW: AW: [Zope3-Users] z3c.form - howto ignore the context for singlewidgets in an Edit form?

2008-02-18 Thread Hermann Himmelbauer
Am Sonntag, 10. Februar 2008 19:39 schrieb Roger Ineichen:
 Hi Christophe

  Betreff: Re: AW: [Zope3-Users] z3c.form - howto ignore the
  context for singlewidgets in an Edit form?

 [...]

   class ISubscribeSchema(zope.interface.Interface):
   The subscription form.
  
   password = zope.schema.Password(
   title=_(u'Password'),
   description=_(u'The password for the applicant.'),
   required=True)
  
   confirm = zope.schema.Password(
   title=_(u'Confirm password'),
   description=_(u'The password for the principal.'),
   required=True)
  
   @zope.interface.invariant
   def confirmPassword(task):
   if task.password != task.confirm:
   raise zope.interface.Invalid(
   _(Password doesn't compare with password
 
  confirmation.))
 
   if len(task.password)  6:
   raise zope.interface.Invalid(
   _(Password must be at least 6 characters long.))
  
   class SubcriptionForm/form.Form):
   Subscription form.
  
   ignoreContext = True
  
   fields = field.Fields(ISubscribeSchema)

 [...]

  On the other hand, the password is already used in the
  definition of the Principal (ex: in IInternalPrincipal), so
  you get overlapping definitions of the password, and you need
  to explicitly omit() the Principal password in the form generation.
  Or maybe you think it's better to use different schemas for
  the Principal itself and for the subscription?

 Yes, I think using a different schema for password confirmation
 is the right concept. This let us define a invariant in the schema too.
 Both the invariant and the confirmation field are not a part of
 the (real) data model. Of corse that's not the only one solution,
 but most of the time this works very well. It also allows you to
 use a very simple form implementation  without any magic widgets
 etc.

Yes, although a confirmation widget looked appealing at first, I also agree 
with Roger now and implemented this similar as shown above.

Back to z3c.formwidget: What do you think should this package exactly contain:

- Only widgets?
- Combinations of schemas and widgets?
- Also schemas without widgets (like an Email schema that inherits from a 
TextLine and thus uses a TextWidget)?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: AW: [Zope3-Users] eggsplosion again

2008-02-18 Thread Hermann Himmelbauer
Am Sonntag, 10. Februar 2008 15:09 schrieb Roger Ineichen:
 Hi Christophe

  Betreff: [Zope3-Users] eggsplosion again

 [...]

  But I fear that in a near future we will need to start any
  interfaces.py with :
  import zope.schema
  import foo.schema
  import bar.schema
  (...)
  import mycoolnamespace.schema

 I agree with your point that the implementations are
 found everywhere and that is hard to get the full picture
 of what's available and what's not.

 But I also think a package is not the right place to
 collect widgets or fields etc. Because this will very
 quickly end in unmanagable dependencies.

Well, but where would we put such quite generic stuff such an EMail field? I 
don't think it makes much sense to create some z3c.email package. And I can 
think of numerous generic and simple fields, e.g. for telephone numbers, a 
choice for the gender, etc.

What about the following layout:

- z3c.fields: extra fields but no widgets; The code does not depend on extra 
packages such as z3c.form etc. This would be a place for the EmailTextLine 
field, a Currency field etc. People developing packages would commit their 
specific fields to this package and use it from their package.
- z3c.formwidget: widgets for z3c.fields and also alternative widgets for 
fields.

In this case, I only have to import from z3c.fields and - in case I'd like to 
override widgets - register widgets for fields from z3c.formwidget.

Another advantage would be that we could provide skeletons (interfaces, 
classes, tests etc.) in these packages that show people how to implement 
their own fields/widgets in a good style.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] How to check access on a view?

2008-02-16 Thread Hermann Himmelbauer
Hi,
For a simple menu, I need to check if the current principal has permissions to 
access a view. I understand that I can use the canAccess()/canWrite() 
function on object attributes but how could I do this for views?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] login/logout with z3c.pagelet?

2008-02-12 Thread Hermann Himmelbauer
 Hi,

 Are there any login/logout/redirect templates for z3c.pagelet?

 I could reuse the templates from zope.app.authentication, but they
 obviously
 contain some macros that need some registrations I don't have, such as
 @@standard_macros. And my layout template does not contain any macro.
 Maybe there is some package with a layer that does this job?
 How are you doing?

I simply created a simple z3c.form based form that looks like this:

class LoginPage(ActionForm):
 Login logic and page 

template = ViewPageTemplateFile('pt/login.pt')
fields = form.field.Fields(IFYMUser).select('login', 'password')
prefix = login_data
unsuccessfulLogin = False

def __call__(self):
request = self.request
if (not IUnauthenticatedPrincipal.providedBy(request.principal)
and 'login_data.widgets.login' in request):
# Login succeeded!
camefrom = request.get('camefrom', '.')
request.response.redirect(camefrom)
else:
if 'login_data.widgets.login' in request:
# Something went wrong with the authentication
self.unsuccessfulLogin = True
return super(LoginPage, self).__call__()

@form.button.buttonAndHandler(_('Anmelden'), name='login')
def handleLogin(self, action):
data, errors = self.extractData()
if errors:
self.status = self.formErrorsMessage
return
if self.unsuccessfulLogin:
 raise ActionExecutionError(Invalid(
_(uUngültige Login/Passwort-Kombination!)))

@form.button.buttonAndHandler(_(u'Abbrechen'), name='abbrechen')
def handle_abbrechen(self, action):
self.request.response.redirect('index.html')

class LogoutPage(BrowserPagelet):
 Logout logic and page 

template = ViewPageTemplateFile('pt/logout.pt')

def update(self, nextURL=None):
if not IUnauthenticatedPrincipal.providedBy(self.request.principal):
auth = getUtility(IAuthentication)
ILogout(auth).logout(self.request)
site_path = absoluteURL(getSite(), self.request)
return self.request.response.redirect(site_path + '/logout.html')

My templates looks like this:

- login 

h2 i18n:translate= Anmelden /h2

p/

span tal:replace=structure view/errorstatus /

input tal:replace=structure view/widgets/login/snippets/div /
input tal:replace=structure view/widgets/password/snippets/div /

div class=buttons
 input tal:repeat=action view/actions/values
tal:replace=structure action/render
/
/div

 logout 

h2 i18n:translate=Abmelden/h2

p i18n:translate=
Sie sind nun vom System abgemeldet.
/p

Moreover, I have a link in my menu that points to the login/logout page,
(only logout if logged in and reverse).

However, I still have the problem that I don't know how to make Zope3
point to my login page in case unauthorized content is requested. Zope3
displays some Unauthorized - a sever error has occured page I don't know
where it comes from.

Best Regards,
Hermann

P.S.: Ah yes, the ActionForm is a simple form inheriting from form.Form
that ignores the context. And the input fields in the template rely on my
z3c.formsnippets package, which you can easily replace with your TAL code.

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form - howto ignore the context for single widgets in an Edit form?

2008-02-08 Thread Hermann Himmelbauer
Am Freitag, 8. Februar 2008 09:33 schrieb Christophe Combelles:
 Hermann Himmelbauer a écrit :
  Am Freitag, 8. Februar 2008 00:48 schrieb Stephan Richter:
  Right, that seems to be a perfect solution. Btw., it seems that there are
  quite some generic widget/field-patterns that a lot of people are needing
  - such as the PasswordConfirmationWidget. Or, in my case I need a
  special Email field, that inherits from TextLine and may also have some
  specific widget.
 
  So I'd suggest to open some repository, e.g. z3c.formwidgets where
  people can contribute their fields/widgets so that they can be reused by
  others. Moreover, this would also be a good entry point for people
  developing new widgets.

 Why not contributing directly into z3c.form ?  There are already too many
 packages. Splitting things into eggs was a good thing, but too many eggs is
 worse.  I suggest to do this in a branch of z3c.form, so that the new
 widgets could be quickly moved in the trunk.

Hmmm, that's for sure an option, however, I'd not like to see that people 
contributing widgets would accidentally break z3c.form, moreover, I got the 
impression that z3c.form aims to be very generic and therefore should not 
deal with anything specific like an email widget.

What's your opinion on this, Stephan?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Zope eggification - impressions

2008-02-08 Thread Hermann Himmelbauer
Am Freitag, 8. Februar 2008 10:10 schrieb Kai Diefenbach:
 I've also started to dive into plain Zope 3 development (coming from
 Plone) and I like it very much. But as you mentioned I also found it
 somewhat hard to start. What I have found helpful so far is:

Thanks for the links!

 Code examples:
 - http://svn.zope.org/z3c.formdemo/trunk/src/z3c/formdemo/

Yes, z3c.form, z3c.pagelet etc. are really a good thing!

 - http://tinyurl.com/3cdlyp
   (BTW: I wasn't aware that there is a 3rd edition)

Really? I did not know this too, does someone know what's new in Philipps  3rd 
Edition?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] z3c.form - howto ignore the context for single widgets in an Edit form?

2008-02-07 Thread Hermann Himmelbauer
Hi,
I'm creating a simple user-administration, which requires the user to type in 
the password and a password confirmation. For that, I have an interface which 
contains the attributes password and password_confirm. Of course, only 
the password is stored as an object attribute.

When I now use form.EditForm for editing this object, z3c.form raises an error 
as it cannot find the required attribute in the context for 
the password_confirm widget.

What's the suggested way to circumvent this problem?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Zope eggification - impressions

2008-02-07 Thread Hermann Himmelbauer
Am Donnerstag, 7. Februar 2008 17:36 schrieb Philipp von Weitershausen:
 Hermann Himmelbauer wrote:
  At first, thanks to the newest Zope-3.4.0c1 release. I just installed it
  from the tarball and it seems to work.
 
  However, I'm still somehow technically overwhelmed by installing Zope3
  the egg-style way - maybe it's not that hard, but I can't really find a
  good entry point to that topic.

 http://pypi.python.org/pypi/zopeproject

To be honest, I know that already but did not have a deep look at it as 
zopeproject seems to be a setup for one application, while I currently use 
one Zope server for multiple applications, therefore I still stick to the 
tarball.

What I wanted to point out is not that there is no documentation for specific 
technology but that there is no meta-documentation that points out what 
exists and what I should use - especially not on the zope.org website.

But I appreciate a lot that the zope.org website will be overhauled, giving 
Zope3 more focus, maybe this will solve the problem.

Btw., I very nice addition would be to point out applications people created 
with Zope3. The only ones I am aware of is schooltool and (I 
think) lovelybooks, so for newcomers it's always great to see what can be 
done with the technology.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form - howto ignore the context for single widgets in an Edit form?

2008-02-07 Thread Hermann Himmelbauer
Am Freitag, 8. Februar 2008 01:33 schrieb Christophe Combelles:
 Stephan Richter a écrit :
  On Thursday 07 February 2008, Christophe Combelles wrote:
  Maybe the best way to have a password validation would be to let the
  PasswordWidget display two password fields and check itself the values
  are the same?
 
  Bingo. :-) I Would implement a PasswordConfirmationWidget. Then you have
  a special converter that throws an error, if the passwords do not match.

 I have written a very basic confirmation with only javascript, that does
 not enforce password equality but just warns the user, and that should be
 sufficient in most case.
 This is a template that just has to be registered for PasswordWidget,
 without implementing a new widget:
 http://kelpi.com/script/10992d

 z3c:widgetTemplate
  template=password_input.pt
  mode=input
  layer=myapp.interfaces.IMyLayer
  widget=z3c.form.browser.password.PasswordWidget /

 If a PasswordConfirmationWidget was implemented, the javascript code should
 probably be moved into the widget view class.

If I understand it right, your solution would alter all password widgets in 
your application, right? Hmmm, I have also a case when there should be only a 
single password field, e.g. for the login-page or for changing the password 
(old password, new password, confirmation of new password). 

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form - howto ignore the context for single widgets in an Edit form?

2008-02-07 Thread Hermann Himmelbauer
Am Freitag, 8. Februar 2008 00:48 schrieb Stephan Richter:
 On Thursday 07 February 2008, Christophe Combelles wrote:
  Maybe the best way to have a password validation would be to let the
  PasswordWidget display two password fields and check itself the values
  are the same?

 Bingo. :-) I Would implement a PasswordConfirmationWidget. Then you have a
 special converter that throws an error, if the passwords do not match.

Right, that seems to be a perfect solution. Btw., it seems that there are 
quite some generic widget/field-patterns that a lot of people are needing - 
such as the PasswordConfirmationWidget. Or, in my case I need a 
special Email field, that inherits from TextLine and may also have some 
specific widget.

So I'd suggest to open some repository, e.g. z3c.formwidgets where people 
can contribute their fields/widgets so that they can be reused by others. 
Moreover, this would also be a good entry point for people developing new 
widgets.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] SessionCredentialsPlugin + z3c.pagelets/z3c.form

2008-02-04 Thread Hermann Himmelbauer
Hi,
I'm currently trying to integrate the SessionCredentialsPlugin with 
z3c.pagelets / z3c.form. I currently set up a simple z3c.form-based login 
page and configured the loginfield/passwordfield 
to form.widgets.login/password. Now I can login, but I still have some 
problems:

1) I'd like to be redirected to the login field when the user accesses 
unauthorized pages. This seems not to work as there is the following error:

TypeError: There isn't enough context to get URL information. This is probably 
due to a bug in setting up location information.

Moreover, I'd like to redirect the user to the original page, would I 
implement this in the form's update() method or somewhere else?

2) I'd like to display some error in the login page, e.g. incorrect 
login/password combination in case the user enters invalid data - how could 
this be handled?

3) How could I implement a logout button/page?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Zope translation status

2008-02-04 Thread Hermann Himmelbauer
Am Montag, 4. Februar 2008 22:51 schrieb Christophe Combelles:
 Below is the translation status of Zope 3.4.0c1,
 as generated by the i18nstats tool.

 Is there anyone willing to update the translation for his/her language
 before 3.4.0 final is (soon) released?

Maybe I could do so for german (although there's only 0.3% missing) if you 
tell me how to do and where to start...

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Beginner: Reference to ZPT macros

2008-01-16 Thread Hermann Himmelbauer
Am Mittwoch, 16. Januar 2008 19:27 schrieb Achim Domma:
 Hi,

 I have a simple view. Here is the entry in configure.zcml:

browser:page
for=.CMS.Page
name=index.html
class=.CMS.PageView
permission=zope.Public
template=index.pt
menu=zmi_views
title=Default View
/

 The view works fine so far, but now I want to use a template macro to
 implement a common layout. So I created a layout.pt in the same
 folder as index.pt. In index.pt I try to reference layout.pt like this:

 div xmlns:metal=http://xml.zope.org/namespaces/metal; metal:use-
 macro=context/@@layout.pt/macros/default_layout
  div metal:fill-slot=content
  div tal:content=structure view/html_content/div
  /div
 /div

 Now I get an TraversalError but I could not figure out why. How do I
 have to reference layout.pt? Do I have to register the emplate
 somehow? I work with Philips book, but he uses a template created via
 ZMI in his example.

Hav a look at skin/standardmacros.py in the worldcookery examples: There you 
can see the mechanism that allows other pages to access the macros.

I personally don't like macros that much, therefore I prefer Stephan Richters 
pagelet/viewlet approach, which you can find in z3c.pagelet.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] how to model a 1-to-1 relation

2008-01-11 Thread Hermann Himmelbauer
Am Donnerstag, 10. Januar 2008 23:00 schrieb john saponara:
 I want to allow the user to create car and driver objects in a
 limoService container.  Car objects will stand alone, but each driver
 object should contain a car object by reference (not by value) and the
 driver add form should allow the user to choose which car the new driver
 object will have.  Should IDriver's car attribute be a schema.Object or
 a schema.Choice?

That's an interesting question, as I currently have a similar problem. It 
seems that if you store one object mulitple times in the ZODB, it does not 
duplicated it but stores only references. I tested that, however, I'm unsure 
if ZODB can really handle this in all situations.

If this proves to work, things are quite easy, as one can do things like that:

class Driver(BTreeContainer):
A BTreeContainer for Drivers

# A car is owned by two drivers:

driver1 = Driver()
driver2 = Driver()
mycar = Car()

driver1['mycar'] = mycar
driver2['mycar'] = mycar

Another issue I still have to sort out are permissions for this case, e.g. 
driver1 and driver2 may set attributes, but driver3 who does not own the car, 
may not. One way would perhaps be to permit a driver modification of all 
objects in his driver-container.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] How to store objects with multiple owners in the ZODB

2008-01-08 Thread Hermann Himmelbauer
Hi,
I have the following scenario here (somehow similar to hard links on a UNIX 
system):

- Users should be able to create documents (then they are owners)
- Users may grant ownership of their document to other users
- Users may abandon their document (no owner)
- Documents, who have no owner, are deleted
- Users may list 

My question is: How would I store these documents in the ZODB? If I create a 
container object for each user and store the document there, how would then 
other users get a link to their own folder? Moreover, what happens if the 
original owner abandons the document?

If I have one huge container that holds all documents, how would then list 
users their documents?

The other issue is how to set up permissions on these objects, would I e.g. 
store the owners along with the object (e.g. as an object attribute)?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Building a viewlet-based menu

2008-01-04 Thread Hermann Himmelbauer
Hi,
I'm currently trying to build a viewlet-based menu. As any common menu, it 
should consist of entries, which link in my case to certain object views. If 
such a link is clicked, the menu entry should change (no link) to denote that 
the entry is selected.

Therefore I built a base class that looks like the following:

class MenuEntryViewlet(ViewletBase):

def update(self):
site_path = absoluteURL(getParent(getSiteManager(self)), self.request)
self.link = site_path + self.link

render = ViewPageTemplateFile('pt_desktop/menuentry.pt')

def iscurrent(self):
current_url = absoluteURL(getParent(getParent(self)), self.request)
if current_url == self.link:
return True
else:
return False

The page template either returns an entry with a link or without one, 
regarding to view/iscurrent. Now I can inherit menu entries and configure 
them to show up in the menu like this:

class ME_Home(MenuEntryViewlet):

label = uStartseite
link = /index.html  # Relative to my Site Object

My problem is that the update() function which sets the link does not always 
work. The link should always include the URL of the local site object, which 
is does not when a 404 page is displayed, therefore all menu entries have 
invalid links.

Does anyone know why, or does someone have a better suggestion to my problem?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] How to persist an attribute of list type

2007-12-02 Thread Hermann Himmelbauer
Am Freitag, 30. November 2007 19:34 schrieb Yuan HOng:
 Hi,

 It seems that I can not get list attribute of an persistent object
 changed. I have the following class, which has a list as one of its
 attributes:

 class Cart(Persistent):
 items = []
 amount = 0

Hehe, I had the same pitfall some weeks ago...

This has nothing to do with persitence, the problem is that you are assigning 
the dictionary to the class and not to the class instance (= the object). For 
that reason, strange things will happen, e.g.:

c1=Cart()
c2 = Cart()
c1.items.append(abc)
c2.items
['abc']

So, I follow this pattern:

class Cart(Persistent):
  items = None
  def __init__(self):
self.items = []

My problem was that I was so much focussed on Persistence, that I forgot about 
this quite simple Python issue...

;-)

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] How to close a ZODB connection and reopen it for testing?

2007-11-19 Thread Hermann Himmelbauer
Hi,
I am currently writing a doctest for one of my persistent classes. It's 
purpose is to check, if object modifications, e.g. through methods, are 
really persistent, however, my objects are magically remembered, therefore I 
cannot properly test them.

My doctest looks like this:

  from ZODB import FileStorage, DB
  storage = FileStorage.FileStorage('tests/tmp/test.fs')
  db = DB(storage)
  conn = db.open()
  dbroot = conn.root()
  x = myClass()
  dbroot['x'] = x

Now I can do some modifications of my object, call some methods which modify 
the object and call transaction.commit().

Next I want to somehow close the database, reopen it, read my object and check 
if my modifications were really stored, e.g.:

  conn.close()
  db.close()
  conn = db.open()
  dbroot = conn.root()
  y = dbroot['x']

But unfortunately, the following applies:

  x is y
 True

This is bad, as it means that Python/ZODB magically remembered my object and 
did not reread it from the database. Therefore I cannot correctly check 
persistence issues.

What is the suggested solution to this?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: Zope 3 w/ SQLAlchemy 0.4 (was Re: [Zope3-Users] Eggs and classic instance homes, again...)

2007-11-09 Thread Hermann Himmelbauer
Am Freitag, 9. November 2007 18:44 schrieb Jeff Shell:
 On Nov 9, 2007 12:04 AM, Hermann Himmelbauer [EMAIL PROTECTED] wrote:
  Am Freitag, 9. November 2007 01:31 schrieb Jeff Shell:
   - zope.component 3.4.0  (or anything built into the zope 3.4
   tarball) - sqlalchemy 0.4.0
   - simplejson
 
  Btw., how do you integrate Zope3 with SQLAlchemy 0.4? As far as I
  know zalchemy is not SQLAlchemy-0.4 ready yet?

 We have an in-house solution/framework. And it's actually not ready
 for SQLAlchemy 0.4 yet either :). I do have a branch for it, but I
 haven't been working on any major RDBMS backed projects lately. The
 above list was more of an example than a list of requirements from any
 existing app.

 For core connection and integration, I take a lot of inspiration from
 zalchemy and some other toolkits, and the last bit of work I did
 towards SQLAlchemy 0.4 integration came from there.

Thanks for the reply - I just recognized, that z3c.sqlalchemy seems to be 
SA-0.4 ready, at least the CHANGES.txt states:

WARNING: this version requires SA 0.4.X and higher

Perhaps I'll try my luck with that one instead of zalchemy - they don't seem 
to be that different, at least not for the basic things (transaction handling 
etc.).

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Eggs and classic instance homes, again... (was Re: Eggs, workingenv.py, and 'classic' instance homes)

2007-11-08 Thread Hermann Himmelbauer
Am Freitag, 9. November 2007 01:31 schrieb Jeff Shell:
 Oops. Forgot to send this to the list as well as Stephan. Goddamn Gmail.

 On Nov 8, 2007 8:28 AM, Stephan Richter [EMAIL PROTECTED] 
wrote:
  Hi Jeff,
 
 - zope.component 3.4.0  (or anything built into the zope 3.4 tarball)
 - sqlalchemy 0.4.0
 - simplejson

Btw., how do you integrate Zope3 with SQLAlchemy 0.4? As far as I 
know zalchemy is not SQLAlchemy-0.4 ready yet?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] How to best include Zope3-based code in Zope3 unrelated Python projects?

2007-09-21 Thread Hermann Himmelbauer
Hi,
I have the problem that I cannot include parts of my Zope3 project in 
external, Zope3-unrelated projects due to import errors.

For instance, I currently build a LaTeX converter that automatically converts 
SQL-Alchemy table definitions into nicely formatted LaTeX that I can then 
include in my project documentation.

This converter has to import my table definitions file, which however fails, 
as on the top of the file there are Zope3-specific imports and directives, 
e.g.:

from zope.interface import implements
import z3c.zalchemy
metadata = z3c.zalchemy.metadata()

My Python interpreter does not know anything about zope yet, as it's not in 
the PYTHONPATH, therefore the import of zope.interface fails. I assume, I 
should somehow put the Zope3 modules into the PYTHONPATH - but how would you 
recommend that? Should I perhaps link it from python/lib/site-packages? Or 
should I include the Zope3 top-level directory into PYTHONPATH?

Moreover, what's even more complicated is the import of z3c.zalchemy, how 
should I solve that one? I thought about a construct like this:

if ???started via debugzope / zopectl???:
   import z3c.zalchemy
   metadata = MetaData()
else:
   from sqlalchemy import MetaData
   metadata = MetaData()

But I don't know how to fomulate the if-clause above. Perhaps there's a better 
solution to this problem?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Interfaces with circular references

2007-09-21 Thread Hermann Himmelbauer
Hi,
Does someone know how to create interfaces with circular references?

E.g.:

class IHusband(Interface):
   wife = Object(schema=IWife)

class IWife(Interface):
   husband = Object(schema=IHusband)

What's the suggested solution to this problem?

Perhaps I should modify the classes after they are declared, e.g.:

class IHusband(Interface):
   pass

class IWife(Interface):
   pass

IHusband.wife = Object(schema = IWife)
IWife.husband = Object(schema = IHusband)

Or is there a better solution?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Implementing a DropdownWidget for a country-code vocabulary

2007-09-17 Thread Hermann Himmelbauer
Am Samstag, 15. September 2007 18:08 schrieb Jesper Petersen:
 Hello!I'm trying to implement a DropdownWidget for my country list. In my
 app i'd like to have a dropdown menu where a user can choose a country (for
 my main content object, a job). My vocabulary is created from a list of
 strings, and stored in a local utility:


 SimpleVocabulary.fromValues( [u'AD', u'AE', 'AF', ...] )


 But in my dropdown widget i want to display the country name for each
 option too.. and not just the same value on both the value attribute and
 inside the element:

 option value=ADAndorra/option

Perhaps I misunderstand your question, but AFAIK vocabulary support this 
scenario. In my application, I also have a country drop-down that is in my 
case filled from a relational database. The vocabulary looks like this:

def landVocabulary(obj):
Get ktoids and ktonrs from session
session = zalchemy.getSession()
laender = session.query(Land)
laender_terms = []
for n, land in enumerate(laender):
laender_terms.append(vocabulary.SimpleVocabulary.\
 createTerm(land.landid,
n,
land.name))
return vocabulary.SimpleVocabulary(laender_terms)

# Make function a vocabulary factory
alsoProvides(landVocabulary, IVocabularyFactory)

and in my configuration:

utility
component=.utils.landVocabulary
name=landVocabulary
/

Now I can use this vocabulary from any interface.

Best regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] zalchemy with sqlalchemy 0.4 support?

2007-09-10 Thread Hermann Himmelbauer
Am Sonntag, 9. September 2007 09:55 schrieb Christian Theune:
 Hi,

 Am Samstag, den 08.09.2007, 20:46 +0200 schrieb Peter Piehler:
  Does anybody know if there is a zalchemy version, which supports
  sqlalchemy 0.4?

 There isn't, right now. 0.4 introduced some incompatibilities.

  At this time the following error occurs:
  Error: There is a version conflict.
  We already have: SQLAlchemy 0.4.0beta5
  but z3c.zalchemy 0.2dev-r79489 requires 'SQLAlchemy=0.3.9,0.4dev'.
 
  But I need some features from sqlalchemy 0.4.

 Which features are those? We have some plans on making the two-phase
 commit available in the data manager when making compatibility with 0.4.

Well, I also would very much appreciate 0.4 compatibility as in my case I have 
to use a database engine for the RDB MaxDB that is unavailable in 0.3.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] PAU / credentials / authentication

2007-09-05 Thread Hermann Himmelbauer
Hi,
After thoroughly studying Philipp's book and the PAU-doctests, I unfortunately 
still have no clue how to do my authentication. My (simple) scenario is the 
following:

- I wrote a Zope package that can be added as a site
- I have one Zope instance with several of these sites
- Users should authenticate site-specific, e.g. users that authenticated for 
site A should not automatically be authenticated for site B and never for the 
Zope root
- I want to use Session Credentials
- I wrote an authenticator plug-in for an existing relational database that 
looks like this:

class PasswdAuthenticator(Persistent):
implements(IPasswd, IAuthenticatorPlugin, ILocation)
__parent__ = __name__ = None

def authenticateCredentials(self, credentials):
if not (credentials and 'login' in credentials and
'password' in credentials):
return
login, password = credentials['login'], credentials['password']
if relation_db_check(login,passwd):
return PrincipalInfo()

Now I have to glue all this together, but how?

Do I need a local, site specific PAU? If yes, how do I create/store one 
without the ZMI? I want that to automatically be done during site creation, 
e.g. via a subscriber (I have already one that builds the basic site 
structure). Probably a PAU is created like this:

pau = zope.app.authentication.PluggableAuthentication('myprefix_')

But - how do I add this to my site manager then? Have the prefixes to be 
different for every PAU that are located in the different sites?

How do I enable Session Credentials, or are they already enabled?

And - how do I tell the PAU to use my authentication utility, perhaps I have 
to create one and somehow place it into the PAU, as it's a container? Or 
should I register it as a local utility? Or as a global utility? In case of a 
utility, the Authenticator Plugin probably does not have to inherit from 
persistent.Persistent?

Moreover Philipp's book states that available plug-ins need to be configured 
but I don't know to do this without the ZMI?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form / TextLine-Schema in List-Schema

2007-09-03 Thread Hermann Himmelbauer
Am Sonntag, 2. September 2007 18:26 schrieb Markus Leist:
 Hi list,

 z3c.form has a very generic, well approach - but at the moment it's to
 complicated to me.

 I have an interface defined like:

 100   osList = List (
 101   title = _(operating systems),
 103   value_type = TextLine(
 105   title = _(Operatingsystem),
 107   default = u,
 108   required = False),
 109   required = False)
 [originally from
 http://trac.ict-ok.org/browser/trunk/org/ict_ok/components/host/interfaces.
py ]

 when z3c.form will do his update, i'll get a

 ComponentLookupError: (
   (zope.schema._field.List object at 0x989054c,
zope.schema._bootstrapfields.TextLine object at 0x989090c,
zc.resourcelibrary.publication.Request instance
 URL=http://localhost:8081/cc071bd954f8fd7b3fccf9fab2b1c7b58/add_host.html)
, InterfaceClass z3c.form.interfaces.IFieldWidget, u'')
 [full trace on http://paste.lisp.org/display/47105 ]

I think I know that one: Your request object hast to be marked with the 
appropriate interface, in this case it's IFormLayer.

I recommend you to have a decent look at z3c.formdemo.

To sum my z3c.form-experience up: In the beginning it's quite hard and 
complicated, although the documentation is good. One has to deeply understand 
the component-based software design (Interfaces, Adapters etc.) and other 
packages (e.g. pagelets). However it pays off later on, because other 
alternatives (e.g. formlib) are too limiting for many use cases.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Creating edit form with z3c.form

2007-08-20 Thread Hermann Himmelbauer
Am Montag, 20. August 2007 12:09 schrieb Florian Lindner:
 Am Sonntag, 19. August 2007 schrieb Hermann Himmelbauer:
  Am Samstag, 18. August 2007 12:53 schrieb Florian Lindner:
  Hmmm, perhaps the browser request is not marked with the IFormLayer
  layer? (Hence you need a skin that derives from it.)

 It's a real browser request (not generated by some piece of test code, but
 from a real browser) with no layer (thus the default layer). Moreover
 mostly indentical code that uses formlib works perfectly.

As far as I know, formlib-based forms work with the default layer, while 
z3c.form-based forms need the IFormLayer.

I recommend you to have a look at the z3c.formdemo package, there you will 
find working z3c.form examples which you can then clone.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Creating edit form with z3c.form

2007-08-18 Thread Hermann Himmelbauer
Am Samstag, 18. August 2007 12:53 schrieb Florian Lindner:
 Hello,
 I try to create an edit form with z3c.form but it gives me an system error
 only:

   File /home/florian/Desktop/zope/lib/python/z3c/form/form.py, line 120,
 in updateWidgets
 self.widgets = zope.component.getMultiAdapter(
   File /home/florian/Zope3/src/zope/component/_api.py, line 103, in
 getMultiAdapter
 raise ComponentLookupError(objects, interface, name)
 ComponentLookupError: ((zope.app.publisher.browser.viewmeta.EditEntry
 object at 0x9f6c68c, zope.publisher.browser.BrowserRequest instance
 URL=http://localhost:8080/Blog/2007_08_16_abc/EditEntry.html,
 Blog.blog.BlogEntry object at 0x9264d2c), InterfaceClass
 z3c.form.interfaces.IWidgets, u'')
 127.0.0.1 - - [18/Aug/2007:12:45:24
 +0200] GET /Blog/2007_08_16_abc/EditEntry.html HTTP/1.1 500
 89 - Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.7 (like
 Gecko)
 127.0.0.1 - - [18/Aug/2007:12:45:25 +0200] GET /favicon.ico HTTP/1.1 404
 4159 - Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.7 (like
 Gecko)

Hmmm, perhaps the browser request is not marked with the IFormLayer layer? 
(Hence you need a skin that derives from it.)

Moreover I think you have to use pagelets instead of browser pages for your 
form?

Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form: Howto include validation errors into a custom pagetemplate?

2007-08-14 Thread Hermann Himmelbauer
Am Dienstag, 14. August 2007 12:45 schrieb Peter Piehler:
 Hello,

 i have a  spreadsheet like z3c.formdemo spreadsheet.
 I copy and paste
 ul class=errors
 tal:condition=view/widgets/errors
 metal:define-macro=errors
   li tal:repeat=error view/widgets/errors
 tal:block condition=error/widget
   span tal:replace=error/widget/label /:
 /tal:block
 span tal:replace=structure error/renderError Type/span
   /li
 /ul
 from formui.table-form.pt into my pagetemplate. view/widgets/errors
 seems to be empty but validation error occurs.
 What should i do to display validation errors?

Are you sure that view/widgets/errors are empty? I'd recommend to check that 
in the view class - maybe it's only a pagetemplate problem.

Moreover there was some problem with z3c.form + invariants, so if you use 
invariants, I'd recommend you to upgrade to the latest SVN-Version of 
z3c.form / z3c.formui.

At least for me, validation works.

Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Strange ZODB error - Solved: Zalchemy bug

2007-08-13 Thread Hermann Himmelbauer
Am Montag, 13. August 2007 08:10 schrieb Christian Zagrodnick:
 On 2007-08-09 17:21:57 +0200, Christian Zagrodnick

 [EMAIL PROTECTED] said:
  On 2007-08-09 16:27:23 +0200, Hermann Himmelbauer
 
  [EMAIL PROTECTED] said:
  Am Donnerstag, 9. August 2007 15:44 schrieb Hermann Himmelbauer:
  Hi,
  After updating some z3c packages and changing some of my code, I recei
 
  ve a
 
  very strange traceback from Zope3:
 
  Ah, after fiddling around I found out that the svn update of the
  zalchemy package resulted in this error. If somewhere in my code
  zalchemy is used, the TypeError emerges. It seems that recently there
  was a change to the zalchemy package (svn log):
 
  ---
 
  -
 
  r78682 | zagy | 2007-08-08 10:53:01 +0200 (Mi, 08 Aug 2007) | 1 line
 
  using the threadlocal strategy of sqlalchemy instead of creating one en
 
  gine per
 
  thread. This allows connection pooling for instance.
  ---
 
  -
 
  I reverted zalchemy to an older version an all is well again.
 
  Interesting. I wonder why this happens. I'll try to reproduce.

 So it happend when the ZAlchemy engine was used as a local utility.

Yes, that's right.

 Hermann, could you check if it works now?

I updated zalchemy it to the current SVN-Version, but it does still not work. 
However, the error message is different and a lot more verbose:

--
2007-08-13T11:01:03 INFO sqlalchemy.engine.threadlocal.TLEngine.0x..d0 
{'fp_name1': 'A%'}
2007-08-13 11:01:03,777 INFO sqlalchemy.engine.threadlocal.TLEngine.0x..d0 
COMMIT
--
2007-08-13T11:01:03 INFO sqlalchemy.engine.threadlocal.TLEngine.0x..d0 COMMIT
--
2007-08-13T11:01:03 CRITICAL txn.1082132800 A storage error occurred during 
the second phase of the two-phase commit.  Resources may be in an 
inconsistent state.
--
2007-08-13T11:01:03 ERROR txn.1082132800 Error in tpc_abort() on manager 
z3c.zalchemy.datamanager.AlchemyDataManager object at 0x42b30d0
Traceback (most recent call last):
  
File /local/home/dusty/Zope-3.4.0b1/lib/python/transaction/_transaction.py, 
line 462, in _cleanup
rm.tpc_abort(self)
  File /home/dusty/prog/zope3-inst/lib/python/z3c/zalchemy/datamanager.py, 
line 222, in tpc_abort
self._cleanup()
  File /home/dusty/prog/zope3-inst/lib/python/z3c/zalchemy/datamanager.py, 
line 236, in _cleanup
util._resetEngine()
  File /home/dusty/prog/zope3-inst/lib/python/z3c/zalchemy/datamanager.py, 
line 64, in _resetEngine
self.engine = None
  File /local/home/dusty/Zope-3.4.0b1/lib/python/ZODB/Connection.py, line 
927, in register
self._register(obj)
  File /local/home/dusty/Zope-3.4.0b1/lib/python/ZODB/Connection.py, line 
937, in _register
self.transaction_manager.get().join(self)
  
File /local/home/dusty/Zope-3.4.0b1/lib/python/transaction/_transaction.py, 
line 222, in join
raise ValueError(expected txn status %r or %r, but it's %r % (
ValueError: expected txn status 'Active' or 'Doomed', but it's 'Committing'
--
2007-08-13T11:01:03 ERROR txn.1082132800 Failed to abort resource manager: 
z3c.zalchemy.datamanager.AlchemyDataManager object at 0x42b30d0
Traceback (most recent call last):
  
File /local/home/dusty/Zope-3.4.0b1/lib/python/transaction/_transaction.py, 
line 476, in abort
rm.abort(self)
  File /home/dusty/prog/zope3-inst/lib/python/z3c/zalchemy/datamanager.py, 
line 205, in abort
self._cleanup()
  File /home/dusty/prog/zope3-inst/lib/python/z3c/zalchemy/datamanager.py, 
line 236, in _cleanup
util._resetEngine()
  File /home/dusty/prog/zope3-inst/lib/python/z3c/zalchemy/datamanager.py, 
line 64, in _resetEngine
self.engine = None
  File /local/home/dusty/Zope-3.4.0b1/lib/python/ZODB/Connection.py, line 
927, in register
self._register(obj)
  File /local/home/dusty/Zope-3.4.0b1/lib/python/ZODB/Connection.py, line 
937, in _register
self.transaction_manager.get().join(self)
  
File /local/home/dusty/Zope-3.4.0b1/lib/python/transaction/_transaction.py, 
line 216, in join
self._prior_operation_failed() # doesn't return
  
File /local/home/dusty/Zope-3.4.0b1/lib/python/transaction/_transaction.py, 
line 210, in _prior_operation_failed
raise TransactionFailedError(An operation previously failed, 
TransactionFailedError: An operation previously failed, with traceback:

  File /local/home/dusty/python/Python-2.4.4/lib/python2.4/threading.py, 
line 442, in __bootstrap
self.run()
  File /local/home/dusty/python/Python-2.4.4/lib/python2.4/threading.py, 
line 422, in run
self.__target(*self.__args, **self.__kwargs)
  
File /local/home/dusty/Zope-3.4.0b1/lib/python/twisted/python/threadpool.py, 
line 148, in _worker
context.call(ctx, function, *args, **kwargs)
  File /local/home/dusty/Zope-3.4.0b1/lib/python/twisted/python/context.py, 
line 59, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File

Re: [Zope3-Users] Invariants and forms

2007-08-13 Thread Hermann Himmelbauer
Am Montag, 13. August 2007 12:01 schrieb Darryl Cousins:
 Hi,

 This was answered recently me thinks.

 http://mail.zope.org/pipermail/zope3-users/2007-August/006648.html

I think this covers a z3c.form-related issue, but not formlib...

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] z3c.form - how to raise/create an error in an action?

2007-08-13 Thread Hermann Himmelbauer
Hi,
I have a case where an error may occur in the form-action method (z3c.form, 
not formlib!), e.g. when data is not found in my database. I'd then like to 
output this error, similar when a widget error occurs. Moreover there are two 
simple cases:

1) Errors that are related to a widget (hence the error should be shown along 
with the widget)
2) Errors which are unrelated to the widget (like an Invariant).

Is there a simple way to accomplish this?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form - how to raise/create an error in an action?

2007-08-13 Thread Hermann Himmelbauer
Am Montag, 13. August 2007 19:42 schrieb Stephan Richter:
 On Monday 13 August 2007 12:02, Hermann Himmelbauer wrote:
  I have a case where an error may occur in the form-action method
  (z3c.form, not formlib!), e.g. when data is not found in my database. I'd
  then like to output this error, similar when a widget error occurs.
  Moreover there are two simple cases:
 
  1) Errors that are related to a widget (hence the error should be shown
  along with the widget)
  2) Errors which are unrelated to the widget (like an Invariant).

 Hi Hermann,

 could you elaborate a little bit more? I think a step-by-step description
 of how *you* envision it to work would be great as well as a very specific
 use case of what you are trying to do.

Well, in my specific case, I have a search form for persons that queries (via 
zalchemy) a relational database and saves the result on the view object. Then 
I have a page template that displays this object.

My form also has an interface with some input fields, which are validated via 
the schema and I also have an invariant. In case there's an error, there is 
the error macro in the formui page template that displays these errors, which 
is fine. In my form there are three input fields after which can be searched:

1) A unique person ID (in case the user already knows it). This field has 
precedence.
2) A surename and name field (which may give multiple results)

Then I have a search button and a corresponding action. In this action, a 
DB-search is performed. There are two error cases:

1) The user enters an ID, which is invalid/unknown. In this 
case, invalid/unknown ID should be denoted for the widget and in the form 
status.
2) The user enters the name. In case there are no matching records, a not 
found error message should be displayed in the form status, which is not 
widget-related.

What I would favor is that the error-macros of the formui package can be 
reused, hence I need the same error objects in the view. Therefore I have to 
somehow set these errors. My first thought was to do it the following way 
(for the two cases):

1) Widget-specific error: Somehow set the error field, e.g. in the action:

self.widgets['myIDfield'].error=Invalid/unknown ID
Another variant would be to raise a specific error, like this:

raise WidgetActionError(['myIDfield', 'invalid/unknown ID'])

2) Generic error: Raise an exception, similar like in invariants:

raise Invalid(No data was found)

 My initial reaction is: This really needs to be supported by the API. Once
 I have more details, I will either implement an API for this or give you a
 response on how to do it in your code.

Great! Thanks a lot for your quick reply!

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Using zope.formlib for a search form

2007-08-10 Thread Hermann Himmelbauer
Am Freitag, 10. August 2007 04:14 schrieb Andrew Groom:
 Hi All,

 I've been battling with formlib for the last three days now and, while

Uh oh, sorry, formlib. 

My example was based on z3c.form.

Anyway, I would recommend you to have a decent look at this library, as I 
struggled a lot with formlib beforehand (due to very similar problems) and am 
much more content with z3c.form as it is much more flexible and adaptable.

z3c.form is very nicely documented and there are various demos (z3c.formlib), 
however, it also takes quite some time to get into it. (At least for me).

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Using zope.formlib for a search form

2007-08-10 Thread Hermann Himmelbauer
Am Freitag, 10. August 2007 04:14 schrieb Andrew Groom:
 Hi All,

 I've been battling with formlib for the last three days now and, while
 I've learnt a lot, it's nearly driven me crazy. I'm trying to use it to
 create simple search form, i.e., a form that does input validation,
 remembers the values you entered, etc., but is not tied to a persisted
 object.

 I've got the form rendering and processing requests, but I'm completely
 stuck on getting the form to remember the values I just entered after a
 form post.

 Has anyone got any suggestions ? Here's what I've got so far, the latest
 attempt being to use a dummy object to provide the context, which also
 doesn't seem to work:

Yes, I do the same and use a self-made class, called ActionForm for that, 
it's quite simple:

class ActionForm(Formframe, form.Form):
 Generic form for context-less patterns 

def updateWidgets(self):
self.widgets = getMultiAdapter(
(self, self.request, self.getContent()), IWidgets)
self.widgets.ignoreContext = True
self.widgets.update()

Then I have a persisten object, that acts as an entry point to my view, and 
which may provide various methods, e.g.:

class SearchData(persistent.Persistent):
   implements(ISearchData)

   def search_data(self, **kd):
   # Here the data is retrieved, in my case from a relational database
   return data

And then there's the view:

class ViewSerachKunde(ActionForm):
formErrorsMessage = _('There were some errors.')

template = ViewPageTemplateFile('pt/searchdata.pt')
   
fields = field.Fields(IViewSearchData)

# If data is found, it's stored in a view-object-attribute
found_data = None

@button.buttonAndHandler('Search', name='search')
data, errors = self.extractData()
if errors:
self.status = self.formErrorsMessage
return
self.found_data = self.context.search_data(**data)

And then in my template file I have something like this (please note that I 
use a custom library for displaying fields (formsnippet):

--! This displayes the search-widgets --
span tal:repeat=widget view/widgets/values
  span tal:replace=structure widget/snippets/div /
/span

--! And this displays the found data --
div tal:condition=view/found_data
  h2Found Data:/h2
span tal:replace=structure view/found_data/
/div

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Problems importing zalchemy

2007-08-10 Thread Hermann Himmelbauer
Am Freitag, 10. August 2007 08:28 schrieb Christian Theune:
 Hey,

 Am Freitag, den 27.07.2007, 11:18 +1000 schrieb Catriona Johnson:
  Hello
 
  I am a novice zope 3 user and would appreciate any help on this.
 
  I am trying to follow a few examples using zalchemy but am unable to
  progress beyond importing zalchemy. My python script so far contains
 
  import sqlalchemy
  import z3c.zalchemy
 
  and I get the following error when trying to import zalchemy
 
  AttributeError: __path__
 
  Traceback (innermost last):
 
  File C:\Projects\TestZalchemyOracleConnection.py, line 1, in ?
  File C:\Projects\TestZalchemyOracleConnection.py, line 3, in ?
import z3c.zalchemy
  File
  C:\Python24\Lib\site-packages\z3c.zalchemy-0.2-py2.4.egg\z3c\zalchemy\__
 init__.py, line 15, in ?
from datamanager import (
  File
  C:\Python24\Lib\site-packages\z3c.zalchemy-0.2-py2.4.egg\z3c\zalchemy\da
 tamanager.py, line 20, in ?
from zope.component import queryUtility, getUtility, getUtilitiesFor
  File C:\Python24\Lib\site-packages\zope\component\__init__.py, line 24,
  in ? from zope.component.interfaces import IComponentArchitecture
  File
  C:\Python24\Lib\site-packages\zope\deferredimport\deferredmodule.py,
  line 71, in __getattr__
raise AttributeError, name
 
 
  I am running  this in the Wing IDE on Windows XP with Python 2.4, Zope
  3.3, SQLalchemy 0.3.8 and zalchemy 0.2

 Zope 3.3 might be too old in the sense that zalchemy probably depends on
 some other packages (via egg dependencies) that are not satisfied in
 Zope 3.3 yet.

I successfully used z3c.zalchemy with Zope-3.3.1, although I'd recommend to 
use Zope-3.4.0b1 as other packages (e.g. z3c.form) work better with the newer 
Zope version.

However, if you use the SVN-version, use revision 77230, as the last revision 
seems to be buggy (at least for me).

Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Strange ZODB error - Solved: Zalchemy bug

2007-08-09 Thread Hermann Himmelbauer
Am Donnerstag, 9. August 2007 15:44 schrieb Hermann Himmelbauer:
 Hi,
 After updating some z3c packages and changing some of my code, I receive a
 very strange traceback from Zope3:

Ah, after fiddling around I found out that the svn update of the zalchemy 
package resulted in this error. If somewhere in my code zalchemy is used, the 
TypeError emerges. It seems that recently there was a change to the zalchemy 
package (svn log):


r78682 | zagy | 2007-08-08 10:53:01 +0200 (Mi, 08 Aug 2007) | 1 line

using the threadlocal strategy of sqlalchemy instead of creating one engine 
per
thread. This allows connection pooling for instance.


I reverted zalchemy to an older version an all is well again.

Once again it proves that updating only makes sense if an update is really 
necessary... ;-)

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form: How to hide a button/define action without a button?

2007-08-09 Thread Hermann Himmelbauer
Am Donnerstag, 9. August 2007 04:08 schrieb Stephan Richter:
 On Monday 06 August 2007 10:41, Hermann Himmelbauer wrote:
  Is there a way simple way to accomplish this? Perhaps via a hidden=True
    attribute in the buttonAndHandler decorator method?

 I would override the ``updateActions()`` method in the form as follows:

 def updateActions(self):
   super(MyForm, self).updateActions()
   self.actions['store'].addClass('hidden')

 Then have a style:

 input.hidden {
   display: None;
 }

Great idea! This works out nicely! Thanks!

Best Regards,
Hermann


-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form: Integer-based fields incorrectly validated

2007-08-08 Thread Hermann Himmelbauer
Am Mittwoch, 8. August 2007 05:45 schrieb Stephan Richter:
 On Wednesday 01 August 2007 13:15, Hermann Himmelbauer wrote:
  In one of my forms, one field is defined like that:
  The entered value is not a valid integer literal.
 
  Interestingly, if I set 1,123 as value, zope outputs:
 
  Objekttyp ist falsch.
 
  I tried to investigate this futher, but things are getting complicated at
  the file converter.py, line 96 (no clue what a formatter is).
 
  Is this a bug or am I doing something wrong?

 This error should really not occur. I think we have plenty of tests for
 this and z3c.form is used in production using this feature. Can you extract
 this problem into a test?

Yes, I reproduced it by simply modifying your HelloWorld example in the 
z3c.formdemo package:

Index: interfaces.py
===
--- interfaces.py   (Revision 78682)
+++ interfaces.py   (Arbeitskopie)
@@ -27,7 +27,7 @@
 class IHelloWorld(zope.interface.Interface):
 Information about a hello world message

-who = zope.schema.TextLine(
+who = zope.schema.Int(
 title=u'Who',
 description=u'Name of the person sending the message',
 required=True)

Now the same validation problems occur for this input field.
Maybe the reason for this is my Zope3 version? I still use Zope-3.3.1. The z3c 
packages are all up to date, I use the latest SVN versions.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] How to access request variable from vocabulary

2007-08-07 Thread Hermann Himmelbauer
Am Montag, 6. August 2007 19:08 schrieb Benji York:
 Adam Groszer wrote:
  I'm using something like this:
 
  def getCurrentRequest():
  return getInteraction().participations[0]

 It is, of course, better if you can structure your app so you don't have
 to pull the request out of thin air, but if you do, I'd be a little
 more careful about it.  Like so:

 def getRequest():
  i = zope.security.management.getInteraction() # raises
 NoInteraction
  for p in i.participations:
  if IRequest.providedBy(p):
  return p
  raise RuntimeError('Could not find current request.')

Ah, thanks a lot for this, it works.

In my RDB/SQLAlchemy-based application, when a user logs in, his 
database-userID is stored into the session. In some forms, I have choices 
which are filled with user-related data (e.g. his email addresses). To 
retrieve this data from the relational database, I need the ID from the 
session.

I'd prefer if the vocabulary had direct access to the request, but it seems 
that vocabularies are bound to the content object and not to the view, 
whereas the request is only available in the view.

One solution could be to build a view-bound vocabulary, but that's probably 
hard to do and may break other things.  So this seems like a structural 
problem that is not easy to solve.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Is a view persistent?

2007-08-06 Thread Hermann Himmelbauer
Am Donnerstag, 2. August 2007 13:37 schrieb Fred Drake:
 On 8/2/07, Hermann Himmelbauer [EMAIL PROTECTED] wrote:
  mylist = []
 
  @button.buttonAndHandler(_(u'Suchen'), name='suchen')
  def handle_suchen(self, action):
   self.mylist.append(123)
 
  When I output mylist in my page template, the number 123 is appended to
  mylist if I press the Suchen button, so if I press it 5 times, the list
  holds 5 items. When I restart my zope instance, the list is empty again.

 The attribute will be persistent so long as you don't restart the
 process, *because* it's a class attribute.  Note that the code you
 showed never sets the value of self.mylist, but only mutates the
 existing value.

 To not have a semi-persistent self.mylist, do this instead:

 def handle_suchen(self, action):
  self.mylist = [123]

Thanks for your reply, I was so Zopified and concentrated on object 
persistence that I forgot about this really basic Python issue...

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Rendering subobjects in pages

2007-08-06 Thread Hermann Himmelbauer
Am Montag, 6. August 2007 14:21 schrieb Greg Baker:
 How can I specify a template to render a sub-object within one of my
 content objects?

 For example, pretend I have a Contact object which contains a Person
 object. I am rendering the Contact object through a page template.

 class Contact:
 person = Person()

 In all the examples I see, rendering the person would be done using many
 tal expressions like span tal:content=context/person/name / or
 something similar.

 Is it possible to render the person object using a single tal expression,
 div tal:content=context/person /, having the rendering handled by a
 template somewhere?  The reason I want to do this is because the person
 object will be used in many different classes and for a consistent look and
 feel I would like to render the object the same on all pages without having
 to maintain 10 different page templates.

I'd recommend to have a look at z3c.form and z3c.formdemo, especially 
subforms. z3c.formdemo features the addressbook - demo, which handles such 
issues.

Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] How to access request variable from vocabulary

2007-08-06 Thread Hermann Himmelbauer
Hi,
I have a simple function that is registered a vocabulary for a Choice-widget.

My problem is that the vocabulary should access the session, which seems to be 
only possible if I somehow get the request variable, which is available in 
a view. (A common way to retrieve the session seems to 
be session=ISession(self.request)[KEY]).

However, the vocabulary seems to get only the context as a parameter but not 
the view.

How can I solve this problem?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form: Integer-based fields incorrectly validated

2007-08-02 Thread Hermann Himmelbauer
Am Mittwoch, 1. August 2007 20:37 schrieb Markus Leist:
 Hi,

 do you have a

 from zope.schema.fieldproperty import FieldProperty
 class Foo:
   implements(IFoo)
   foobarid = FieldProperty( IFoo['foobarid'])

I do have an object that implements my IFoo interface, however, I don't use 
FieldProperty, instead the object attributes are automatically created by 
SQLAlchemy's ORM mapper.

Anyway, I don't think that my problem is field related, in my case I just 
select fields from my interfaces and use these for my form. My context does 
not have these attributes at all as I don't store them on the context object.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] z3c.form: Integer-based fields incorrectly validated

2007-08-01 Thread Hermann Himmelbauer
Hi,
In one of my forms, one field is defined like that:

foobarid = Int(
title=u'ID',
description=u'ID of Foobar',
required=False)

When I add this field in a z3c.form based form, e.g.:

fields = field.Fields(IFoo['foobarid'])

Then the validation of the field fails, e.g. if I type in a correct value, 
e.g. 123, zope returns an error:

The entered value is not a valid integer literal.

Interestingly, if I set 1,123 as value, zope outputs:

Objekttyp ist falsch.

I tried to investigate this futher, but things are getting complicated at the 
file converter.py, line 96 (no clue what a formatter is).

Is this a bug or am I doing something wrong?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Building an admin interface

2007-07-17 Thread Hermann Himmelbauer
Am Montag, 16. Juli 2007 22:44 schrieb Stephan Richter:
 On Monday 16 July 2007 15:58, Benji York wrote:
  This reminds me of something I've been curious about but haven't had
  time to research lately.  What are the differences between pagelets and
  viewlets and their various strengths/weaknesses.  An acceptable answer
  is read the docs and decide for yourself. wink

 Viewlets-pure UI design is a great approach, if you have portal, where
 there is really never a main content area, since you can reuse viewlets
 accross many pages. So in this UI pattern, you would create a Contents
 viewlet manager, and register viewlets for this manager. Depending on which
 page you are looking at, viewlets are picked up and displayed.
 Unfortunately, for simple pages, this requires two directives: One to
 define the page and one to define its Contents viewlet. This cost is very
 acceptable to a portal site where those simple pages are rare, but are
 impractical for more traditional Web applications.

 Also, any piece of dynamic code is a viewlet manager with viewlets or a
 simple content provider: left menu, right menu, header, CSS files, JS
 files, title, etc.

 Pagelet-based UI design is pretty much the same pattern, except that it
 allows you to define a main content area. Here you define a layout template
 that is used to define the O-wrap (pretty much like standard_macros/page).
 A page is then registered as a pagelet, which defines a second template
 that defines the content area of the page. As for macros, the advantage
 here is that you only need one generic UI layout directive plus one other
 directive per page. But something that is much nicer in pagelets is that
 you do not have to include the macro from within the pagelet, but that the
 layout is driving everything. Also, it is much simpler to register an
 alternative layout template for a particular view or context.

That leads me to the question if it's possible to mix pagelets/viewlets? In my 
case, I have one main content area but I have some dynamic code, e.g. a 
navigation box, a login box, later perhaps a search box etc. How would I 
implement them? Perhaps I use a viewlet manager / viewlet in the layout 
template?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: Introducing z3c.form - widget snippets

2007-07-13 Thread Hermann Himmelbauer
Am Freitag, 13. Juli 2007 16:08 schrieb Stephan Richter:
 On Wednesday 11 July 2007 12:14, Hermann Himmelbauer wrote:
  Please tell me what you think, if you like it, perhaps it could be
  included in z3c.form?

 I have the same question as Roger. 

Hmmm, I missed that one, I think...

 What do these snippets do that cannot be 
 done with macros or viewlets already? When doing custom projects, I expect
 any developer to develop their own form templates. The ``z3c.formui``
 templates are merely examples, which is the reason they are in their own
 package and layer.

One reason could be that I simply don't understand some aspects of 
z3c.form/macros etc. For me, it was so complicated in my non-generated forms 
that I rather invented something on my own.

Another aspect for me is, that I personally don't like macros so much, with 
these widget snippets, I hope, I can avoid them in my application. For me 
macros tend to be complex (unübersichtlich - I think there's no direct 
translation for that german word?), and I don't see how they would work well 
in the case when I don't use generated forms but arrange the widgets 
manually. Probably I would need an extra macro that acts as my snippet?

So, in my snippet-way, it looks like that for every widget:

span replace=structure view/widgets/mywidget/snippets/foo /

And in the macro-style? Perhaps like that?

span metal:use-macro=snippets/foo
  span metal:fill-slot=snippet
span replace=structure view/widgets/mywidget/render /
  /span
/span

This is boilerplate code I'd rather like to avoid. Moreover, I can register my 
snippets on specific widgets and also on specific modes. In my case, I could 
probably use the same template for input and display widgets as I simply 
register one snippet for input, and another for display.
In case of macros, I assume I'd have to rewrite my template, as I have to use 
e.g.: metal:use-macro=snippets/foo_input 
and metal:use-macro=snippets/foo_display.

 That said, you can, like everyone else, put your package into the z3c
 namespace for other people to use. For example ``z3c.widgetsnippet`` would
 work. The code is definitely out of scope for z3c.form and z3c.formui.

Well, that's certainly a possibility. Currently I'm 
implementing Form-Frames, which complement snippets by adding surrounding 
template code, such as form, buttons etc., let's see...

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: Skin based on IPageletBrowserLayer

2007-07-13 Thread Hermann Himmelbauer
Am Freitag, 13. Juli 2007 16:33 schrieb Stephan Richter:
 On Thursday 05 July 2007 04:54, Hermann Himmelbauer wrote:
  My problem is that when requests are marked with IPageletBrowserLayer,
  there are no error messages, no 404's, nothing. In case of a zope error,
  the browser displays Traversal error - A server error occurred but in
  the transcript.log, no error is printed.

 Did you include the z3c.layer.pagelet/configure.zcml in your
 registrations? ;-) Don't worry, this got me just this week too. :-)

Unfortunately not. configure.zcml and meta.zcml are correctly included. (If I 
make them errorneous, Zope raises an error.)

Hmmm, I'm stuck on this one...

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Introducing z3c.form - widget snippets

2007-07-11 Thread Hermann Himmelbauer
Hi,
I extended the z3c.form package a little bit by form snippets, which eases the 
development of custom form templates. Widget Snippets are a way to 
automatically surround widget code by custom HTML code, e.g. by error 
handling, a label etc.

Snippets can be accessed over a sub-object of the widget, e.g.:

span tal:replace=structure view/widgets/myname/snippets/mysnippet /

Template designers can create their own snippets, register them for a 
view/widget/mode under a name and access them as shown above.

I wrote a simple doctest that explains this further, if you are interested, 
please have look at it. I think my code does not break z3c.form in any way, 
it just extends it, all tests pass.

Please tell me what you think, if you like it, perhaps it could be included in 
z3c.form?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7

Snippets


The idea of widget snippets is that often widgets will have some surrounding
HTML code, perhaps a label, outlining what e.g. an input field is for, some
code regarding error handling and perhaps some simple formatting.

For instance, a widget may render as:

input type=text value= /

But in the resulting HTML page, we need some surrounding code, e.g.

div
MyWidget: input type=text value= /
/div

Widget Snippets allow designers to create custom snippets and register them
for certain widgets and display modes. 

First we have to register the meta configuration for the directive.

   import zope,sys
   from zope.configuration import xmlconfig
   import z3c.form
   context = xmlconfig.file('meta.zcml', z3c.form)
   from z3c.form import testing
   testing.setupFormDefaults()

We need a custom snippet template

   import os, tempfile
   temp_dir = tempfile.mkdtemp()
   file = os.path.join(temp_dir, 'snippet_div_input.pt')
   open(file, 'w').write('''
  ... div tal:content=structure view/labellabel/div
  ... div tal:content=structure view/renderwidget/div
  ... ''')

Now we register it

   context = xmlconfig.string(
  ... configure
  ... xmlns:z3c=http://namespaces.zope.org/z3c;
  ...   z3c:snippetTemplate
  ...   name=div
  ...   mode=input
  ...   template=%s
  ...   /
  ... /configure
  ...  % file, context=context)

And now we do that for a different snippet and register it under a
different name

   file = os.path.join(temp_dir, 'snippet_span_input.pt')
   open(file, 'w').write('''
  ... div
  ... span tal:replace=structure view/label /:
  ... span tal:replace=structure view/render /
  ... /div
  ... ''')
   context = xmlconfig.string(
  ... configure
  ... xmlns:z3c=http://namespaces.zope.org/z3c;
  ...   z3c:snippetTemplate
  ...   name=span
  ...   mode=input
  ...   template=%s
  ...   /
  ... /configure
  ...  % file, context=context)

Now we need a template for our form, which demonstrates the use
of the different snippets.

   file = os.path.join(temp_dir, 'myform.pt')
   open(file, 'w').write('''
  ... span tal:replace=structure view/widgets/myname/snippets/div /
  ... span tal:replace=structure view/widgets/myname/snippets/span /
  ... ''')

We can see that the registered snippets are available under the widget
and the object snippets.

We need some interface/class/browser view

   class IPerson(zope.interface.Interface):
  ...
  ...myname=zope.schema.TextLine(title=u'Persons Name')
   class Person(object):
  ...zope.interface.implements(IPerson)
  ...myname=''
  ...
  ...def __init__(self, myname):
  ...   self.myname = myname

Now we create a form with our template, instantiate and update it 
(we use an AddForm as we have no context)

   from z3c.form import form, field
   from z3c.form.testing import TestRequest
   from zope.app.pagetemplate.viewpagetemplatefile import 
ViewPageTemplateFile
   class PersonForm(form.AddForm):
  ...
  ...fields = field.Fields(IPerson)  
  ...template = ViewPageTemplateFile('myform.pt', temp_dir)
  ...
   request = TestRequest()
   personForm = PersonForm(None, request)
   personForm.update()

And now we render the form

   print personForm.render()
  BLANKLINE
  BLANKLINE
  divPersons Name/div
  divinput type=text id=form-widgets-myname
 name=form.widgets.myname
 class=textWidget textline-field value= /
  /div
  BLANKLINE
  BLANKLINE
  div
  Persons Name:
  input type=text id=form-widgets-myname
 name=form.widgets.myname
 class=textWidget textline-field value= /
  BLANKLINE
  /div
  BLANKLINE
  BLANKLINE
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] z3c.form - field description - widget hint?

2007-07-10 Thread Hermann Himmelbauer
Hi,
I wonder what happens with the field description during widget creation - it 
seems that it is currently not regarded. However, in forms.txt, a widget 
attribute called hint is mentioned (line 238), which seems not to be 
available.

I assume that the field description should be converted to the widget hint?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] ForbiddenAttribute error

2007-07-07 Thread Hermann Himmelbauer
Am Freitag, 6. Juli 2007 16:29 schrieb Mikael Moutakis:
 Hello
 I wrote a feed aggregator using the module FeedParser. I stored the RSS
 feed url in a persistant content component and retrieved the feed data in
 the view class. But I thought that I should move the feed data into the
 content component class instead of retrieving it in the view class. I get a
 ForbiddenAttribute error when viewing the class

Please note, that ForbiddenAttribute is also raised, when an object has no 
such attribute. I'd recommend to check (e.g. via dir(object)) if the 
attribute really exists.

I'm no expert in Zope security, but I assume that ForbiddenAttribute is 
raised, as no permission is known for the attribute, simply, because it does 
not exist.

Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form and subforms in an AddForm?

2007-07-06 Thread Hermann Himmelbauer
Am Freitag, 6. Juli 2007 03:14 schrieb Matt Bowen:
 Stephan and Hermann,
 maximum recursion depth exceeded

That is a good hint, so you're recursively calling something.

  /opt/zope/zope-3.4.0a1

 /lib/python/zope/tal/talinterpreter.py(379)do_startEndTag()
 - self.do_startTag(stuff, self.endsep, self.endlen)

I think I once had this, too, some time ago. The reason was something like 
calling a function from the template, that again rendered the template, 
calling the function again and so on, resulting in an endless recursion.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] z3c.form - Idea for subforms

2007-07-05 Thread Hermann Himmelbauer
Hi,
After playing around with subforms, I think some parts could be more implicit. 
What I don't like so much is that there's quite some boilerplate code which 
is not easily understandable for a newbie, moreover the explicit code is also 
hard to understand (at least for me) unless one does have a decent insight 
into the z3c.form package.

I have some ideas which could perhaps simplify subforms - however, I don't 
know if they work or break some key concepts:

1) Create seperate classes for form within form and logical units for each 
Add/Edit/Display, e.g.:

AddFormInForm / EditFormInForm / DisplayFormInForm
AddSubForm / EditSubForm / DisplaySubForm

I think this would provide a better understanding, as one can look at a class 
and immediately understand what they are ment for. Moreover various 
boilerplate code could be saved, e.g. like this in case of a AddSubForm:

def updateWidgets(self):
self.widgets = getMultiAdapter(
(self, self.request, self.getContent()), IWidgets)
self.widgets.ignoreContext = True
self.widgets.update()

2) Handling the creation / update of the subform in the update() method of the 
parent form is too explicit, I think. Another problem is the placing of the 
form in the HTML widget, this does not seem to work with a generator 
(tal:repeat), one has to insert them manually. In my case, where I don't want 
the subform at the top/bottom but in between other widgets, I probably have 
to write a lot of template code.

To my mind, it would be ideal, if Zope figures out all this for itself. I 
think that the interface itself provides all necessary information that Zope 
needs, e.g. in case of a field such as:

owner = Object(schema=IOwner)

Zope knows that there has to be a subform involved. My idea is to somehow 
register subforms to specific Interfaces/fields, but I'm not sure if that is 
possible. This could look something like this:

z3c:subform
   for = ICar,
   interface = IOwner,
   class = .browser.OwnerForm
   layer = ...
   /
  
In this case the update function would query for an appropriate adapter for 
the subform, moreover these subforms could also possibly be rendered just 
like any other widget, therefore no specific templates are needed.

3) I think SubForms should look/behave very similar to other forms, therefore 
it would be optimal if one could simply have a create() method in an 
AddSubForm where the object is created. This method would then be 
automatically be called by the parent form and the object would be stored in 
the object attribute.

What do you think?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form and subforms in an AddForm?

2007-07-04 Thread Hermann Himmelbauer
Am Mittwoch, 4. Juli 2007 00:33 schrieb Matt Bowen:
 That was not at all a silly question! That got me a little closer -- I am
 new enough not to have understood that i needed the ++skin++. Now, instead
 of a 404 page, I get the following when I try to display my object:

 127.0.0.1 - - [03/Jul/2007:18:26:54 -0400] GET
 /++skin++MovingTargetBrowser/viewguy/ HTTP/1.1 500 131 - Mozilla/5.0
 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.1.4) Gecko/20070515
 Firefox/2.0.0.4
 zope.component.interfaces.ComponentLookupError:
 ((z3c.pagelet.zcml.NextActionDisplayForm object at 0x2affb6d0, 
 zope.publisher.browser.BrowserRequest instance URL=
 http://localhost:9080/++skin++MovingTargetBrowser/viewguy/index.html, 
 movingtarget.nextaction.NextAction object at 0x2adbcf6cd2a8),
 InterfaceClass z3c.form.interfaces.IWidgets, u'')

This looks like some problem with widgets, I'm not sure. Such errors can be 
quite frustrating, I do it like this:

- locate where the adapter is queried, this will be somewhere in the z3c.form 
package
- If not sure, use print 'HERE I AM' statements in the source to find out 
where the exception is raised
- When you found the code line, things hopefully resolve
- Sometimes your object/request is not marked with the requested interface, 
you can check that out with a print 
IRequestedInterface.providedBy(myobject) in the framework source.

I know that it is probably a bad style to temporarily modify the framework 
source but I can't think of a better solution.

Over the time you'll start to smell why these component lookup errors happen 
and resolve them more easily.

 And for edit, I get this:

 127.0.0.1 - - [03/Jul/2007:18:30:30 -0400] GET
 /++skin++MovingTargetBrowser/viewguy/ HTTP/1.1 500 201 - Mozilla/5.0
 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.1.4) Gecko/20070515
 Firefox/2.0.0.4
 zope.security.interfaces.Unauthorized:
 (z3c.pagelet.zcml.NextActionEditForm object at 0x2af9dfd0,
 'browserDefault', 'zope.ManageContent')

  /opt/zope/zope-3.4.0a1

 /lib/python/zope/app/publication/browser.py(66)getDefaultTraversal()
 - return ob.browserDefault(request)

Maybe you did not log in into the Zope instance? You set the permissions 
to zope.ManageContent, you could also change this to zope.Public and try 
it again.

Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Custom Schemas, form widgets

2007-07-03 Thread Hermann Himmelbauer
Hi,
I wonder if there's a package that extends Zope's schemas and widgets as Zope 
covers only basic ones.

There are several missing schemas that derive from a TextLine but have custom 
validation methods, e.g. for URLs, for an email address etc. Moreover there 
are several widgets missing, e.g. a select widget for date/datetime fields.

Probably people do this on their own, however I think it would be a good idea 
to share code, so perhaps it is possible to add a package where people can 
contribute?

Ah yes, I think the package should be based on z3c.form, not on formlib.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Trouble with Skins

2007-06-27 Thread Hermann Himmelbauer
Am Dienstag, 26. Juni 2007 12:43 schrieb Arne Nordmann:
 Hi,

 I tried to create my own skin for a website of mine. I used Phillip's
 book (2nd version) and tried to do everything analog (just different
 names and a slightly different file structure).

 If I call a test view (registered for IRootFolder) with the skin I get
 the following error:

 ComponentLookupError: ((zope.app.folder.folder.Folder object at
 0x886916c, zope.publisher.browser.BrowserRequest instance
 URL=http://localhost:9673/++skin++norro/test), InterfaceClass
 zope.interface.Interface, 'h')

 (Full traceback attached)

 I don't know what this traceback wants to say. I'm wondering about the
 value of the name-parameter that seems to be 'h' in this case. Where
 does this 'h' come from? I really don't know where to look at.

Looking at the traceback, it seems that the lookup error is happening here:
File /usr/lib/python2.4/site-packages/zope/app/basicskin/standardmacros.py, 
line 41, in __getitem__
page = getMultiAdapter((context, request), name=name)

And above there's this:

   - Warning: Macro expansion failed
   - Warning: zope.component.interfaces.ComponentLookupError: 
((zope.app.folder.folder.Folder object at 0x886916c, 
zope.publisher.browser.BrowserRequest instance 
URL=http://localhost:9673/++skin++norro/test), InterfaceClass 
zope.interface.Interface, 'h')

So it seems it's some macro-related problem, perhaps you check the 
metal:define-macro/metal:use-macro definitions.

However, this case shows me that I'm not the only one with such problems. 
These ComponentLookupErrors and cryptic tracebacks (at least for newbies) 
drove me mad and costed me hours to resolve. In the end it was always my 
fault, e.g.:

- Forgot to add the appropriate  layer to the request
- Forgot to omit __parent__ in my formlib class
- Forgot to register something or registered it for the wrong interface

I'm curious how others deal with this problem because I'm often paralyzed by 
this ComponentLookupError. The traceback also does not show which interface 
my objects provide - for example it cannot be seen if a BrowserRequest 
provides a specific layer or not. To solve this problem, I had to insert 
something like print IMyLayer.providedBy(request) into the Zope source to 
find out what happens.

Maybe a Zope3 newbie-debug-mode would help a lot that throws a traceback 
like this (regarding to the original problem)?


... Original Traceback ...
--- Verbose Traceback ---
A query for a named adapter adapting from the object(s):

 - zope.app.folder.folder.Folder object at 0x886916c (providing IFolder)
 - zope.publisher.browser.BrowserRequest instance 
URL=http://localhost:9673/++skin++norro/test (providing IBrowserRequest)

to the interface:

- InterfaceClass zope.interface.Interface

With the adapter name 'h' could not be found.
Helpful tips how to resolve this are given at http://zope3faq.org/123


Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] pagelets vs. pages

2007-06-26 Thread Hermann Himmelbauer
Hi,
It seems that the z3c.formdemo examples are based on pagelets, as they seem to 
perfectly integrate with z3c.form. Therefore I had a look at it and moreover 
at z3c.layer.pagelet, which is a minimal skin for a pagelet based 
application.

What I don't fully understand is if a pagelet-based design/skin replaces 
macro-based skins.

I understand pagelets in a way, that they separate content and layout, whereas 
layout means everything around the content, e.g. Header, Logo, Toolbar, 
Navigation etc. - is that true?

Moreover I assume that every pagelet requires a view class that is based on 
the class BrowserPagelet. However, a simple HTML-page, e.g. an Intro-Page 
or the like does not require any view, therefor I'd rather implement it via a 
simple page template and register it via the browser:page ... directive. 
But how would I use my layout templates in this case? Or do I have to write a 
dummy class for this page, assign acontent template and register it as 
pagelet?

I also don't fully understand the advantage of a pagelet over a page/view: Why 
is it important that the layout is customizable for every view? Isn't it 
common that a skin and therefore the layout is the same in the entire 
application?

So perhaps the decision if to use pagelets or not boils down to the following 
issues:

1) If you need different layout throughout your application, use pagelets
2) If not, use browser pages / views and skin macros

Is that true?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form - How to register IFormLayer?

2007-06-21 Thread Hermann Himmelbauer
Am Mittwoch, 20. Juni 2007 00:24 schrieb Stephan Richter:
 On Friday 15 June 2007 12:10, Hermann Himmelbauer wrote:
  So, at first, what's the idea with this IFormLayer? Why does any request
  to provide this interface? How can I tell Zope that all requests
  implement this interface?

 The problem with the older form-related frameworks is that their
 registrations are made on the default browser layer, making it (1) very
 hard to selectively add registrations to your own layer/skin, and (2)
 polluting the default browser layer.

 z3c.form fixes this problem by creating a new layer dedicated to the form
 registrations. All you need to do is to inherit this layer in your custom
 skin to get the form registrations to work. Philipp provided the sample
 code already.

 Yes, this does mean that z3c.form cannot be used within any of the default
 skins, such as Rotterdam, but that's exactely the point. Of course, you can
 just simply make all the registrations in the Rotterdam layer/skin and
 z3c.form will be available there.

Thanks, I temporarily fixed my problem by creating a skin which inherits from 
Rotterdam + IFormLayer, now z3c.form work.

It seems as if the trend is going away from ZMI - is that true? At least for 
me, customizing ZMI for my application is quite painful, it seems a lot 
easier to use z3c.layer instead. On the other hand, ZMI offers some 
functionality, such as add/delete/cut  paste etc. which I'd have to rewrite 
for many applications, so ZMI is quite appealing, too.

Or is it perhaps possible to use such functionality in my z3c.layer.pagelet - 
based skin?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


  1   2   >