1 << >> 512 entries on 359 pages 
chronological datelist docs images search download love

Sat 13 Apr 2002 18:18
my computer has been seeming slow.
the woman police officer was nice looking.
human relationships with software and computers. With the software, really.
perhaps at 7 I shall go for my evening hour.
Joanna,
peter
eal
phil
relax
food
asia
joanna sort of calling.
peter's dream
I don't remember it,
peace
what's important
what matters
and now

future?
pool man.

80s

love
moving
yes.

2002-04-13-1907
the bastards in 56
there is a strategy of antagonism which goes like this:
act like an asshole--when the authorities come, act nice--when prudent, act like an asshole again. In this way you wear down the resistance of those who would have you not do your loud music playing behavior.
to call the police again?
The police need a web enabled noise complaint form.


.

Sat 13 Apr 2002 11:00
o how did demonstrations ever come to be perceived as an effective action?
o Record expires on 2002-09-29 11:34:31+10 ea.org

j9k.com, ea.com 2003-03-21
openacs.org
aolserver.com
http://webware.sourceforge.net/
http://www.mems-exchange.org/software/quixote/
http://pywx.idyll.org/

make more money to pay to run my own server?




# Example code:

# Import DTML from standard class and
# get the HTML request and response objects.
from Products.PythonScripts.standard import DTML

request = container.REQUEST
RESPONSE =  request.RESPONSE

myString = '<dtml-var standard_html_header>'

# "Coerce" into a DTML-object
myDTML = DTML(myString)

# Return the rendered DTML by *calling* the DTML-object,
# in this case myDTML. context is the namepace - IMPORTANT
return myDTML(context, request, RESPONSE)

# RESPONSE can actually be ommited totally, since it is not used
# and defaults to None.  To restrict the namespace you can use
# container instead, that way the DTML object will not aq vars
# outside the containing object/folder of this PythonScript


Get linux on vaio

Benjamin John Burger
Division of Paleontology
American Museum of Natural History
Central Park West at 79th Street
New York, New York 10024 bjburger@amnh.org

# Example code:

# Import the structured_text standard class,
# and get the HTML request and response objects.
from Products.PythonScripts.standard import structured_text

request = container.REQUEST
RESPONSE =  request.RESPONSE

# An example STX string
stx = """
User Management - A more modular approach

  *by Dario Lopez-K‰sten, dario@ita.chalmers.se,
  IT Systems & Services, Chalmers University of Technology*

  When managing users, one could view the management process as using these following four separate logical services:


    * Identification/authentication Services
"""

# render it. structured_text returns the rendered string
myStx = structured_text(stx)

return myStx



Comments:

correction by peterbe - 2002-02-18

There's a bug in the structured_text module there so it returns and <html> and <body> tag too.

I think thi is better:

myStx = structured_text(stx)
myStx = myStx.replace('<html>','')
myStx = myStx.replace('</html>','')
myStx = myStx.replace('<body>','')
myStx = myStx.replace('</body>','')



 
Re: correction by jens - 2002-02-18

You can write an external python function like this:

return str(StructuredText.HTML(stx, level=1, header=0))

create a new (Script) Python called: tree_walk
arguements are: self, level=0

then from a dtml method you can see the leafs by:
<dtml-var "tree_walk(this())">



Source (Text):

c = []
if len(self.objectValues('Folder'))==0:
    #you could create a image in all leafs by self.manage_addImage()
    return 'leaf id ' + self.id + ' @ ' + str(level) + ' deep '

for a in self.objectValues('Folder'):
    c.append(self.tree_walk(a, level+1))

return c



Submitted by: speedjet
Last Edited: 2001-12-20

Category: Python(Script)
Average rating is: 0.0 out of
5
(0 ratings)


Description:
I'm a newcomer to Zope, came from a world of PHP and other web tools
for development, and found "simple chinese" try to understand the URL
written by scripting engines,
too many "?name=You+name&otherthing=whatever" are type of URL that
limit you share them with your friends, or tell
your grandma visit that page :)
Zope could do that, but offer a "fancier" alternative
(and more search-engine-friendly and HUMAN-friendly :)



Source (Text):

## Script (Python) "parseParams"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=subpath
##title=
##
# subpath is the original traverse_subpath that our
# caller script/pagetemplate want to convert

# put all your valitation and checking here.

# use range(len(subpath)/2) to create a sequence of 'pairs'
# contained in the list.
# NOTE: This will only work if your list item count is a even count
# don't blame me if you get an Exception for using it without
# take all the care and evaluate it before :)
# you can't call the script directly (due the definion of subpath
# as parameter, that will raise and exception.

params = {}

for index in range(len(subpath)/2):
    params[subpath[index*2]] = subpath[index*2+1]

return params



Explanation:

Hidden inside Zope, traverse_subpath offer to PythonScripts (and ZPT)
a list of each branch added after the method/script/pagetemplate
that we call.

So, if we write an URL like this:
http://localhost/myScript/param1/value1/param2/value2

traverse_subpath will return a list that contain:
['param1', 'value1', 'param2', 'value2']

Now, directly, this information isn't useful for us,
but after some "magical conversion" (aka: PythonScript)
we could get a dictionary that contains key:value with each pair
in the list shown before.

Of the simplicity in the scrip shown above,
you could see that validation and checking was leaved to you :)

why use range()?
Was spinning in my head a solution to "iterate" in a list, in pairs,
but couldn't find it, so, hack it!

this could be implemented in a ZPT to get the parameters and use/pass
them to ZSQLMethods, PythonScript or even be used to create a redirector?

<div tal:define="global params python:here.parseParams(traverse_subpath)" />

<b tal:content="params/myparameter | nothing">Here will be the value of 'myparameter'</b>


Ok, bye for now, any coments on this, are welcome!.
(excuse my poor english, trying harder to improve it, when aren't trying to understand zope :)

speedjet



Comments:

No Comments



quick search:



Anonymous User

Join
Login

Features

Lab Wear
Advanced Search

Related

Developer Guide
UnRestricted Scripts
Developer's Guide
Daily-URL!

Z O P E

Get Zope

Achieve Zen
Newbies
CommunityRant
The Book
Building Websites
Hosting
EU Hosting

Information

Help!

PyReference
PyCookbook
FAQTs
Daily-URL!
Contact

Copyright © 2001
zopeLABS and community

 
Form Validation using Formulator

Submitted by: runyaga
Last Edited: 2001-12-08

Category: Python(Script)
Average rating is: 0.0 out of 5
(0 ratings)


Description:

Wanna do form validation? Its pretty straightforward to do it in ZOPE. The trickest part is allowing formulator modules to be imported for Script (Python) use. Following this script you can pretty much get the idea on how to use Formulator as the validation mechanism for your forms.

Uses latest Formulator and DTML.
Does not appear to work with Zope2.5 (as of beta2)
Does not appear to work with Zope2.3.x (darn it)
Works fine for Zope2.4 ;) -- feedback is needed.



Source (Text):

#create a Script Python called process_form
from Products.Formulator.Form import FormValidationError
from Products.Formulator.Form import BasicForm
from Products.Formulator import StandardFields

errors={}
foo=StandardFields.StringField('foo', title='foo', required=1, display_width=20, max_length=20)
emailaddress=StandardFields.EmailField('emailaddress', title='emailaddress')
f=BasicForm()
f.add_fields( (foo, emailaddress) )

try:
    result=f.validate_all(REQUEST)
except FormValidationError, e:
    for error in e.errors:
        errors[error.field.get_value('title')]=error.error_text
    REQUEST.set('errors', errors)
    return context.testValidator(context, context.REQUEST)

return 'all fields valid'

#create a DTML method called testValidator
<form name="form" method="POST" action="process_form" enctype="multipart/form-data">
 <dtml-let errors="REQUEST.get('errors',{})">
  String field:
  <input type="text" name="field_foo"
   value="<dtml-if field_foo>&dtml-field_foo;</dtml-if>" />
   <dtml-if "errors.has_key('foo')">ERR: <dtml-var "errors['foo']"> </dtml-if>  <br/>
  Email Field:
  <input type="text" name="field_emailaddress"
    value="<dtml-if field_emailaddress>&dtml-field_emailaddress;</dtml-if>" />
   <dtml-if "errors.has_key('emailaddress')">ERR: <dtml-var "errors['emailaddress']"> </dtml-if>  <br/>
  <input type="submit" value="submit" />
 </dtml-let>
</form>

#create a folder in $ZOPE/lib/python/Products called GlobalScripts
#create a file in $ZOPE/lib/python/Products/GlobalScripts/__init__.pyfrom Products.CMFCore import DirectoryView, utils
from Products.CMFDecor import FSPageTemplate

from Products.PythonScripts.Utility import allow_module, allow_class
allow_module('Products')
allow_module('Products.Formulator')
allow_module('Products.Formulator.Form')
from Products.Formulator.StandardFields import StringField, FileField, EmailField
from Products.Formulator.Form import FormValidationError, BasicForm
allow_class(StringField)
allow_class(FileField)
allow_class(EmailField)
allow_class(FormValidationError)
allow_class(BasicForm)

#restart your zope server for the module to be exposed



Explanation:

dont have time to explain it yet. I will explain it later. only thing I dont like
abotu this is that the dtml kinda has to know about the imlpementation of
formulator &dtml-field_emailaddress;

someone up for explaining this



Comments:

No Comments
memory.com customer number 30045
A128MSYSR7

.

1 << >> 512 entries on 359 pages 
chronological datelist docs images search download love


about this site