[Zope] sha and newbie db question.

Jens Vagelpohl jens@zope.com
Wed, 19 Jun 2002 12:39:40 -0400


external methods don't know "context" unless you pass it in via your call 
to the method.

jens


On Wednesday, June 19, 2002, at 12:03 , Alejandro Fernandez wrote:

> Hi,
>
> I just tried it in an external method, and it said "global name context
> not defined" - is this because it's in an external method? Maybe I should
> be importing something, or accepting some kind of parameter so it
> recognizes what the context is...
>
> Thanks again!
>
> Ale
>
> On Wed, 19 Jun 2002 14:51:41 +0200
> H.de.Wit@SFK.NL wrote:
>
>>
>> I don't know anything about sha, but you can call a zsql methode
>> sql_abcdefg from a python script this way:
>> RS=context.sql_abcdefg(var1=v1,var2=v2)
>> for row in RS:
>>   for column in row:
>>       print column
>>
>>
>> Met vriendelijke groeten,
>>
>> Hans de Wit
>> Stichting Farmaceutische Kengetallen
>> Postbus 30460
>> 2500 GL  DEN HAAG
>> Tel. 070-3737448
>> Fax 070-3737445
>>
>>
>>
>
>>                       Alejandro
>>
>
>>                       Fernandez                To:      zope@zope.org
>>
>
>>                       <shomon@softhome         cc:
>>
>
>>                       .net>                    Subject: [Zope] sha and
>>                       newbie db question.
>>
>>                       Sent by:
>>
>
>>                       zope-admin@zope.
>>
>
>>                       org
>>
>
>>
>
>>
>
>>                       19-06-02 10:58
>>
>
>>
>
>>
>
>>
>>
>>
>>
>> Hi,
>>
>> I have 2 questions:
>>
>> I'm trying to replicate the following php code in zope:
>>
>> $code = $HTTP_POST_VARS["CODE"];
>> $codemd5  = md5($code);
>>
>> I believe that in straight python, this would be:
>>
>> hcode = sha.new(code).hexdigest()
>>
>> (because as far as I know, there's no md5 equivalent of "hexdigest").
>>
>> But when I run this in a python script, which recieves such a value from
>> a dtml method with a form in it, it complains that it's not allowed to
>> run"new". I'm sorry if this is a well known security restriction, and
>> the page of the zope book or of some manual to get around it would be
>> enough for me thanks!
>>
>> Second problem is a lot easier: I've looked at the relational database
>> chapter of the zope book, but have not found exactly how to do a call to
>> a zsql method from within a python script. Is there somewhere where I
>> can get examples of the dtml/python script code behind a database backed
>> website? The code in particular wouldn't be to display something, but
>> for operations such as inserting, deleting, cacheing queries, storing
>> variables, etc.
>>
>> Thanks so much!
>>
>> Ale
>>
>> --
>> Alejandro Fernandez
>> Electronic Group Interactive
>> --+34-65-232-8086--
>>
>>
>> _______________________________________________
>> Zope maillist  -  Zope@zope.org
>> http://lists.zope.org/mailman/listinfo/zope
>> **   No cross posts or HTML encoding!  **
>> (Related lists -
>>  http://lists.zope.org/mailman/listinfo/zope-announce
>>  http://lists.zope.org/mailman/listinfo/zope-dev )
>>
>>
>>
>>
>>
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )