[Zope3-Users] Zope 3 Boot Camp early bird registration deadline near

2007-02-14 Thread Chris Calloway
The early bird registration deadline for Camp 5 and the BBQ Sprint is 
Wednesday, February 14:


http://trizpug.org/boot-camp/camp5/

You can save $50 by registering early. Registration ends Friday March 2.

--
Sincerely,

Chris Calloway
http://www.seacoos.org
office: 332 Chapman Hall   phone: (919) 962-4323
mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: How do I get the schema/field list from an instance?

2007-02-14 Thread Philipp von Weitershausen

Vinny wrote:

In a ZPT I would do something like:

for field in fieldsInObject(row) # which has (ordered?) fields
  th cell: field.name
for row in rowView
  for field in fieldsInObject(row) # which has (ordered?) fields
td cell: field.value

I know the above is broken in several ways.  I've been
trying various methods all evening.  The closest I get
is the __dict__ usage.  Ideally, I would get the 
interface provided by the object and feed that to 
form.Fields() but I can't determine how to get an

interface value that can be fed to form.Fields().

iface = zope.interface.providedBy(obj)

doesn't seem to work.


By itself it won't work. You'll have to do a bit more. First of all, an 
object can provide 0, 1 or more interfaces. Second, schemas are just 
interfaces whose specifications are fields (a schema can also have 
method specifications, there's no restriction to mixing a traditional 
interface with a schema). Therefore:


  for iface in zope.interface.providedBy(obj):
  for name in iface:
  field = iface[name]
  if zope.schema.interfaces.IField.providedBy(field):
  # you've got a schema field, now you can work with
  # field.title, field.description, etc. (see IField)

--
http://worldcookery.com -- Professional Zope documentation and training
Next Zope 3 training at Camp5: http://trizpug.org/boot-camp/camp5

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


[Zope3-Users] formlib vs. cancel button

2007-02-14 Thread Martin Aspeli

Hi,

I really thought I knew how to do this, but now I can't get it to work 
and I'm really confused.


I have a formlib EditForm, with an action like this:

@form.action(Cancel, validator=lambda *args, **kwargs: True)
def handle_cancel_action(self, action, data):
nextURL = self.nextURL()
if nextURL:
self.request.response.redirect(self.nextURL())
return ''

However, I still get validation errors when I click Cancel. I also tried 
a validator to return None, and no validator at all, and 
validator=None, they all have the same effect.


Is there a proper/easy way of doing this?

Martin

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


Re: [Zope3-Users] formlib vs. cancel button

2007-02-14 Thread Dennis Schulz

I dont know if it is the proper way,
but when I return an empty string there is no validation error.

This was also one of the strangest things I found out with formlib.

Dennis

Martin Aspeli escribió:

Hi,

I really thought I knew how to do this, but now I can't get it to work 
and I'm really confused.


I have a formlib EditForm, with an action like this:

@form.action(Cancel, validator=lambda *args, **kwargs: True)
def handle_cancel_action(self, action, data):
nextURL = self.nextURL()
if nextURL:
self.request.response.redirect(self.nextURL())
return ''

However, I still get validation errors when I click Cancel. I also 
tried a validator to return None, and no validator at all, and 
validator=None, they all have the same effect.


Is there a proper/easy way of doing this?

Martin

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




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


[Zope3-Users] Zope 3.3.1 released

2007-02-14 Thread Philipp von Weitershausen
On behalf of the Zope Foundation I'm happy to announce the release of 
Zope 3.3.1, a bugfix release for the current stable 3.3.x line. Zope 
3.3.1 contains a number of bugfixes, though most importantly it fixes 
compatibility with Python 2.4.4.


You can find more information as well as a tarball for Unix and a 
Windows installer at http://www.zope.org/Products/Zope3/3.3.1.



--
http://worldcookery.com -- Professional Zope documentation and training
Next Zope 3 training at Camp5: http://trizpug.org/boot-camp/camp5
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: How do I get the schema/field list from an instance?

2007-02-14 Thread Vinny
On Wed, 14 Feb 2007 19:22:53 +0100
Philipp von Weitershausen wrote:

 Vinny wrote:
  In a ZPT I would do something like:
  
  for field in fieldsInObject(row) # which has (ordered?) fields
th cell: field.name
  for row in rowView
for field in fieldsInObject(row) # which has (ordered?) fields
  td cell: field.value
  
  I know the above is broken in several ways.  I've been
  trying various methods all evening.  The closest I get
  is the __dict__ usage.  Ideally, I would get the 
  interface provided by the object and feed that to 
  form.Fields() but I can't determine how to get an
  interface value that can be fed to form.Fields().
  
  iface = zope.interface.providedBy(obj)
  
  doesn't seem to work.
 
 By itself it won't work. You'll have to do a bit more. First of all,
 an object can provide 0, 1 or more interfaces. Second, schemas are
 just interfaces whose specifications are fields (a schema can also
 have method specifications, there's no restriction to mixing a
 traditional interface with a schema). Therefore:
 
for iface in zope.interface.providedBy(obj):
for name in iface:
field = iface[name]
if zope.schema.interfaces.IField.providedBy(field):
# you've got a schema field, now you can work with
# field.title, field.description, etc. (see IField)
 


Thank you Philipp,

I have achieved my goal of a generic page template and
sql container view.  There are a few quick questions in the
example code below.  Mainly on being more efficient.  Here
are the results for everyone to use/comment on.  Note that
if anyone wants the rest of the files for this app., just
let me know and I'll see what I can arrange.  I still have
to test it with more tables.

== iso639.py snippet =
from zope.publisher.browser import BrowserView
from zope.security.proxy import removeSecurityProxy
from zope.app import zapi
import zope.interface
from zope.sequencesort import sort
from zope.app.preference import UserPreferences

class SQLAlchemyContainerView(BrowserView):

def __init__(self, context, request):
self.context = context
self.request = request

def rowView(self):

Presumably I have an instance of SQLAlchemyContainer
We will be yielding a list of dictionaries with name and value keys.

Philipp von Weitershausen provided some help on how to get to the
schema/IField interface.



sqlRecordObjects = [sqlRecordObject for sqlRecordObject in 
self.context.values()]

sort_on = (('lookup', 'nocase', 'asc'),)
sorted_rows = sort(sqlRecordObjects, sort=sort_on)

#userPreferences = UserPreferences()
#print userPreferences.hello.sorting.sortGroups
#sorted_rows = sort(sqlRecordObjects, 
sort=userPreferences.hello.sorting.sortGroups)

for sqlRecordObject in sorted_rows:
sqlRecordObject = removeSecurityProxy(sqlRecordObject)

nameValues = []   # A list of two-term dictionaries
for iface in zope.interface.providedBy(sqlRecordObject):
for name in iface:
field = iface[name]
if zope.schema.interfaces.IField.providedBy(field):
# We've got a schema field, now we can work with
# field.title, field.description, etc. (see IField)

# Since we get a 'bonus' item in our schema called 
__name__
# we must ignore it.  We use a list containment 
condition in
# case we want to expand the list of ignored
if field.__name__ in ['__name__']:
pass
else:
#print (field.__name__, 
sqlRecordObject.__dict__[field.__name__], )
nameValues.append({'name': field.title, 'value': 
sqlRecordObject.__dict__[field.__name__]})
#print nameValues[key]

# At this point we yield a list of dictionaries.
# The dictionary has keys 'name' and 'value' and their values are,
# respectively, the schema field title and
# the value of the sql record's column
yield nameValues


def fieldsInObject(self):

objlist = [obj for obj in self.context.values()]
#oneLang = self.context.values(0)
sqlRecordObject = removeSecurityProxy(objlist[0])
# Note: there *must* be a better way of getting
# just one value from the container.  Anyone have a
# quick clue for me?

fieldCount = 0
# I imagine there is a better way of getting the
# number of fields in a schema than that shown below.

for iface in zope.interface.providedBy(sqlRecordObject):
for name in iface:
field = iface[name]
if zope.schema.interfaces.IField.providedBy(field):