[Repoze-dev] [issue150] Chameleon treats every non simple object as a msgid. Non hashable objects will throw exceptions when being used as msg ids

2010-06-07 Thread Malthe Borch

Malthe Borch  added the comment:

Possibly the five.pt compatibility layer (for Zope 2) should accomodate 
explicitly for the 
``Missing`` case, i.e. directly on its translation function.

On the ``__class__`` issue; the reason why we use it instead of invoking 
``type`` is a slight 
performance benefit, and also possibly compatibility with Zope 3 – its security 
proxies report 
an incorrect value if you use ``type`` instead of ``__class__``.

It's a little unclear what the best course of action is on the whole.

--
assignedto:  -> malthe
nosy: +malthe
status: unread -> in-progress

__
Repoze Bugs 

__
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] Deform/Colander: allow empty non-String field in schema?

2010-06-07 Thread Chris McDonough
On Fri, 2010-05-28 at 08:28 -0400, Chris McDonough wrote:
> I agree with how Tim just characterized this.  I'm still trying to
> figure out what the best way to spell it.
> 
> My current idea is to:
> 
> - Define a special "null" sentinel value.
> 
> - Change the type definitions and widget definitions to do something 
>   sensible when they see a "null" during serialization and
>   deserialization. (e.g. "n = SchemaNode(default=null)").
> 
> - Add a required= flag to SchemaNode, e.g. field = SchenaNode(Integer(),
>   required=True).
> 
> - Decouple the meaning of default and required.


This isn't quite how it worked out.

Instead, the SchemaNode constructor grew a "missing" argument, which
represents the value to be used if a form deserialization returns a
"colander.default" sentinel.  If this "missing" argument is provided,
the node is not required.  If the missing argument is not provided, the
node is required.  The "missing" argument may be "colander.null",
representing the null value.  For example:

import colander

class StandardFields(colander.MappingSchema):
manufacturer = SchemaNode(String(), missing='') # not required
obsolete_date = SchemaNode(Date(),missing=colander.null)
length = SchemaNode(Float(), missing=colander.null)
units_per_pack = SchemaNode(Integer(), missing=colander.null)

None of the above fields are required.  A field without a "missing"
value, however, is required.

Tge "default" argument to SchemaNode now means the initial serialization
value for values absent from the appstruct but present in the schema.

It would be useful if the folks for whom it mattered could give this new
regime a roll before I merge it to the respective colander and deform
trunks and make new releases of both.

http://svn.repoze.org/deform/branches/default_overhaul/
http://svn.repoze.org/colander/branches/default_overhaul/

These packages must be used together; an older colander cannot be used
with the branch deform; use setup.py develop of both using a virtualenv.
The docs for both branches are more or less up to date and can be built
via "make clean html" from within the "docs" directory of each.  The
result can be viewed by opening ".build/html/index.html" within the docs
directory.  The CHANGES.txt of each also has relatively useful notes
about changes from the last set of releases.

- C


___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


[Repoze-dev] [issue151] Deform's SequenceWidget needs fixed count support

2010-06-07 Thread admin

System message:


__
Repoze Bugs 

__
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


[Repoze-dev] [issue151] Deform's SequenceWidget needs fixed count support

2010-06-07 Thread Kiran Jonnalagadda

New submission from Kiran Jonnalagadda :

Deform's SequenceWidget currently offers no mechanism to limit the number of 
items 
in a sequence. The attached patch adds a 'fixed' attribute that, when true, 
disables 
the Add and Close links in the sequence widget.

(My Javascript-fu isn't up to adding min/max count support yet.)

--
assignedto: chrism
messages: 416
nosy: chrism, jace
priority: feature
status: unread
title: Deform's SequenceWidget needs fixed count support

__
Repoze Bugs 

__
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


[Repoze-dev] [issue150] Chameleon treats every non simple object as a msgid. Non hashable objects will throw exceptions when being used as msg ids

2010-06-07 Thread admin

System message:


__
Repoze Bugs 

__
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


[Repoze-dev] [issue150] Chameleon treats every non simple object as a msgid. Non hashable objects will throw exceptions when being used as msg ids

2010-06-07 Thread do3cc

New submission from do3cc :

This occurs in plone, after changing the Missing class to at least provide the
__class__ attribute.

01>                _content = _path(item, econtext['request'], True,
'average_rating')
02>                u'_content'
03>                _write(u'')
04>                _tmp3 = _content
05>                _tmp = _tmp3
06>                if (_tmp.__class__ not in (str, unicode, int, float, )):
07>                    try:
08>                        _tmp = _tmp.__html__
09>                    except:
10>                        _tmp = _translate(_tmp, domain=_domain, mapping=None,
target_language=target_language, default=None)
11>                    else:
12>                        _tmp = _tmp()
13>                        _write(_tmp)
14>                        _tmp = None

Line 01 returns a very basic ExtensionClass object. This very basic
extension class has no __class__ attribute. I added it in a branch of
the 'Missing' package.
In 06 and 10 it starts doing some wrong assumptions for our case, and
tries to translate the missing value.
Translation throws an Unhashable Exception, because the 'Missing' object
is not hashable. Gettext requires hashable msgids

The attached patch provides a test case that triggers the described behaviour.

--
messages: 415
nosy: do3cc
priority: bug
status: unread
title: Chameleon treats every non simple object as a msgid. Non hashable 
objects will throw exceptions when being used as msg ids

__
Repoze Bugs 

__
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev