Thanks Simon, I just learned my mistake was I needed to start the
interactive prompt with bin/myproj-debug.exe.  I get the root obj for
free, and I even get all the buildout eggs in the path this way.  Life
is good!

However, I have another question now...

In the z3c.form documentation here:

In the section on Custom Widget Factories (CTRL + F "MyEditForm")

Even if I start my interactive prompt with myproj-debug.exe, the following line

>>> myEdit = MyEditForm(root[u'srichter'], TestRequest())

gives a KeyError (naturally).  I am guessing this refers to some
object representing Stephan's logged in credentials?  How is this

I have a feeling that if I get that far, I may have all I need for a
good while!  :)


On Tue, Jun 23, 2009 at 1:12 AM, Simon Elbaz<> wrote:
> Hi,
> the way I've seen to get the root Folder is:
> from import folder
> r_folder = folder.rootFolder()
> Regards
> Simon
> On Tue, Jun 23, 2009 at 9:36 AM, Edward Zwart <> wrote:
>> Is there an easy way to use the interactive shell as though I were the
>> logged in admin user?
>> Following the documentation for z3c.form on Custom Widgets, I try the
>> following:
>> from z3c.form import testing, form, field
>> testing.setupFormDefaults()
>> from z3c.form.testing import TestRequest
>> request = TestRequest()
>> testing.setUp(request)
>> from z3c.form.browser import text
>> class MyWidget(text.TextWidget):
>>        """My new widget."""
>>        klass = u'MyCSS'
>> def MyFieldWidget(field, request):
>>        """IFieldWidget factory for MyWidget."""
>>        return widget.FieldWidget(field, MyWidget(request))
>> class MyEditForm(form.EditForm):
>>        fields = field.Fields(IPerson)
>>        fields['name'].widgetFactory = MyFieldWidget
>> myEdit = MyEditForm(root[u'srichter'], TestRequest())
>> I get "root" is not defined.  So I figured out something like this...
>> root = request.globs.get('root')
>> If I try again, I get a KeyError (also if I use "admin").  In fact,
>> the root Folder object doesn't have anything in it at all.  (If I log
>> in through the ZMI, I have added some objects.)
>> Is there a more correct way to get the root folder?  And to run these
>> tests from the prompt, can I do so as though I was logged in (like I
>> do through the ZMI)?
>> Somewhat related, everytime I use the interactive prompt, I copy/paste
>> from bin/ to set the path to include all my buildout
>> eggs folders.  Is there a better way to do this?
>> Thanks again.
>> e.
>> _______________________________________________
>> Zope3-users mailing list
Zope3-users mailing list

Reply via email to