Hi,<br>the way I&#39;ve seen to get the root Folder is:<br><br>from zope.site import folder<br>r_folder = folder.rootFolder()<br><br>Regards<br>Simon<br><br><br><div class="gmail_quote">On Tue, Jun 23, 2009 at 9:36 AM, Edward Zwart <span dir="ltr">&lt;<a href="mailto:ed.zwart@softserv.ca">ed.zwart@softserv.ca</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Is there an easy way to use the interactive shell as though I were the<br>
logged in admin user?<br>
<br>
Following the documentation for z3c.form on Custom Widgets, I try the following:<br>
<br>
from z3c.form import testing, form, field<br>
testing.setupFormDefaults()<br>
from z3c.form.testing import TestRequest<br>
request = TestRequest()<br>
testing.setUp(request)<br>
<br>
from z3c.form.browser import text<br>
<br>
class MyWidget(text.TextWidget):<br>
        &quot;&quot;&quot;My new widget.&quot;&quot;&quot;<br>
        klass = u&#39;MyCSS&#39;<br>
<br>
def MyFieldWidget(field, request):<br>
        &quot;&quot;&quot;IFieldWidget factory for MyWidget.&quot;&quot;&quot;<br>
        return widget.FieldWidget(field, MyWidget(request))<br>
<br>
class MyEditForm(form.EditForm):<br>
<br>
        fields = field.Fields(IPerson)<br>
        fields[&#39;name&#39;].widgetFactory = MyFieldWidget<br>
<br>
<br>
myEdit = MyEditForm(root[u&#39;srichter&#39;], TestRequest())<br>
<br>
I get &quot;root&quot; is not defined.  So I figured out something like this...<br>
<br>
root = request.globs.get(&#39;root&#39;)<br>
<br>
If I try again, I get a KeyError (also if I use &quot;admin&quot;).  In fact,<br>
the root Folder object doesn&#39;t have anything in it at all.  (If I log<br>
in through the ZMI, I have added some objects.)<br>
<br>
Is there a more correct way to get the root folder?  And to run these<br>
tests from the prompt, can I do so as though I was logged in (like I<br>
do through the ZMI)?<br>
<br>
Somewhat related, everytime I use the interactive prompt, I copy/paste<br>
from bin/test-script.py to set the path to include all my buildout<br>
eggs folders.  Is there a better way to do this?<br>
<br>
Thanks again.<br>
<br>
e.<br>
_______________________________________________<br>
Zope3-users mailing list<br>
<a href="mailto:Zope3-users@zope.org">Zope3-users@zope.org</a><br>
<a href="http://mail.zope.org/mailman/listinfo/zope3-users" target="_blank">http://mail.zope.org/mailman/listinfo/zope3-users</a><br>
</blockquote></div><br>