[Zope3-Users] WingIDE and debugging Zope3.3

2006-06-15 Thread mats.nordgren
I've tried to get WingIDE to work for debugging Zope3 but have only had
limited success.  I've followed the instructions at wingware.com where it
tells you to add the wingdbstub.  I added 'import wingdbstub' in
$ZOPEINSTANCE/bin/runzope and it will break on errors but will not break on
breakpoints.

Other instructions tells you to make sure there is only _one_ thread, and I
finally found a setting in zope.app.twisted.schema.xml where I changed it to

   <== Changed to 1

  The number of threads which should be used to serve requests.

  The threads are placed in a pool and are used to serve requests
  received from the servers configured using 
  sections.  This does not constrain the total number of threads
  used by the application server; additional threads may be used
  for internal purposes.

  

Still no success.

Has anyone had any success with debugging with WingIDE?

Sincerely,

Mats

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


[Zope3-Users] Using restructered text

2006-06-15 Thread Florian Lindner
Hello,
how can I use (render to html) restructered text that is in a static file?

Thanks,

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


Re: [Zope3-Users] Trusted adapters and annotated security

2006-06-15 Thread Frank Burkhardt
Hi,

On Wed, Jun 14, 2006 at 01:24:14PM +0200, Frank Burkhardt wrote:
> Hi,
> 
> Is there a general way make an adapter 'inherit' annotated security 
> permissions
> from the object it adapted?

I've found the solution. This statement

>  for="mpgsite.workflow.interfaces.IAnnotatable"
>   factory=".annotatableadapter.MyAdapter"
>   provides=".interfaces.IMyInterface"
>   trusted="true"
>   />

needs an additional attribute locate="true".

Regards,

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


Re: [Zope3-Users] Dict Widget

2006-06-15 Thread Frank Burkhardt
Hi,

On Wed, Jun 14, 2006 at 02:41:05PM -0500, mats.nordgren wrote:
> Frank,
> 
> That would be great.  If you wish you can email it to me.
> 
> This should be included in the trunk IMHO.
> 
> Thanks,

I attached the widgets, zcml-statements to configure them and
modified Dict-implementation.

Good luck,

Frank
http://namespaces.zope.org/zope";
xmlns:i18n="http://namespaces.zope.org/i18n";
xmlns="http://namespaces.zope.org/browser"; i18n_domain="mpgsite">










from zope.app.form.browser import ObjectWidget, ListSequenceWidget
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.interface import implements
from zope.app import zapi
from zope.app.form.browser.objectwidget import ObjectWidgetView, ObjectWidget
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from mpgsite.interfaces import IMpgSequenceField
from zope.app.form.browser.widget import BrowserWidget
from zope.app.form.interfaces import IDisplayWidget, IInputWidget
from zope.app.form import InputWidget
from zope.app.form.interfaces import WidgetInputError, MissingInputError
from zope.schema.interfaces import ValidationError, InvalidValue
from zope.app.i18n import MessageFactory
_=MessageFactory('mpgsite')
from zope.i18n import translate
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from zope.app.form.browser.widget import renderElement
from zope.app.form.interfaces import ConversionError
from zope.app.form.browser import TextWidget, SequenceDisplayWidget
from zope.security.proxy import removeSecurityProxy
import sys
from zope.schema import Object
from zope.annotation.interfaces import IAnnotations

class MpgTextWidget(TextWidget):
def _toFieldValue(self, input):
try:
value = unicode(input)
except ValueError, v:
raise ConversionError(_("Invalid text data"), v)
return value


class I18NTextLineWidget(MpgTextWidget):
   def __call__(self):
value = self._getFormValue()
if value is None or value == self.context.missing_value:
value = ''

kwargs = {'type': self.type,
  'name': self.name,
  'id': self.name,
  'value': value,
  'cssClass': self.cssClass,
  'style': self.style,
  'extra': self.extra}
if self.displayMaxWidth:
kwargs['maxlength'] = self.displayMaxWidth # TODO This is untested.

return renderElement(self.tag, **kwargs)

class SimpleObjectWidget(ObjectWidget):
"""A Widget that shows all widgets of an object"""
def __call__(self,context,request):
xhtml=''
for widget in context.subwidgets:
xhtml +=widget()
return xhtml


def ObjectInputWidgetDispatcher(context, request):
"""Dispatch widget for Object schema field to widget that is
registered for (IObject, schema, IBrowserRequest) where schema
is the schema of the object."""
class Obj(object):
implements(context.schema)

widget=zapi.getMultiAdapter((context, Obj(), request), IInputWidget)
return widget

class ObjectInputWidget(ObjectWidget):
def getInputValue(self):
errors = []
content = self.factory()
for name in self.names:
try:
setattr(content, name, 
self.getSubWidget(name).getInputValue())
except Exception, e:
errors.append(e)
if self._error is None:
self._error = {}

if name not in self._error:
self._error[name] = e

# Don't raise errors when widget operations (add to list, 
remove element, ...) are processed
if ( 'mpgsite.no_form_action' not in IAnnotations(self.request) 
) and errors:
raise errors[0]

return content

def FileLocal(filename,depth):
path='/'.join(sys._getframe(depth).f_globals['__file__'].split('/')[:-1])
return path + '/' +  filename


class TemplateObjectWidget(ObjectWidget):
"""A Widget that uses a page template"""
def __init__(self, context, request, factory, template_, **kw):
super(TemplateObjectWidget, self).__init__(context, request, factory, 
**kw)
class TemplateObjectWidgetView(ObjectWidgetView):
template = ViewPageTemplateFile(template_)
self.view = TemplateObjectWidgetView(self, request)

def TemplateObjectWidgetFactory(context,request,factory,template):
widget=TemplateObjectWidget(context,request,factory,FileLocal(template,2))
return widget


class TemplateSequenceWidget(ListSequenceWidget):
def __init__(self, context, field, request, subwidge

Re: [Zope3-Users] list woes

2006-06-15 Thread Marco Mariani
Bernd Dorn wrote:
> you reassign the attribute here, so the list is never persistent
I thought about that, it's python 101 after all
> in Person.__init__ do: self.gadgets=PersistentList()
>
> and then in growup:
>
> person.gadgets.extend([ Gadget(toy) for toy in baby.toys ])

Yes, indeed, what I tried was

person.gadgets = PersistentList()
for toy in baby.toys:
person.gadgets.append(Gadget(toy))


Anyway, I am reassured by the fact that it should "just work", so I'm
trying again instead of refactoring. Must be something stoopid I overlooked.

tnx

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


Re: [Zope3-Users] list woes

2006-06-15 Thread Bernd Dorn


On 13.06.2006, at 00:16, Marco Mariani wrote:


I'm having this stripped-down use case.



class IToy(Interface):
name = TextLine(title=u"Toy")

class Toy(Persistent):
name = FieldProperty(IToy['name'])


class IGadget(Interface):
name = TextLine(title=u"Gadget")

class Gadget(Persistent):
name = FieldProperty(IGadget['name'])

def __init__(self,toy):
super(Person, self).__init__(self)
self.name = toy.name



class IBaby(Interface):
name = TextLine(title=u"Name")
toys = List(title=u"toys",value_type=Object 
(schema=IToy,title=u"toy")


class IPerson(Interface):
name = TextLine(title=u"Name")
gadgets =
List(title=u"toys",value_type=Object(schema=IGadget,title=u"toy")


class Baby(Persistent):
name = FieldProperty(IBaby['name'])
toys = FieldProperty(IBaby['toys'])

class Person(Persistent):
name = FieldProperty(IBaby['name'])
gadgets = FieldProperty(IPerson['gadgets'])

def __init__(self,baby):
super(Person, self).__init__(self)
self.name = baby.name



When IBaby is at the end of its workflow, it should be replaced by an
IPerson.

So I've made a view that creates a new IPerson based on data from the
old IBaby, and replaces the baby with the person on its container.

class BabyView(BrowserView):

def growup(self):
baby = self.context
parentfolder = baby.__parent__
id = baby.__name__
person = Person(baby)
del parentfolder[id]
parentfolder[id] = person

self.request.response.redirect(zapi.absoluteURL(person,self.request) 
+'/@@edit.html')



It works, and I see the new object with the name I passed over from  
IBaby.


The trouble is when I add the following to growup()

person.gadgets = [ Gadget(toy) for toy in baby.toys ]


you reassign the attribute here, so the list is never persistent

in Person.__init__ do: self.gadgets=PersistentList()

and then in growup:

person.gadgets.extend([ Gadget(toy) for toy in baby.toys ])

Regards, Bernd




This creates the gadgets (one per each toy) but the Gadget.name
attributes, altough being created, are not persisted.

The @@edit and @@index views show the Gadget.name attributes are
missing. I did not @@introspect the gadgets because I cannot  
traverse to

them.


Is this the right place for a PersistentList? Using it in growup() and
__init__ in place of FieldProperty does not make it work.


___
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