[Zope] Problem with Python ZClass properties
Jamie
greatbks@truevine.net
Thu, 10 Apr 2003 12:15:38 -0400
This is a multi-part message in MIME format.
------=_NextPart_000_0008_01C2FF5A.E616AB20
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
I am having a problem with specifying the properties when I create an
object I have built using a ZClass. This python script is what I am
using to create the object:
# in the current context (the place the factory was called from).
content=container.Content.createInObjectManager(REQUEST['id'], REQUEST)
request = context.REQUEST
# Create Content
content.manage_addProduct['Content']
# Change Properties
------------------------------------------------------------------------
---------------------------------------------------------------
----- I am having problems here the SortOrder property is always made 1.
------------------------------------------------------------------------
---------------------------------------------------------------
# Change Sort Order
SortOrder=(len(context.objectValues('Content')) + 1)
if SortOrder is not 0:
content.manage_changeProperties(SortOrder=SortOrder)
------------------------------------------------------------------------
---------------------------------------------------------------
----nothing appears in this property even if I specify something in the
form to create the object
------------------------------------------------------------------------
---------------------------------------------------------------
# Change Content Text
if ContentText is not None:
content.manage_changeProperties(ContentText='ContentText')
# Change Author
user=AUTHENTICATED_USER.getUserName()
content.propertysheets.userProperties.manage_changeProperties(Author=use
r)
#Change Title
if title is not None:
content.manage_changeProperties(title=title)
# Change Paragraph
if para is not None:
content.propertysheets.userProperties.manage_changeProperties(para=para)
# Change Bold
if bold is not None:
content.propertysheets.userProperties.manage_changeProperties(bold=bold)
# Change Italic
if italic is not None:
content.propertysheets.userProperties.manage_changeProperties(italic=ita
lic)
# Change Underline
if underline is not None:
content.propertysheets.userProperties.manage_changeProperties(underline=
underline)
if request:
# redirect to the management view of the instance's container
request.RESPONSE.redirect(content.aq_parent.absolute_url() +
'/manage_main')
else:
# If we aren't supposed to redirect (ie, we are called from a
script)
# then just return the ZClass instance to the caller
return content
Thanks in advance,
Jamie
Jamie@brobus.net
------=_NextPart_000_0008_01C2FF5A.E616AB20
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns=3D"http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DProgId content=3DWord.Document>
<meta name=3DGenerator content=3D"Microsoft Word 10">
<meta name=3DOriginator content=3D"Microsoft Word 10">
<link rel=3DFile-List href=3D"cid:filelist.xml@01C2FF5A.E557A0E0">
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:DoNotRelyOnCSS/>
</o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:SpellingState>Clean</w:SpellingState>
<w:GrammarState>Clean</w:GrammarState>
<w:DocumentKind>DocumentEmail</w:DocumentKind>
<w:EnvelopeVis/>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]-->
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;
text-underline:single;}
span.EmailStyle17
{mso-style-type:personal-compose;
mso-style-noshow:yes;
mso-ansi-font-size:10.0pt;
mso-bidi-font-size:10.0pt;
font-family:Arial;
mso-ascii-font-family:Arial;
mso-hansi-font-family:Arial;
mso-bidi-font-family:Arial;
color:windowtext;}
span.SpellE
{mso-style-name:"";
mso-spl-e:yes;}
span.GramE
{mso-style-name:"";
mso-gram-e:yes;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */=20
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
</style>
<![endif]-->
</head>
<body lang=3DEN-US link=3Dblue vlink=3Dpurple =
style=3D'tab-interval:.5in'>
<div class=3DSection1>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>I am having a problem with specifying the properties =
when I create
an object I have built using a <span class=3DSpellE>ZClass</span>. This =
python
script is what I am using to create the =
object:<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'># <span class=3DGramE>in</span> the current context =
(the place
the factory was called from).<o:p></o:p></span></font></p>
<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>content=3D</span></font></sp=
an><span
class=3DSpellE><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:
Arial'>container.Content.createInObjectManager</span></font></span><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>(REQUEST['id'],
REQUEST)<o:p></o:p></span></font></p>
<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>request</span></font></span>=
<font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'> =3D <span
class=3DSpellE>context.REQUEST</span><o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'># Create Content<o:p></o:p></span></font></p>
<p class=3DMsoNormal><span class=3DSpellE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>content.manage_<span =
class=3DGramE>addProduct</span></span></font></span><span
class=3DGramE><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:
Arial'>[</span></font></span><font size=3D2 face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial'>'Content']<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'># Change Properties<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>------------------------------------------------------=
-------------------------------------------------------------------------=
--------<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>----- I am having problems here the <span =
class=3DSpellE>SortOrder</span>
property is always made 1.<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>------------------------------------------------------=
-------------------------------------------------------------------------=
--------<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'># Change Sort Order<o:p></o:p></span></font></p>
<p class=3DMsoNormal><span class=3DSpellE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>SortOrder</span></font></spa=
n><span
class=3DGramE><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:
Arial'>=3D(</span></font></span><span class=3DSpellE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>len</span></font></span><fon=
t
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>(<span
class=3DSpellE>context.objectValues</span>('Content')) + =
1)<o:p></o:p></span></font></p>
<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>if</span></font></span><font=
size=3D2
face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'> <span
class=3DSpellE>SortOrder</span> is not 0:<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><span style=3D'mso-spacerun:yes'> =
</span><span
class=3DSpellE>content.manage_<span =
class=3DGramE>changeProperties</span></span><span
class=3DGramE>(</span><span class=3DSpellE>SortOrder</span>=3D<span =
class=3DSpellE>SortOrder</span>)<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>------------------------------------------------------=
-------------------------------------------------------------------------=
--------<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>----nothing appears in this property even if I =
specify
something in the form to create the object<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>------------------------------------------------------=
-------------------------------------------------------------------------=
--------<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'># Change Content Text<o:p></o:p></span></font></p>
<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>if</span></font></span><font=
size=3D2
face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'> <span
class=3DSpellE>ContentText</span> is not =
None:<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><span style=3D'mso-spacerun:yes'> </span><span
style=3D'mso-spacerun:yes'> </span><span =
class=3DSpellE>content.manage_<span
class=3DGramE>changeProperties</span></span><span =
class=3DGramE>(</span><span
class=3DSpellE>ContentText</span>=3D'<span =
class=3DSpellE>ContentText</span>')<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'># Change Author<o:p></o:p></span></font></p>
<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>user=3D</span></font></span>=
<span
class=3DSpellE><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:
Arial'>AUTHENTICATED_USER.getUserName</span></font></span><font size=3D2
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>()<o:p></o:p></span></font><=
/p>
<p class=3DMsoNormal><span class=3DSpellE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>content.propertysheets.userP=
roperties.manage_<span
class=3DGramE>changeProperties</span></span></font></span><span =
class=3DGramE><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>(</span></font></span><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>Author=3Duser)<o:p></o:p></s=
pan></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>#Change Title<o:p></o:p></span></font></p>
<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>if</span></font></span><font=
size=3D2
face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'> title =
is not None:<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><span style=3D'mso-spacerun:yes'> =
</span><span
class=3DSpellE>content.manage_<span =
class=3DGramE>changeProperties</span></span><span
class=3DGramE>(</span>title=3Dtitle)<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'># Change Paragraph<o:p></o:p></span></font></p>
<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>if</span></font></span><font=
size=3D2
face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'> <span
class=3DSpellE>para</span> is not None:<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><span style=3D'mso-spacerun:yes'> =
</span><span
class=3DSpellE>content.propertysheets.userProperties.manage_<span =
class=3DGramE>changeProperties</span></span><span
class=3DGramE>(</span><span class=3DSpellE>para</span>=3D<span =
class=3DSpellE>para</span>)<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'># Change Bold<o:p></o:p></span></font></p>
<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>if</span></font></span><font=
size=3D2
face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'> bold is =
not None:<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><span style=3D'mso-spacerun:yes'> =
</span><span
class=3DSpellE>content.propertysheets.userProperties.manage_<span =
class=3DGramE>changeProperties</span></span><span
class=3DGramE>(</span>bold=3Dbold)<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'># Change Italic<o:p></o:p></span></font></p>
<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>if</span></font></span><font=
size=3D2
face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'> italic =
is not
None:<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><span style=3D'mso-spacerun:yes'> =
</span><span
class=3DSpellE>content.propertysheets.userProperties.manage_<span =
class=3DGramE>changeProperties</span></span><span
class=3DGramE>(</span>italic=3Ditalic)<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'># Change Underline<o:p></o:p></span></font></p>
<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>if</span></font></span><font=
size=3D2
face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'> =
underline is not
None:<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><span style=3D'mso-spacerun:yes'> =
</span><span
class=3DSpellE>content.propertysheets.userProperties.manage_<span =
class=3DGramE>changeProperties</span></span><span
class=3DGramE>(</span>underline=3Dunderline)<o:p></o:p></span></font></p>=
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>if</span></font></span><font=
size=3D2
face=3DArial><span style=3D'font-size:10.0pt;font-family:Arial'> =
request:<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><span style=3D'mso-spacerun:yes'> =
</span># <span
class=3DGramE>redirect</span> to the management view of the instance's =
container<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><span style=3D'mso-spacerun:yes'> =
</span><span
class=3DSpellE><span =
class=3DGramE>request.RESPONSE.redirect</span></span><span
class=3DGramE>(</span><span =
class=3DSpellE>content.aq_parent.absolute_url</span>()
+ '/<span =
class=3DSpellE>manage_main</span>')<o:p></o:p></span></font></p>
<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>else</span></font></span><fo=
nt
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>:<o:p></o:p></span></font></=
p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><span style=3D'mso-spacerun:yes'> =
</span>#
If we aren't supposed to redirect (<span class=3DSpellE>ie</span>, we =
are called
from a script)<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><span style=3D'mso-spacerun:yes'> =
</span>#
then just <span class=3DGramE>return</span> the <span =
class=3DSpellE>ZClass</span>
instance to the caller<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><span style=3D'mso-spacerun:yes'> =
</span><span
class=3DGramE>return</span> content <o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Thanks in advance,<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Jamie<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><a =
href=3D"mailto:Jamie@brobus.net">Jamie@brobus.net</a><o:p></o:p></span></=
font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
</div>
</body>
</html>
------=_NextPart_000_0008_01C2FF5A.E616AB20--