Re: [Zope-dev] Massive scalability

2001-01-14 Thread Steve Alexander

Michael Bernstein wrote:

 I am currently planning two separate 'Archive' type
 projects/Products. In both cases, I need to make sure that
 my implementation will scale to hundreds of thousands or
 even millions of objects.
 

 In one project the objects are very simple ZClasses with a
 few attributes, in the other project, the objects will be
 instances of the Photo Product, and considerably larger.

Do you mean "instances of the Photo Product" or "instances of class 
FooBar from the Photo Product" ?

 One implementation I'm considering is a simple Specialist
 with a Rack. Does anyone know if there are any inherent
 limitations on the number of objects that can be stored in a
 Rack? are there any performance limitations at the scale
 that I'm talking about?

Seeing as a Rack can provide data from absolutely anywhere, I can't see 
a problem with this.
If you're talking about the BTree implementation that Racks use when 
they store data in the ZODB, well, I've never stored more than a few 
thousand objects in one of those. There certainly aren't the same 
limitations that you get with the default ObjectManager, as that uses a 
python dict to hold its sub-objects.

The performance limitations will more likely be to do with searching and 
indexing the data, adding the data in bulk (if you need to do this), and 
retrieving the data if you have a vast number of clients wanting it all 
at once.

 The other implementation I'm considering is to create a
 ZClass that inherits from ZCatalog and Btree Folder.

I can't think why you'd want to do that. What role would instances of 
this class play in your application?

 Would
 this approach run into any scalability problems with the
 number and type of objects I'm talking about?

I think other aspects of your application will determine whether it will 
scale. Scalabillity is an emergent property of a system. You only get to 
know about it when you consider the system holisticly.

With Zope, where you store objects and how you plan to find objects, is 
more significant than what the objects you're storing are.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




[Zope-dev] Tip: Skinscript Debugging

2001-01-14 Thread Steve Alexander

When debugging skinscript, especially tricky dependencies between what 
gets computed when during state changes, do the following:

1: Run zope in debug mode (-D)

2: Put an external method called print_ in the root of your ZODB, with 
the code:

   def print_(s):
 print s

3: In your SkinScript, if you want to know when a trigger is called, or 
when a set of attributes get computed, use this kind of thing:

WITH QUERY foo(id=some_id) COMPUTE
   thing=RESULT,
   bar=baz,
   _printout_foo=self.print_('query foo called, id=%s' % some_id)
OTHERWISE LET
   thing=_.None,
   bar='no bar',
   _printout_foo=self.print_('query foo called, otherwise clause')


WHEN OBJECT CHANGED CALL
print_('CHANGED start'),
Catalog
.uncatalog_object(_.string.join(self.getPhysicalPath(),'/')),
print_('CHANGED middle'),
Catalog
.catalog_object(self, _.string.join(self.getPhysicalPath(),'/')),
print_('CHANGED end')


4: Read the debug printout, and work out that you're computing 
attributes for cataloging before changing the attributes they depend on.

5: Amend code and skinscript, test, document code, sleep.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




[Zope-dev] SkinScript enhancement

2001-01-14 Thread Steve Alexander

While debugging some dependencies in some of my SkinScript, I had an idea.

SkinScript could be extended so that COMPUTE statements can have a 
RECOMPUTE FOR clause. This clause would tell a dataskin to invalidate 
its cache for the attributes in the COMPUTE statement if any of the 
attributes in the RECOMPUTE FOR clause changed.

So,

WITH QUERY some_method(primary_key=ms_vars_id) COMPUTE
   foo,bar,baz
OTHERWISE LET
   foo='no foo',
   bar='no bar',
   baz='no baz'
RECOMPUTE FOR
   ms_vars_id

This is equivalent to the above statement, without the RECOMPUTE FOR 
clause, followed by a trigger:

WHEN OBJECT ADDED, CHANGED CALL
   HAS_CHANGED('ms_vars_id')
 and self._uncache_attrs(['foo', 'bar', 'baz'])

This assumes a method of DataSkins.DataSkin _uncache_attrs:

def _uncache_attrs(self, names):
 v=self._v_attrCache
 for name in names:
   del v[name]


I haven't tested any of this yet.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




[Zope-dev] Re: SkinScript enhancement

2001-01-14 Thread Steve Alexander

Steve Alexander wrote:


 This assumes a method of DataSkins.DataSkin _uncache_attrs:
 
 def _uncache_attrs(self, names):
 v=self._v_attrCache
 for name in names:
   del v[name]
  
 I haven't tested any of this yet.

And I realized just after I sent it that the method should be more like:

  def _uncache_attrs(self, names):
  v=self._v_attrCache
  for name in names:
  if v.has_key(name): del v[name]

-- 
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Massive scalability

2001-01-14 Thread Michael Bernstein

Steve Alexander wrote:
 
 Michael Bernstein wrote:
 
  I am currently planning two separate 'Archive' type
  projects/Products. In both cases, I need to make sure that
  my implementation will scale to hundreds of thousands or
  even millions of objects.
  
 
  In one project the objects are very simple ZClasses with a
  few attributes, in the other project, the objects will be
  instances of the Photo Product, and considerably larger.
 
 Do you mean "instances of the Photo Product" or "instances of class
 FooBar from the Photo Product" ?

Sorry. I meant instances of class Photo from the Photo
Product.

  Does anyone know if there are any inherent
  limitations on the number of objects that can be stored in a
  Rack? are there any performance limitations at the scale
  that I'm talking about?
 
 If you're talking about the BTree implementation that Racks use when
 they store data in the ZODB, well, I've never stored more than a few
 thousand objects in one of those. There certainly aren't the same
 limitations that you get with the default ObjectManager, as that uses a
 python dict to hold its sub-objects.
 
 The performance limitations will more likely be to do with searching and
 indexing the data, adding the data in bulk (if you need to do this), and
 retrieving the data if you have a vast number of clients wanting it all
 at once.

Yes, I was referring to the way a Rack stores data in the
ZODB.

Photo instances store several sizes of the same image as
attributes of the object, as well as various meta-data
fields. I anticipate indexing the meta-data in a ZCatalog.

Data will not be added in bulk, but several people may want
to retreive the data at the same time (if the site becomes
popular).

  The other implementation I'm considering is to create a
  ZClass that inherits from ZCatalog and Btree Folder.
 
 I can't think why you'd want to do that. What role would instances of
 this class play in your application?

The same as the Rack. A single archive of indexed objects.
It seems that this would scale better than creating a ZClass
that inherits from ZCatalog and ObjectManager as described
here:

http://www.zope.org/Members/tseaver/inherit_ZCatalog

  Would
  this approach run into any scalability problems with the
  number and type of objects I'm talking about?
 
 I think other aspects of your application will determine whether it will
 scale. Scalabillity is an emergent property of a system. You only get to
 know about it when you consider the system holisticly.

The system is fairly simple: I want to store a large number
of objects in a single location, I want to index them in a
ZCatalog, I want to find objects by either searching for
them, or by browsing a ZTopics based heirarchy (that is
populated with ZCatalog searches as well).

The search time (whether a user or ZTopic initiates it)
should happen fairly fast, regardless of the number of
objects (potentially hundreds of thousands), and direct
object retreivals (or rendering) should also happen quickly,
without major penalties for the number of objects.

 With Zope, where you store objects and how you plan to find objects, is
 more significant than what the objects you're storing are.

I hope I've explained myself better this time.

Thanks for the help,

Michael Bernstein.

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope] REPOST: dtml-with doesn't work

2001-01-14 Thread Shai Berger


Philip has already made it clear that this was not his problem, but
still,

Dieter Maurer wrote:

 Just a remark:
 
   SQL methods do *NOT* look at the DTML namespace *AT ALL*,
   just at REQUEST (or the expliciitly passed keyword arguments).
 
   Thus, "dtml-with", "dtml-let" and friends are all ineffective
   with respect to ZSQL methods.
 

My experience is somewhat different: ZSQL methods in general *DO*
look at the namespace just like normal DTML methods, with two 
exceptions:

1) The major one, is that Dieter's remark does describe (almost) 
correctly the behavior of dtml-sqlvar and dtml-sqltest. These two 
tags only look at a very limited local namespace, initialized with the
REQUEST and passed arguments; but even this namespace may be modified,
*INSIDE* the ZSQL method, with dtml-in and dtml-let. However, 
other tags behave quite normally -- which means that a lot of the
problems can be bypassed by thoughtful use of dtml-var, especially
using the sql_quote modifier (BTW, it is by virtue of this that you
can call other methods -- even other ZSQL methods -- from within a
ZSQL method).

2) Changing REQUEST does *not* update the local namespace, that is,
within a ZSQL method,

dtml-call "REQUEST.set('some_var', 17)"
dtml-var some_var

doesn't work; but

dtml-var "REQUEST['some_var']"

Does.

Hope this helps,

Shai.

___
Zope maillist  -  [EMAIL PROTECTED]
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] DCOracle bug?

2001-01-14 Thread Shai Berger


Hi guys,

As I have written before, we are using DCOracle 1.3.2 / Oracle 8.0.5
on a Linux/i386. We need some LONG RAW columns, and we hold them
in a special table long_data, with two columns, long_id (int) and
long_data (long raw). Other tables where long data is needed hold
references to this table.

We have recently encountered a peculiar behavior: In Zope, if we issue
a query which selects many rows with one long column each (essentially,

select * from long_data

), it works; if the query selects more than one column, but only one 
row (essentially,

select a.*,b.*
from long_data a, long_data b
where a.long_id=17 and b.long_id=34

), it also works; but if we select multiple rows with multiple long 
columns (as in

select a.*,b.*
from long_data a, long_data b

) we get an Oracle error indicating a buffer is not allocated to 
receive the data.

Has anyone seen anything like this before?

Thanks,
Shai.

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] reindex when a zclass is edited

2001-01-14 Thread Aleksander Salwa

On Sat, 13 Jan 2001, Tim Hicks wrote:

 Thanks very much for the help Aleksander, but when I drop your code into my
 method, it doesn't work (it doesn't break either). I simply copied and
 pasted your code, then edited the final redirect at the bottom.  Here is the
 submission part of my edit form (if it makes any difference).
 
 TD align=left
   INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Change"
  /TD
  TD align=left
INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Taller"
INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Shorter"
INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Wider"
INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Narrower"
  /TD
 
 I had a look on the ZQR, and found the section on manage_edit, but I still
 don't really understand how the dtpref_cols/rows works.  Any insight?

It uses cookies (named 'dtpref_rows' and 'dtpref_cols') storing size of
your textarea. Have you turned off cookies by accident ?
If it receives (from edit form) a variable named 'SUBMIT' with value equal
to one of the above ('Taller', etc.), then it sends new cookie values to
the browser.

Source file: lib/python/OFS/DTMLMethod.py,
methods 'manage_edit' and '_er'.


[EMAIL PROTECTED], [EMAIL PROTECTED]

/--\
| `long long long' is too long for GCC |
\--/


___
Zope maillist  -  [EMAIL PROTECTED]
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] PrincipiaSearchSource() dtml-method and Catalog

2001-01-14 Thread Max M

I have made a dtml method called "PrincipiaSearchSource" in a bunch of
zClasses so that my Catalog will index severeal parameters in the zClass,
but nothing happens.

As far as I can see PrincipiaSearchSource is a default value that is indexed
in catalog. Have I misunderstood that?

The title gets indexed ok when i update my classes but not the content
delivered via the PrincipiaSearchSource method. Does anybody have an idea?

I have tried to return via PrincipiaSearchSource in 2 different ways (None
of which works):

#1 ---
dtml-return "var1 + var2 +var3"

#2 ---
dtml-var var1 dtml-var var2 dtml-var var2

regards Max M

Max M. W. Rasmussen,Denmark.   New Media Director
private: [EMAIL PROTECTED] work: [EMAIL PROTECTED]
-
Specialization is for insects.  -  Robert A. Heinlein


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] PrincipiaSearchSource() dtml-method and Catalog

2001-01-14 Thread Geir Bækholt

PrincipiaSearchSource  will  have  to be a PythonMethod or an External
Method.

dtml won't be called by Catalog... Anything Python will work.

so instead of :  dtml-return "var1 + var2 +var3" , you have to use :
return var1 + var2 + var3

--
Geir Bkholt
web-developer/designer
[EMAIL PROTECTED]
http://www.funcom.com

on Sunday, January 14, 2001 Max M wrote :
MM I have made a dtml method called "PrincipiaSearchSource" in a bunch of
MM zClasses so that my Catalog will index severeal parameters in the zClass,
MM but nothing happens.

MM As far as I can see PrincipiaSearchSource is a default value that is indexed
MM in catalog. Have I misunderstood that?

MM The title gets indexed ok when i update my classes but not the content
MM delivered via the PrincipiaSearchSource method. Does anybody have an idea?

MM I have tried to return via PrincipiaSearchSource in 2 different ways (None
MM of which works):

MM #1 ---
MM dtml-return "var1 + var2 +var3"

MM #2 ---
MM dtml-var var1 dtml-var var2 dtml-var var2

MM regards Max M

MM Max M. W. Rasmussen,Denmark.   New Media Director
MM private: [EMAIL PROTECTED] work: [EMAIL PROTECTED]
MM -
MM Specialization is for insects.  -  Robert A. Heinlein


MM ___
MM Zope maillist  -  [EMAIL PROTECTED]
MM http://lists.zope.org/mailman/listinfo/zope
MM **   No cross posts or HTML encoding!  **
MM (Related lists - 
MM  http://lists.zope.org/mailman/listinfo/zope-announce
MM  http://lists.zope.org/mailman/listinfo/zope-dev )



___
Zope maillist  -  [EMAIL PROTECTED]
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] Raw post data

2001-01-14 Thread Shai Berger

Hi guys,

For several reasons, I would like to have direct access to raw posted 
data in my dtml-code (an analogue of QUERY_STRING). Can anyone please
show me the light?

Thanks,
Shai.

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] Raw post data

2001-01-14 Thread Steve Spicklemire


Hi Shai,

   This external method works for me.

-steve

--

def getRawInput(self, REQUEST):

meth = REQUEST.environ.get('REQUEST_METHOD','GET')

if meth != 'GET':
REQUEST.stdin.seek(0)
result = REQUEST.stdin.read()
else:
result = REQUEST.environ.get('QUERY_STRING','')

return result

#
# Test functions..
#
if __name__=='__main__':

import StringIO

class Foo:
pass

REQUEST = Foo()
REQUEST.environ =  {'REQUEST_METHOD':'GET', 'QUERY_STRING':"Yup.. it's a query 
string."}
print getRawInput(None, REQUEST)

REQUEST = Foo()
REQUEST.environ =  {'REQUEST_METHOD':'POST'}
REQUEST.stdin = StringIO.StringIO()
REQUEST.stdin.write("It's a streamed input ")

print getRawInput(None, REQUEST)



___
Zope maillist  -  [EMAIL PROTECTED]
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] Re: [Skinscript] unable to update property

2001-01-14 Thread Steve Spicklemire


Hi Dirksen,

   I think that WHEN OBJECT CHANGED is used when some code tries to 
change a DataSkin attribute and you need to update some external source.
So... an appropriate thing to do would be to call an SQL method, or
talk to another Specalist which needs to be notified .. etc. I think
that you may be 'double' chaning... e.g., some code tries to change
the transaction count... this fires a trigger that *also* tries to change
the same thing... hence the conflic error. Can you share the code
that is firing the trigger? (TransCount is used to keep track of 
the shopper's 'current' transaction. In the current implementation
It is used to calculate a 'basked id' since each shopper can have
mulitiple baskets, as they return for more shopping later.. ) TransCount
should only be modified when a shopper completes a transaction and
they need a 'new' basket. Does that help?

-steve


 "Dirksen" == Dirksen  [EMAIL PROTECTED] writes:

Dirksen Hi Steve,

Dirksen I ran into a very tricky problem when developing a site
Dirksen with emarket. Here is the structure of my site:

Dirksen root |--acl_users(Membership product) |--emarket
Dirksen |--shoppers

Dirksen The acl_users is an instance of Membership product, which
Dirksen is as a specialist as shoppers, and they both have a
Dirksen WebIC_MemberClass zclass as their rack object class. The
Dirksen difference is that, acl_users stores WebIC_MemberClass
Dirksen persistently, while shoppers just reflects that
Dirksen storage. Here is the skinscript for shopper's rack:

Dirksen WITH acl_users.getItem(self.id) COMPUTE oo=RESULT

Dirksen WITH self.oo COMPUTE email, transCount

Dirksen WHEN OBJECT CHANGED STORE transCount USING
Dirksen 
self.oo.propertysheets.webic.manage_changeProperties(transCount=self.transCount)

Dirksen When emarket trying to increment a shopper's transCount,
Dirksen I ran into a "ZODB.POSException.ConflictError". The
Dirksen following is the traceback: Traceback (innermost last):
Dirksen File C:\WebSite\lib\python\ZPublisher\Publish.py, line
Dirksen 222, in publish_module File
Dirksen C:\WebSite\lib\python\ZPublisher\Publish.py, line 199, in
Dirksen publish File C:\WebSite\lib\python\ZPublisher\Publish.py,
Dirksen line 199, in publish File
Dirksen C:\WebSite\lib\python\ZPublisher\Publish.py, line 199, in
Dirksen publish File C:\WebSite\lib\python\ZPublisher\Publish.py,
Dirksen line 195, in publish File
Dirksen C:\WebSite\lib\python\Zope\__init__.py, line 188, in
Dirksen zpublisher_exception_hook (Object: ProviderContainer)
Dirksen File C:\WebSite\lib\python\ZPublisher\Publish.py, line
Dirksen 175, in publish File
Dirksen C:\WebSite\lib\python\Zope\__init__.py, line 235, in
Dirksen commit File C:\WebSite\lib\python\ZODB\Transaction.py,
Dirksen line 251, in commit File
Dirksen C:\WebSite\lib\python\ZODB\Connection.py, line 351, in
Dirksen commit (Info: (('*hdVMVCvgk/wIgJaYf/nkEA==',
Dirksen 'WebIC_MemberClass'), '\000\000\000\000\000\000d\357',
Dirksen '')) File C:\WebSite\lib\python\ZODB\FileStorage.py, line
Dirksen 664, in store (Object: C:\WebSite/var/Data.fs)
Dirksen ConflictError: ('\0039\323C4=\266\210',
Dirksen '\0039\323B\375\036\270U')

Dirksen Is it something wrong with my skinscript?

Dirksen cheers Dirksen



Dirksen __ Do You
Dirksen Yahoo!?  Get email at your own domain with Yahoo! Mail.
Dirksen http://personal.mail.yahoo.com/


___
Zope maillist  -  [EMAIL PROTECTED]
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] convert a String ...

2001-01-14 Thread Marc Fischer


Hi,

how is it possible to convert a string into my own zclass type?
I get a String from a form and want to do some operation like
string.manage_addFile(... on it. So what to do ??? Perhaps some out there is
able to help ...

Thanks,

Marc


___
Zope maillist  -  [EMAIL PROTECTED]
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] ZMySQLDA, Problems Connecting

2001-01-14 Thread Steve McMahon

Greetings Zopers,

I'm attempting to make connections between Zope and MySQL using 
MySQL-python 0.3.0 and ZMySQLDA 2.01.

The Python/MySQLdb side is working. I can use "connect(db='test')" or 
"connect(db='test', user='guest', passwd='token')" -- where guest and token 
are a MySQL username and password -- to build a connection object and go on 
to do queries.

However, when I attempt to add a Z MySQL Database Connection to a folder, I 
get "Invalid connection string" -- no matter what the connection string I 
offer. (e.g., "test" or "test guest token" or "test@localhost guest token" 
or any number of permutations of these.

Anybody run into this problem? Any suggestions on avenues to pursue?

Thanks, Steve McMahon


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] ZClasses meet PythonScripts, sample request

2001-01-14 Thread Jim Washington

Hi, Tim

I am not working through that example, but the below is a start on what
you seem to need. Let me know what you think.

good luck!

-- Jim Washington

***

You probably want the work to be done in the context of an instance of
the class, so assure you have "context" bound to the Python Script on
the "bindings" tab.  It's bound by default.

You might want to name the Script in a Zopish way to distinguish it from
other scripts that may do other things.  I would probably call it
manage_changeCDProperties.

You will want to pass REQUEST to it so you can use it like the Zope
builtins:

containerName.CDInfoName.manage_changeCDProperties(REQUEST)

So, put REQUEST in the parameters list.

(BTW, REQUEST is available as context.REQUEST if you choose not to pass
REQUEST.)

Inside the script, you would use Zope's manage_changeProperties method:

context.propertysheets['cd_info'].manage_changeProperties(REQUEST)
-or-
context.propertysheets.cd_info.manage_changeProperties(REQUEST)

You're done, unless you want to get fancy and process the items
separately.

If you want to get fancy, REQUEST.form['title'], REQUEST.form['artist'],
and REQUEST.form['date_purchased'] are available to you.

For example, if you want to assure title case for title and artist (try
this in DTML first, just to get the scope of how much easier it is in a
Python Script):

import string
dontCapitalize = ['a','in','of', 'for']
localPropertiesDict = {}
for aproperty in ['title','artist']:
  theProperty = string.strip(REQUEST.form[aproperty])
  splitWords = string.split(theProperty)
  newlist = []
  for aWord in splitWords:
if aWord in dontCapitalize and aWord != splitWords[0]:
  newlist.append(string.lower(aWord))
else:
  newlist.append(string.capitalize(aWord))
  newValue = string.join(newlist,' ')
  localPropertiesDict[aproperty] = newValue
context.propertysheets['cd_info'].manage_changeProperties(localPropertiesDict)  





To delete something from the ZODB, pass a list of ids to
manage_delObjects in your container.

To delete them all:

thelist = context.containerName.objectIds('CD_Info')
context.containerName.manage_delObjects(thelist)

Let's say you lent out all your Britney Spears CDs and don't expect to
get them back.  How do you update your collection?

Make a form that allows you to select 'Britney Spears' into a variable
called 'deleteThisArtist'

Make a Python Script that is called by the action for the form.  This
goes into your class for CD collection, whatever you have named it.

import string
#we make this case-insensitive by converting all to uppercase
deleteMe = string.upper(context.REQUEST.form['deleteThisArtist'])
listToDel = []
for CD in context.objectValues('CD_Info'):
  if string.upper(CD.artist) == deleteMe:
listToDel.append(CD.id)  #in Zope-2.3.0+, you should use .getId()
instead of .id
context.manage_delObjects(listToDel)


Timothy Wilson wrote:
 
 Hi everyone,
 
 I'm looking forward to using some PythonScripts as methods of some ZClasses
 because it seems like a much cleaner way to do things. I wonder if one of
 the PythonScript gurus out there would be willing to show an example of two
 presumably common PythonScript/ZClass tasks: processing changes to a
 property sheet using form input and deleting a ZClass instance.
 
 Let's say we've got a ZClass for keeping track of a CD collection. (I recall
 seeing that example in a ZClass How-To.) Let's say the ZClass has a property
 sheet called 'cd_info' with the following properties:
 
 title (string)
 artist (string)
 date_purchased (date)
 
 (for extra credit, add a 'songs' property of type 'lines' :-)
 
 Is that enough info? Anybody want to take a crack at this? (This would
 surely be good info to put at zope.org somewhere.)
 
 -Tim

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




RE: [Zope] hasRole bug or feature in 2.2.?

2001-01-14 Thread Dieter Maurer

Ron Bickers writes:
  I think I understand, but correct me if I'm wrong.  The problem is that my
  browser is not even *sending* the authentication information to the other
  parts of the site until I first access a protected document at the root
  level.  That is, the browser only continues to send auth info on levels at
  and below where I've requested a protected document.  If that potected
  document is at the root level, I get the auth info everywhere in the site.
  Does this also mean that even after authenticating myself on one part of the
  site, accessing a protected document on another part of the site may result
  in an "unauthroized" response from Zope, to which my browser kindly responds
  for me without me realizing it?
Yes, that may well be the case.

You may read RFC 2617 which describes HTTP authentication.
Browsers have a bit of freedom to decide when (and partially what)
authentication information they may send.

The spec allows them to automatically include authentication
information for requests into a subtree, when the root required
authorization. This is to efficiently handle the usual policy that
objects are not protected in isolation but usually whole
subtrees are protected.

  If this is true, it explains clearly Zope's behavior.  It's really a browser
  "feature" and not a Zope issue at all.
Right.

  Given that, is it fair to say that I can never really be sure that an
  authenticated user (somewhere else on the site) accessing an unprotected
  document has a given role?  Or would it be safe to assume that after
  accessing a root protected document, hasRole() will return the "right"
  answer anywhere in the site?
You can not be sure. As said above, RFC 2617 lets browsers lots
of freedom about authentication information.
It suggests however (for efficiency reasons) that browsers
should behave as you hope for.

You get some more control, when you use cookie based authentication.
The cookie spec allows for the "path" parameter that instructs
the browser into what parts of the site the cookie
should be sent. As I know, Zope'e cookie based authentication
products define the cookie in such a way that it is sent to
the whole site.

This will not give complete safety (with respect to question),
as the browser may drop the cookie for various reasons
thereby effectively performing a log out.

  If I can't safely assume any of the above, would I be better off using a
  session product to track a user after log in so I can determine their roles
  from an unprotected document?  Any other ways?
If the session product uses cookies, you will have a situation
similar to cookie based authentication. Otherwise, you
will need to shift the session id often between query string
and hidden variable which is a bit tedious.

  My goal, BTW, is to avoid showing certain content on an otherwise public
  page unless the authenticated user has the Member role.  If there is a
  cleaner way to do this, I'm all ears.
If your users have trust in cookies (unlike me), I would
go for cookie based authentication.
Otherwise, I would place a "login" document in the root folder
and trust the browsers that they want to be efficient
and therefore send authentication information with all requests
to the site.



Dieter

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] ZClasses meet PythonScripts, sample request

2001-01-14 Thread Evan Simpson

From: "Jim Washington" [EMAIL PROTECTED]
 I am not working through that example, but the below is a start on what
 you seem to need. Let me know what you think.

Thanks for the fine examples!  I have only one nit to pick; When using
Scripts in ZClasses, you will typically want to use 'container', not
'context', since 'context' may not be the ZClass instance, but 'container'
always is.  Of course, a Script may operate on both the instance and on
whatever object it was called on, in which case both 'container' and
'context' will be used.

Cheers,

Evan @ digicool  4-am


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] convert a String ...

2001-01-14 Thread Peter Bengtsson

To "convert" a string to an object, you use the getitem() function.

## example 1:
Your: dtml-var last_name
#returns:
Your: Peter Bengtsson

## example 2:
dtml-call "REQUEST.set('var_to_go_and_get','last_name')"
Your: dtml-var "_.getitem(var_to_go_and_get)"
# returns:
Your: Peter Bengtsson

There's more

You could also do this:

dtml-var "_[var_to_go_and_get]" or dtml-var "_['last_name']"

The different between _['foo'] and _.getitem('foo') is tricky. 
Check out (somewhere in the middle):
http://www.zope.org/Documentation/How-To/AdvancedDTML
 
 Hi,
 
 how is it possible to convert a string into my own zclass type?
 I get a String from a form and want to do some operation like
 string.manage_addFile(... on it. So what to do ??? Perhaps some out there is
 able to help ...
 
 Thanks,
 
 Marc
 
 
 ___
 Zope maillist  -  [EMAIL PROTECTED]
 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  -  [EMAIL PROTECTED]
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] renaming python input params in DTML

2001-01-14 Thread Lee

Hi,

I am having a problem passing in a variable to a Python method, which is
obtained from the REQUEST object - I'd really appreciate someone's
insight into how to correctly go about this.

I have a form that submits a parameter named '9728430xp0xclasstest' with
a value = 7 to a DTML method.

I have a Python method expecting 'text' as a parameter so I want the
DTML method to send 'text' onto this with a value = the value of the
original parameter appended to name (i.e. 9728430xp0xclasstestx7).

So text=9728430xp0xclasstestx7

Does that make sense?

The Python method, testSQL, returns 'result'. As I recently found out, I
have to make to make use of the REQUEST object to obtain these
parameters.

The following snippet produces the correct value
(9728430xp0xclasstestx7)...

dtml-in expr="REQUEST.form.items()"dtml-var sequence-keyxdtml-var
sequence-item/dtml-in

... but how can I can pass this as 'text' to my Python method?

Am I on the right track with the following:

dtml-in expr="REQUEST.form.items()"
dtml-in expr="testSQL(text='dtml-var sequence-keyxdtml-var
sequence-item')"
dtml-var result
/dtml-in/dtml-in

Thank very much for any help you can offer.

- Best regards,

PS:

dtml-let text="'9728430xp0xclasstestx7'"
dtml-var text
/dtml-let ... may help

but...

dtml-var standard_html_header
dtml-in expr="REQUEST.form.items()"
   dtml-let text="'dtml-var sequence-keyxdtml-var sequence-item'"
  dtml-var text
 /dtml-let
/dtml-in ... gives me text = x !

Any help would really be appreciated?

Thanks :)

--
Lee Reilly
mailto:[EMAIL PROTECTED]

````

HAVE SKILLS; WILL TRAVEL.

I'm currently looking for an internship in the USA
in the field of web development. Ideally, I'm looking
for a placement for 3 to 18 months. Can you help?

More details, my resume, etc. @
http://homepages.strath.ac.uk/~aeu97172/

/shameless plug




___
Zope maillist  -  [EMAIL PROTECTED]
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 )




RE: [Zope] renaming python input params in DTML

2001-01-14 Thread Randall F. Kern

You can't use DTML tags inside an expr="" attribute; the value of expr
is python code.

To access the sequence-item variable from python, you need:
_['sequence-item']

So, try something like this (untested):

dtml-in expr="REQUEST.form.items()"
dtml-in expr="testSQL(text=_['sequence-key'] + 'x' +
_['sequence-item'])"
dtml-var result
/dtml-in/dtml-in


-Randy

-Original Message-
From: Lee [mailto:[EMAIL PROTECTED]]
Sent: Sunday, January 14, 2001 1:23 PM
To: [EMAIL PROTECTED]
Subject: [Zope] renaming python input params in DTML


Hi,

I am having a problem passing in a variable to a Python method, which is
obtained from the REQUEST object - I'd really appreciate someone's
insight into how to correctly go about this.

I have a form that submits a parameter named '9728430xp0xclasstest' with
a value = 7 to a DTML method.

I have a Python method expecting 'text' as a parameter so I want the
DTML method to send 'text' onto this with a value = the value of the
original parameter appended to name (i.e. 9728430xp0xclasstestx7).

So text=9728430xp0xclasstestx7

Does that make sense?

The Python method, testSQL, returns 'result'. As I recently found out, I
have to make to make use of the REQUEST object to obtain these
parameters.

The following snippet produces the correct value
(9728430xp0xclasstestx7)...

dtml-in expr="REQUEST.form.items()"dtml-var sequence-keyxdtml-var
sequence-item/dtml-in

... but how can I can pass this as 'text' to my Python method?

Am I on the right track with the following:

dtml-in expr="REQUEST.form.items()"
dtml-in expr="testSQL(text='dtml-var sequence-keyxdtml-var
sequence-item')"
dtml-var result
/dtml-in/dtml-in

Thank very much for any help you can offer.

- Best regards,

PS:

dtml-let text="'9728430xp0xclasstestx7'"
dtml-var text
/dtml-let ... may help

but...

dtml-var standard_html_header
dtml-in expr="REQUEST.form.items()"
   dtml-let text="'dtml-var sequence-keyxdtml-var sequence-item'"
  dtml-var text
 /dtml-let
/dtml-in ... gives me text = x !

Any help would really be appreciated?

Thanks :)

--
Lee Reilly
mailto:[EMAIL PROTECTED]

````

HAVE SKILLS; WILL TRAVEL.

I'm currently looking for an internship in the USA
in the field of web development. Ideally, I'm looking
for a placement for 3 to 18 months. Can you help?

More details, my resume, etc. @
http://homepages.strath.ac.uk/~aeu97172/

/shameless plug




___
Zope maillist  -  [EMAIL PROTECTED]
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  -  [EMAIL PROTECTED]
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 )




Re: [Zope] Raw post data

2001-01-14 Thread Dieter Maurer

Shai Berger writes:
  For several reasons, I would like to have direct access to raw posted 
  data in my dtml-code (an analogue of QUERY_STRING). Can anyone please
  show me the light?
"REQUEST['BODY']" may work.


Dieter

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] TREE tag - not showing Folderish objects that contain no sub-objects

2001-01-14 Thread Dieter Maurer

Kevin Howe writes:
  ...
dtml-tree expr="PARENTS[-1]" branches_expr="objectValues()" sort=id
  ...
  What I would like to do is display these objects, but ONLY IF they currently
  contain some objects, so that if an object does not contain any subobjects
  at the moment, it is not displayed.
Search the searchable list archive.

There has recently been a thread about filtering for "dtml-tree".
Search for "branches_expr" to locate the thread.


Dieter

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] REPOST: dtml-with doesn't work

2001-01-14 Thread Dieter Maurer

I checked the sources

Shai Berger writes:
  My experience is somewhat different: ZSQL methods in general *DO*
  look at the namespace just like normal DTML methods, with two 
  exceptions:
ZSQL methods do *NOT* look at the DTML(!) namespace.

They do look at REQUEST or (exclusive) explicitly provided keyword arguments
*AND* they can acquire names from the ZSQL methods and its
acquisition context.

  ...
  dtml-sqlvar and dtml-sqltest
  only look at a very limited local namespace, initialized with the
  REQUEST and passed arguments; but even this namespace may be modified,
  *INSIDE* the ZSQL method, with dtml-in and dtml-let.
I see, I should have been more specific.

ZSQL methods do not look at the DTML namespace of the *CALLING*
document template.

They use a document template (to generate the query)
which is evaluated in a (newly creatd) namespace.
Of cause, it looks at this DTML namespace in the usual
way. And all DTML tags are available to extend this namespace.

  However, 
  other tags behave quite normally -- which means that a lot of the
  problems can be bypassed by thoughtful use of dtml-var, especially
  using the sql_quote modifier (BTW, it is by virtue of this that you
  can call other methods -- even other ZSQL methods -- from within a
  ZSQL method).
There is no difference with respect to name lookup
between "dtml-var" and "dtml-sqlvar" or the other "dtml-sql*" tags.
They *ALL* work with the same namespace.

  2) Changing REQUEST does *not* update the local namespace, that is,
  within a ZSQL method,
That is right.
The reason is that "REQUEST" is not part of the newly
generated namespace in which the ZSQL template is evaluated.
"REQUEST" is acquired.

  dtml-call "REQUEST.set('some_var', 17)"
  dtml-var some_var
  
  doesn't work; but
  
  dtml-var "REQUEST['some_var']"
  
  Does.



Dieter

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] convert a String ...

2001-01-14 Thread Dieter Maurer

Marc Fischer writes:
  how is it possible to convert a string into my own zclass type?
  I get a String from a form and want to do some operation like
  string.manage_addFile(... on it. So what to do ??? Perhaps some out there is
  able to help ...
"_.getitem(string)" converts a string into an object.

Probably, you will not get a "zclass type".
But such a type would probably not have a "manage_addFile" method
anyway.

Do you mean "Z Instance" rather than "zclass type"?


Dieter

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] ZClasses meet PythonScripts, sample request

2001-01-14 Thread Timothy Wilson

On Sun, 14 Jan 2001, Jim Washington wrote:

 I am not working through that example, but the below is a start on what
 you seem to need. Let me know what you think.

Thanks Jim. I will study the examples you provided. Do you suppose that the
Zope Book would benefit from some examples of this type?

-Tim

--
Tim Wilson  | Visit Sibley online: | Check out:
Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/
W. St. Paul, MN |  | http://slashdot.org/
[EMAIL PROTECTED] |   dtml-var pithy_quote | http://linux.com/


___
Zope maillist  -  [EMAIL PROTECTED]
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] RE: ZMySQLDA, Problems Connecting

2001-01-14 Thread Steve McMahon

 ...when I attempt to add a Z MySQL Database Connection to a folder, I get 
"Invalid connection string" -- no matter what the connection string

Problem solved. It turned out there was a line of commented-out diagnostics 
on the page that reported "Invalid connection string." That let me know the 
problem was an inability to connect through the socket. Checking that, I 
discovered that the RedHat default install has 0700 permissions for the 
directory containing the MySQL socket. Changing that to 0711 cleared up my 
problems.
_
Steve McMahon, SunType Publishing Systems
[EMAIL PROTECTED]
voice  fax: (530) 757-7682
http://www.suntype.com


___
Zope maillist  -  [EMAIL PROTECTED]
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] More than one condition indtml-if

2001-01-14 Thread Angietel




The following is my DTML code, purposely to valid 
the entry field and return the right sql method according to the 
situation:-

dtml-if "_['dtml-var custname']!=""" 
AND "_['dtml-var custid']==""" 

 dtml-in 
sqlSearchcust3#// if the custid is blank and 
custnameis not blank then will use 
sqlSearch3
 dtml-elif "_['dtml-var 
custid']!=""" AND "_['dtml-var custname']=="""

 dtml-in 
sqlSearchcust2
#// if the custid is not blank and 
custname is blank then will use sqlSearch2

dtml-elif "_['dtml-var custid']==""" 
AND "_['dtml-var 
custname']==""" 
 
 dtml-in 
sqlSearchcust#// if the 
custname is not blank and custid is not blank then will use 
sqlSearch
dtml-else

 dtml-var 
expr="REQUEST['/Customer/View/searchallcust']" 
#// if the 
custname isblank and custid isblank then willgo to view a list 
of customer record.
/dtml-if

The following is the ZOPE error:-
Unexpected tag, for tag dtml-elif 
"_['dtml-var custid']==""" AND "_['dtml-var custname']!=""", 
on line 9 of a


For my sql method syntax are as 
follow:-

1.sqlSearchcust3

 select *from 
customerdtml-sqlgroup where dtml-sqltest custid 
op=ne type=stringdtml-anddtml-sqltest custname 
op=like'%%' type=string/dtml-sqlgroup

2. sqlSearchcust2

select *from customerdtml-sqlgroup 
where dtml-sqltest custid op=eq 
type=stringdtml-anddtml-sqltest custname op=ne 
type=string/dtml-sqlgroup
3. sqlSearchcust

select *from customerdtml-sqlgroup 
where dtml-sqltest custid op=eq 
type=stringdtml-anddtml-sqltest custname 
op=like'%%' type=string/dtml-sqlgroup

This is urgent! Please give me some solution, 
Thanks!


Re: [Zope] ZClasses meet PythonScripts, sample request

2001-01-14 Thread Timothy Wilson

On Sun, 14 Jan 2001, Jim Washington wrote:

 You probably want the work to be done in the context of an instance of
 the class, so assure you have "context" bound to the Python Script on
 the "bindings" tab.  It's bound by default.
 
 You might want to name the Script in a Zopish way to distinguish it from
 other scripts that may do other things.  I would probably call it
 manage_changeCDProperties.
 
 You will want to pass REQUEST to it so you can use it like the Zope
 builtins:
 
 containerName.CDInfoName.manage_changeCDProperties(REQUEST)
 
 So, put REQUEST in the parameters list.

I'm afraid I'm a bit confused here. Is 'CDInfoName' the id of an instance of
this CD class? If so, what would 'containerName' be?

In the particular example I'm thinking about (not a CD collection), I've
created a form that displays the current properties of the class (a job
opening for the H.R. deparment in my case), allows the user to modify any of
the properties in the form, and submit those changes. I suppose for the CD
example it would something like: (ignoring everything but the form)

form action="manage_changeCDProperties(REQUEST)"
table border="0"

trthTitle/th
  tdinput type="text" name="title" value="dtml-var title"/td
/tr

trthArtist/th
  tdinput type="text" name="artist" value="dtml-var artist"/td
/tr

trtd
input type="submit" value=" Submit Edits "
/td/tr
/table
/form

I don't think I'm calling the PythonScript correctly. In fact, I suspect I'm
quite a bit off.

 Inside the script, you would use Zope's manage_changeProperties method:
 
 context.propertysheets['cd_info'].manage_changeProperties(REQUEST)
 -or-
 context.propertysheets.cd_info.manage_changeProperties(REQUEST)

Following Evan's advice, would this then be:

container.propertysheets['cd_info'].manage_changeProperties(REQUEST)

So that's a one-liner? Hmmm. Cool if true. :-)

Let's say that I wanted to redirect the user back to the Web page where they
had begun this process. How would that be accomplished?

-Tim

 Timothy Wilson wrote:
  
  Hi everyone,
  
  I'm looking forward to using some PythonScripts as methods of some ZClasses
  because it seems like a much cleaner way to do things. I wonder if one of
  the PythonScript gurus out there would be willing to show an example of two
  presumably common PythonScript/ZClass tasks: processing changes to a
  property sheet using form input and deleting a ZClass instance.
  
  Let's say we've got a ZClass for keeping track of a CD collection. (I recall
  seeing that example in a ZClass How-To.) Let's say the ZClass has a property
  sheet called 'cd_info' with the following properties:
  
  title (string)
  artist (string)
  date_purchased (date)
  
  (for extra credit, add a 'songs' property of type 'lines' :-)
  
  Is that enough info? Anybody want to take a crack at this? (This would
  surely be good info to put at zope.org somewhere.)
  
  -Tim

--
Tim Wilson  | Visit Sibley online: | Check out:
Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/
W. St. Paul, MN |  | http://slashdot.org/
[EMAIL PROTECTED] |   dtml-var pithy_quote | http://linux.com/


___
Zope maillist  -  [EMAIL PROTECTED]
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] Searching method due to situation

2001-01-14 Thread Angietel





The following is my DTML code, purposely to valid 
the entry field and return the right sql Searching method according to the 
situation:-

dtml-if "_['dtml-var custname']!=""" 
AND "_['dtml-var custid']==""" 

 dtml-in 
sqlSearchcust3#// if the custid is blank and 
custnameis not blank then will use 
sqlSearch3
 dtml-elif "_['dtml-var 
custid']!=""" AND "_['dtml-var custname']=="""

 dtml-in 
sqlSearchcust2
#// if the custid is not blank and 
custname is blank then will use sqlSearch2

dtml-elif "_['dtml-var custid']==""" 
AND "_['dtml-var 
custname']==""" 
 
 dtml-in 
sqlSearchcust#// if the 
custname is not blank and custid is not blank then will use 
sqlSearch
dtml-else

 dtml-var 
expr="REQUEST['/Customer/View/searchallcust']" 
#// if the 
custname isblank and custid isblank then willgo to view a list 
of customer record.
/dtml-if

The following is the ZOPE error:-
Unexpected tag, for tag dtml-elif 
"_['dtml-var custid']==""" AND "_['dtml-var custname']!=""", 
on line 9 of a


For my sql method syntax are as 
follow:-

1.sqlSearchcust3

 select *from 
customerdtml-sqlgroup where dtml-sqltest custid 
op=ne type=stringdtml-anddtml-sqltest custname 
op=like'%%' type=string/dtml-sqlgroup

2. sqlSearchcust2

select *from customerdtml-sqlgroup 
where dtml-sqltest custid op=eq 
type=stringdtml-anddtml-sqltest custname op=ne 
type=string/dtml-sqlgroup
3. sqlSearchcust

select *from customerdtml-sqlgroup 
where dtml-sqltest custid op=eq 
type=stringdtml-anddtml-sqltest custname 
op=like'%%' type=string/dtml-sqlgroup

This is urgent! Please give me some solution, 
Thanks!


Re: [Zope] ZClasses meet PythonScripts, sample request

2001-01-14 Thread Jim Washington

Hi, Tim

 
  You will want to pass REQUEST to it so you can use it like the Zope
  builtins:
 
  containerName.CDInfoName.manage_changeCDProperties(REQUEST)
 
  So, put REQUEST in the parameters list.
 
 I'm afraid I'm a bit confused here. Is 'CDInfoName' the id of an instance of
 this CD class? If so, what would 'containerName' be?

Yes.  CDInfoName here would be an instance of your CD Class. 
containerName is the name of the container, whether it be a folder or a
folderish ZClass made for handling a collection of CD Class objects.  It
doesn't have to be there in the statement unless something else is
asking the folderish object to ask the CD Class object to change the
properties, which at the moment seems kind of silly.  I must have gotten
off on containers with your second question about deletion. Apologies
for the confusion.
 
 In the particular example I'm thinking about (not a CD collection), I've
 created a form that displays the current properties of the class (a job
 opening for the H.R. deparment in my case), allows the user to modify any of
 the properties in the form, and submit those changes. I suppose for the CD
 example it would something like: (ignoring everything but the form)
 
 form action="manage_changeCDProperties(REQUEST)"
 table border="0"
 
 trthTitle/th
   tdinput type="text" name="title" value="dtml-var title"/td
 /tr
 
 trthArtist/th
   tdinput type="text" name="artist" value="dtml-var artist"/td
 /tr
 
 trtd
 input type="submit" value=" Submit Edits "
 /td/tr
 /table
 /form
 
 I don't think I'm calling the PythonScript correctly. In fact, I suspect I'm
 quite a bit off.

I think it would work, at least as far as updating the properties, but
it would not  return anything. See below my attempt at an alternative.

  Inside the script, you would use Zope's manage_changeProperties method:
 
  context.propertysheets['cd_info'].manage_changeProperties(REQUEST)
  -or-
  context.propertysheets.cd_info.manage_changeProperties(REQUEST)
 
 Following Evan's advice, would this then be:
 
 container.propertysheets['cd_info'].manage_changeProperties(REQUEST)
 
 So that's a one-liner? Hmmm. Cool if true. :-)

Always has been, even in DTML. 
 
 Let's say that I wanted to redirect the user back to the Web page where they
 had begun this process. How would that be accomplished?

There are many ways.  I like to make it all happen at the beginning of
the DTML Method.
Hacking up the form you provided above (lines with ! have been added or
changed):

!dtml-var standard_html_header

!dtml-if "REQUEST.form.has_key('editCD')"
!  dtml-call "manage_changeCDProperties(REQUEST)"
!  pfont color="red"Your changes have been saved/font/p
!/dtml-if

!form action="replace_this_with_id_of_this_method"
 table border="0"
 
 trthTitle/th
  tdinput type="text" name="title" value="dtml-var title"/td
 /tr
 
 trthArtist/th
   tdinput type="text" name="artist" value="dtml-var artist"/td
 /tr
 
 trtd
! input type="submit" name="editCD" value=" Submit Edits "
 /td/tr
 /table
 /form
!dtml-var standard_html_footer

Hoping I have not confused further,

-- Jim Washington

  Timothy Wilson wrote:
  
   Hi everyone,
  
   I'm looking forward to using some PythonScripts as methods of some ZClasses
   because it seems like a much cleaner way to do things. I wonder if one of
   the PythonScript gurus out there would be willing to show an example of two
   presumably common PythonScript/ZClass tasks: processing changes to a
   property sheet using form input and deleting a ZClass instance.
  
   Let's say we've got a ZClass for keeping track of a CD collection. (I recall
   seeing that example in a ZClass How-To.) Let's say the ZClass has a property
   sheet called 'cd_info' with the following properties:
  
   title (string)
   artist (string)
   date_purchased (date)
  
   (for extra credit, add a 'songs' property of type 'lines' :-)
  
   Is that enough info? Anybody want to take a crack at this? (This would
   surely be good info to put at zope.org somewhere.)
  
   -Tim

___
Zope maillist  -  [EMAIL PROTECTED]
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] Apache ProxyPass directive and REMOTE_ ENV

2001-01-14 Thread Denis

Hi,

I'm confronted to the same problem as the one as discussed
at that address :
http://www.egroups.com/message/zope/43874?threaded=1

I'm trying to get back the REMOTE_ADDR variable because it's
changed to the Server's address by a ProxyPass directive.

I'm trying to use SetEnv or SetEnvIf directives to do that.
But I can't manage to expand %{REMOTE_ADDR} to an IP address.
I mean, if I use :
  SetEnv client_ip_1 %h
  SetEnv client_ip_2 %{Remote_Addr}
  SetEnv client_ip_3 %{ENV:Remote_Addr}
I get :
  client_ip_1 = %h
and not :
  client_ip_1 = 212.68.75.6
and the same for all my tries.

Is there a way to expand those values ? A magic key to turn ?

Have you found a better solution than the one exposed by HTH
in the message above ?

Thank you.
-- 
Denis FRERE
P3B: Club Free-Pytho-Linuxien Caroloregien http://www.p3b.org

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] ZClasses meet PythonScripts, sample request

2001-01-14 Thread Timothy Wilson

This seems to almost work. :-)

On Sun, 14 Jan 2001, Jim Washington wrote:

 !dtml-var standard_html_header
 
 !dtml-if "REQUEST.form.has_key('editCD')"
 !  dtml-call "manage_changeCDProperties(REQUEST)"
 !  pfont color="red"Your changes have been saved/font/p
 !/dtml-if
 
 !form action="replace_this_with_id_of_this_method"
  table border="0"
  
  trthTitle/th
   tdinput type="text" name="title" value="dtml-var title"/td
  /tr
  
  trthArtist/th
tdinput type="text" name="artist" value="dtml-var artist"/td
  /tr
  
  trtd
 ! input type="submit" name="editCD" value=" Submit Edits "
  /td/tr
  /table
  /form
 !dtml-var standard_html_footer

That's quite clever. I wouldn't have thought of doing it that way.

After translating the CD example to my own ZClass, I get the following error
after hitting "Submit Edits" on the edit form:

h2Zope Error/h2
pZope has encountered an error while publishing this resource.
  /p
pstrongResource not found/strong/p
Sorry, the requested Zope resource does not exist.pCheck the URL and try
again.p
!--
http://www.isd197.k12.mn.us/hr/jobs/postings/1234/editJobAction%28REQUEST%29
--

and the traceback:

Traceback (innermost last):
  File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 222, in
publish_module
  File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 187, in
publish
  File /var/lib/zope/2.3.0a2/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
(Object: Traversable)
  File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 162, in
publish
  File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/BaseRequest.py, line 369,
in traverse
  File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/HTTPResponse.py, line
528, in notFoundError
NotFound: (see above)

It looks like REQUEST isn't getting passed correctly. I've got REQUEST
listed as a parameter for my PythonScript. I don't need to mess with
bindings do I?

-Tim

--
Tim Wilson  | Visit Sibley online: | Check out:
Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/
W. St. Paul, MN |  | http://slashdot.org/
[EMAIL PROTECTED] |   dtml-var pithy_quote | http://linux.com/


___
Zope maillist  -  [EMAIL PROTECTED]
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] Calling other frames

2001-01-14 Thread Etienne Labuschagne

Hi there

I have a navigation/sitemap object that shows the user where he is in the
website at the current moment.  I want this object eg. to sit in the left
frame.  This object must update every time the main (right) frame updates to
reflect the position of the right frame.  The website can be navigated both
from this navigation/sitemap object or from links inside the website itself.
Thus, the object must also update itself even if it is not used as the means
to navigate the site.

How do I "talk" to objects in other frames? Or is there a better way to do
this? 

I know that this can probably be done with Javascript, but would prefer to
use Zope as far as I can.

Thanks!
Etienne

Tel: (012) 348 4586
Cel: 082 442 8981
Fax: (012) 361 8355


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] Calling other frames

2001-01-14 Thread Dirksen

Hi Etienne,

First of all, I don't think you can achieve that with javascript. As far as I know,
neither IE nor Netscape allows javascript to access DOM objects of other frame page for
security reasons.

Therefore, to do it at backend is a good solution. Session is the thing you want.
Unfortunately, zope doesn't have session management built in, but you can find a bunch 
of
session management products in zope's download page.

cheers
Dirksen

--- Etienne  Labuschagne [EMAIL PROTECTED] wrote:
 Hi there
 
 I have a navigation/sitemap object that shows the user where he is in the
 website at the current moment.  I want this object eg. to sit in the left
 frame.  This object must update every time the main (right) frame updates to
 reflect the position of the right frame.  The website can be navigated both
 from this navigation/sitemap object or from links inside the website itself.
 Thus, the object must also update itself even if it is not used as the means
 to navigate the site.
 
 How do I "talk" to objects in other frames? Or is there a better way to do
 this? 
 
 I know that this can probably be done with Javascript, but would prefer to
 use Zope as far as I can.
 
 Thanks!
 Etienne
 
 Tel: (012) 348 4586
 Cel: 082 442 8981
 Fax: (012) 361 8355
 
 
 ___
 Zope maillist  -  [EMAIL PROTECTED]
 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 )
 


__
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

___
Zope maillist  -  [EMAIL PROTECTED]
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 )