#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Posts
    0
    Rep Power
    0

    Question writing pyhton scripts in zope


    i am building a website in Zope, and learning as i go along. can somebody help demonstrate how to write custom functions (using Python scripts i guess) such as:

    a function called DrawSpacer() that would handle variables for height and width, so that when

    DrawSpacer(50, 20)

    is called, the result is something like

    <img src="/img/spacer.gif" height="50" width="20">

    (after the page is parsed or course)? i have done this with ASP, but i cannot get it to work in Zope, yet i'm sure it can easily be done. this type of functionality would allow me to break up many parts of the site into reusable modules that draw certain aspects of the page; i just need a basic example to learn from.

    thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Posts
    266
    Rep Power
    14
    First off I don't use Zope but I do write python. But since not many people post here I thought some help is better than none.

    If I where to write what you described it would look like this

    def DrawSpacer(height, width):
    print "<img src=\"/img/spacer.gif\" height=\"%d\" width=\"%d\">" % (height, width)


    Then when you execute the function:

    DrawSpacer(50, 20)

    You should get what you want. Hope this helps.

    E.
  4. #3
  5. No Profile Picture
    Consultant
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    Monroe, WA, USA
    Posts
    0
    Rep Power
    0
    What you want is listed below:


    Code:
    print "<img src='/img/spacer.gif' height='%d'0 width='%d'>" % (height, width) 
    return printed

IMN logo majestic logo threadwatch logo seochat tools logo