Re: [Zope] Adding users

2000-12-06 Thread Randall Kern



Something like this should work:

dtml-with acl_users
 dtml-call 
expr="manage_users(submit = 'Add')"
/dtml-with

It will look in the REQUEST for the following 
fields:
 name
 password
 confirm (this must match 
password)
 roles
 domains

So either set these from an HTML form, or use 
dtml-call expr="REQUEST.set('name', 'Joe')". For examples of the 
form technique, look at zope/lib/python/AccessControl/addUser.dtml

-Randy

  - Original Message - 
  From: 
  Mike 
  Kelland 
  To: [EMAIL PROTECTED] 
  Sent: Wednesday, December 06, 2000 8:47 
  PM
  Subject: [Zope] Adding users
  
  Is it possible to have a form in a zope page that 
  allows you to add a new user to the acl_users folder? I can get the data 
  I need, I just need to know, if I have the user name and password as dtml 
  variables, and the user adding the other user has all the appropriate 
  permissions, is there a way in dtml to use this information to add a user 
  (with a defined role).
  
  Thanks very much for this and prior 
  help!
  
  Mike Kelland
  [EMAIL PROTECTED] 



Re: [Zope] How to specify to z sql methods, the connection object to use at runtime...time...

2000-12-05 Thread Randall Kern

I haven't actually tried this, but it seems it should work:

/
/db1- folder
connection- a DB connection object to db 1
/db2- folder
connection- a DB connection object to db 2
query- a ZSqlMethod, set to use the connection 'connection'.  Note,
you may have to add a temporary DB connection to the root, to allow you to
setup these methods.  After you have created your methods, remove the
/connection object.

Then use urls like http://your.server/db1/query to run the query using the
first database connection, and http://your.server/db2/query to run query
using the second database connection.

-Randy
- Original Message -
From: "Tino Wildenhain" [EMAIL PROTECTED]
To: "Frederic Quin" [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, December 05, 2000 4:56 AM
Subject: Re: [Zope] How to specify to z sql methods, the connection object
to use at runtime...time...


 Hi Frederic,

 Frederic Quin schrieb:
 
  Hi all,
 
  I have the same querry to execute on different servers. I don't want to
  create as many z sql methods as servers I have. I would like to specify
  to my z sql method, the connection object to use at run time. Do I have
  to patch the files of z sql methods ? Can I use directly the connection
  object ??
 A clean approach would be subclassing the zsql-method
 for your purpose. I would not recommend a free-form
 string as argument for the Datasource. May be an integer index
 (first, second, third... database server)
 or something like that?

 Regards
 Tino

 ___
 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] siblings of me, rather than of parent

2000-12-04 Thread Randall Kern



ahahhaha!!! (sorry, been up _way_ too 
long.)

the trick was returning ob.aq_base.__of__(self), 
not ob.aq_inner.__of__(self)!

Seems to work great now.
-Randy

  - Original Message - 
  From: 
  Randall Kern 
  
  To: [EMAIL PROTECTED] 
  Sent: Sunday, December 03, 2000 11:08 
  PM
  Subject: Re: [Zope] siblings of me, 
  rather than of parent
  
  Sorry, my __bobo_traverse__ method is working, 
  the PARENTS stack is exactly as I would hope, with my module as the parent of 
  the category, rather than the root.
  
  Here's the whole story:
  
  /
   index_html 
  (dtml method)
   index.html 
  (dtml method)
   category (Folder)
  foo.html 
  (dtml method)
   blah 
  (Module)
   
  category (Folder)
   
  header.html (dtml method)
   weather 
  (Category)
  
  /index_html:
   dtml-var 
  index.html
  
  /index.html:
   dtml-var 
  standard_html_header
  
   dtml-if expr="meta_type == 
  'Category'" !-- true in cases of url like 
  /blah/weather --

  dtml-call expr="REQUEST.set('splevel', category)"
   /dtml-if
  
   dtml-with splevel 
  mapping

  dtml-var header.html
   
/dtml-with
  
   dtml-var 
  standard_html_footer
  
  
  Now, what I hope to happen is that the dtml-with 
  would bind to the /blah/category folder, and therefore be able to find 
  header.html. However, somehow it's getting the /category folder instead, 
  which doesn't have header.html.
  
  Anyone understand why this is 
  happening?
  
  Thanks again,
  -Randy
  
- Original Message ----- 
    From: 
    Randall 
Kern 
To: [EMAIL PROTECTED] 
Sent: Sunday, December 03, 2000 8:08 
PM
Subject: [Zope] siblings of me, rather 
than of parent

My site has two main classes of objects, 
Modules (and their derivatives), and Categories. A normal setup might 
look something like this:

root
 blab 
(Module)
 weather 
(Category)
 rain 
(Category)
  sun 
(Category)
 region 
(Category)

I need to handle URLs like 
/root/blab/weather. The problem is that I need weather.__of__(blab) on 
the stack, rather than weather.__of__(root) on top. This is because 
blab (in some cases) overrides default behaviors from root.

I thought the proper way to do this was by 
adding a __bobo_traverse__ method to my Module, like this:

 def __bobo_traverse__(self, 
REQUEST, name): 
try: 
parents = 
REQUEST['PARENTS'] 
parent = 
parents[-2] 
if hasattr(parent, 
name): 
ob = getattr(parent, 
name) 
if ob.meta_type == 
'Category': 
return 
ob.aq_inner.__of__(self) 
except: 
pass

 
return getattr(self, name)

But that doesn't seem to change anything, 
although it does perform the return (and doesn't throw any 
exceptions.)

Basically, I'm trying to offer my siblings as 
if they were my children, so if they fail to offer something, it will be 
looked for in me, rather than my parent.

Thanks,
-Randy


Re: [Zope] weird bug?

2000-12-03 Thread Randall Kern


- Original Message -
From: "Dieter Maurer" [EMAIL PROTECTED]
 of the method. Moreover, proxy roles are no longer inherited
 to called methods.

This has confused me several times, could anyone shed some light as to why
proxy roles are not inherited?

Thanks,
-Randy


___
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] siblings of me, rather than of parent

2000-12-03 Thread Randall Kern



My site has two main classes of objects, Modules 
(and their derivatives), and Categories. A normal setup might look 
something like this:

root
 blab 
(Module)
 weather (Category)
 rain 
(Category)
  sun 
(Category)
 region (Category)

I need to handle URLs like 
/root/blab/weather. The problem is that I need weather.__of__(blab) on the 
stack, rather than weather.__of__(root) on top. This is because blab (in 
some cases) overrides default behaviors from root.

I thought the proper way to do this was by adding a 
__bobo_traverse__ method to my Module, like this:

 def __bobo_traverse__(self, REQUEST, 
name): 
try: 
parents = 
REQUEST['PARENTS'] 
parent = 
parents[-2] 
if hasattr(parent, 
name): 
ob = getattr(parent, 
name) 
if ob.meta_type == 
'Category': 
return ob.aq_inner.__of__(self) 
except: 
pass

 return 
getattr(self, name)

But that doesn't seem to change anything, although 
it does perform the return (and doesn't throw any exceptions.)

Basically, I'm trying to offer my siblings as if 
they were my children, so if they fail to offer something, it will be looked for 
in me, rather than my parent.

Thanks,
-Randy


Re: [Zope] siblings of me, rather than of parent

2000-12-03 Thread Randall Kern



Sorry, my __bobo_traverse__ method is working, the 
PARENTS stack is exactly as I would hope, with my module as the parent of the 
category, rather than the root.

Here's the whole story:

/
 index_html 
(dtml method)
 index.html 
(dtml method)
 category (Folder)
foo.html 
(dtml method)
 blah 
(Module)
 category 
(Folder)
 
header.html (dtml method)
 weather 
(Category)

/index_html:
 dtml-var 
index.html

/index.html:
 dtml-var 
standard_html_header

 dtml-if expr="meta_type == 
'Category'" !-- true in cases of url like 
/blah/weather --
  dtml-call 
expr="REQUEST.set('splevel', category)"
 /dtml-if

 dtml-with splevel 
mapping
  dtml-var 
header.html
 /dtml-with

 dtml-var 
standard_html_footer


Now, what I hope to happen is that the dtml-with 
would bind to the /blah/category folder, and therefore be able to find 
header.html. However, somehow it's getting the /category folder instead, 
which doesn't have header.html.

Anyone understand why this is 
happening?

Thanks again,
-Randy

  - Original Message - 
  From: 
  Randall Kern 
  
  To: [EMAIL PROTECTED] 
  Sent: Sunday, December 03, 2000 8:08 
  PM
  Subject: [Zope] siblings of me, rather 
  than of parent
  
  My site has two main classes of objects, Modules 
  (and their derivatives), and Categories. A normal setup might look 
  something like this:
  
  root
   blab 
  (Module)
   weather 
(Category)
   rain 
  (Category)
sun 
  (Category)
   region (Category)
  
  I need to handle URLs like 
  /root/blab/weather. The problem is that I need weather.__of__(blab) on 
  the stack, rather than weather.__of__(root) on top. This is because blab 
  (in some cases) overrides default behaviors from root.
  
  I thought the proper way to do this was by adding 
  a __bobo_traverse__ method to my Module, like this:
  
   def __bobo_traverse__(self, REQUEST, 
  name): 
  try: 
  parents = 
  REQUEST['PARENTS'] 
  parent = 
  parents[-2] 
  if hasattr(parent, 
  name): 
  ob = getattr(parent, 
  name) 
  if ob.meta_type == 
  'Category': 
  return ob.aq_inner.__of__(self) 
  except: 
  pass
  
   return 
  getattr(self, name)
  
  But that doesn't seem to change anything, 
  although it does perform the return (and doesn't throw any 
  exceptions.)
  
  Basically, I'm trying to offer my siblings as if 
  they were my children, so if they fail to offer something, it will be looked 
  for in me, rather than my parent.
  
  Thanks,
  -Randy


[Zope] adding roles to Zope in Product.initialize()

2000-11-29 Thread Randall Kern



I wish to restrict the creation of a class 
(SpokeSite) to people with the "Add Spoke Site" permission, and in turn only 
provide that permission to people in the 'Super-manager' Role.

When I call ProductContext.registerClass for my 
SpokeSite class, I can pass the permission argument with the tuple ('Add Spoke 
Site', 'Super-manager'), which does a good job of limiting the availability of 
my class (just as I desire).

However, I would like my Product to automatically 
create the 'Super-manager' Role, if it doesn't exists. The bad part is 
that this role needs to be added before any of my objects exist, which makes it 
hard...

I've got it *working* by cheating, and using the 
private __app attribute of the ProductContext. Is there a better way for 
python Products to alter the Zope installation (add Roles, create Folders, etc.) 
during installation?

Thanks!
-Randy


Re: [Zope] client argument to python function calls?

2000-11-27 Thread Randall Kern



Figured this out, with the zope-dev 
archives.

In case anyone else bumps into the same thing, 
the FunctionTemplate class at http://www.zope.org/Members/htrd/howto/FunctionTemplate 
is very helpful.
-Randy

  - Original Message - 
  From: 
  Randall Kern 
  
  To: [EMAIL PROTECTED] 
  Sent: Sunday, November 26, 2000 8:17 
  PM
  Subject: [Zope] client argument to python 
  function calls?
  
  I'm trying to emulate some DTML methods with 
  python code in my (python) product.
  
  Let's say I have two Python classes, one named 
  Foo, the other Bar. Something like this:
  
  class Foo(Folder.Folder, Persistent, 
  Implicit):
   meta_type = "Foo"
  
   def magic(self, 
  client=None):
   "magic 
  method!"
  
if client 
  == None:

   client = self
  
return 
  client.magic_word
  
  class Bar(Folder.Folder, Persistent, 
  Implicit):
   meta_type= 
  "Bar"
  
   def __init__(self, 
  id):
self.id = 
  id

  self.magic_word = 'Alacazam!"
  
  
  Now I create a structure like this in 
  Zope:
  
  /
   foo 
  (instance of the Foo class)
   bar 
  (instance of the Bar class)
  
  Now if I goto /bar/foo/magic, I see the magic 
  word. However, I would also like to use /foo/bar/magic, and also receive 
  the magic word. This latter case doesn't work, the magic_word isn't 
  set.
  
  In fact, the "client" argument is never anything 
  but None.
  
  This is a facet of Zope I still don't quite 
  understand...
  
  Thanks,
  -Randy


[Zope] client argument to python function calls?

2000-11-26 Thread Randall Kern



I'm trying to emulate some DTML methods with python 
code in my (python) product.

Let's say I have two Python classes, one named Foo, 
the other Bar. Something like this:

class Foo(Folder.Folder, Persistent, 
Implicit):
 meta_type = "Foo"

 def magic(self, 
client=None):
 "magic 
method!"

  if client == 
None:
  
 client = self

  return 
client.magic_word

class Bar(Folder.Folder, Persistent, 
Implicit):
 meta_type= 
"Bar"

 def __init__(self, 
id):
  self.id = 
id
  
self.magic_word = 'Alacazam!"


Now I create a structure like this in 
Zope:

/
 foo (instance 
of the Foo class)
 bar (instance 
of the Bar class)

Now if I goto /bar/foo/magic, I see the magic 
word. However, I would also like to use /foo/bar/magic, and also receive 
the magic word. This latter case doesn't work, the magic_word isn't 
set.

In fact, the "client" argument is never anything 
but None.

This is a facet of Zope I still don't quite 
understand...

Thanks,
-Randy


[Zope] ZClass/DTML Document transparency

2000-11-20 Thread Randall Kern



Hi all,

I have a folder (foo) which contains a set of DTML Documents, and instances 
of a ZClass.

From another DTML document, I enumerate the contents of this folder, using 
a DTML-IN tag:

dtml-in expr="bar.foo.objectValues()" sort="order"
...
/dtml-in

My problem is with ..., namely dealing with both 
DTML documents and ZClasses. In the case of 
DTML Documents, the following works fine:

dtml-var sequence-item

In the case of ZClasses, I have to use something 
like this:

dtml-with sequence-item
 dtml-var index_html
/dtml-with

So I'm using this:

dtml-if expr="_['sequence-var-meta_type'] == 
'DTML Document'" dtml-var 
sequence-itemdtml-else dtml-with 
sequence-item dtml-var index_html 
/dtml-with/dtml-if


But this is rather ugly, and it's the sort of thing 
one shouldn't have to do in an oo system.

So, is there a better way?
-Randy


Re: [Zope] Uploading files

2000-11-15 Thread Randall Kern

make sure you set the enctype correctly in your form tag:

form action="foo" method="post" enctype="multipart/form-data"

-Randy
- Original Message - 
From: "Nolan Darilek" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, November 15, 2000 5:07 PM
Subject: [Zope] Uploading files


 I'm trying to write a replacement form which allows users to upload
 images into a folder. I'm almost there, but not quite.
 
 I'm having difficulties getting the file contents into the database. I
 have an input type="file" field, and I'm fairly sure that the data
 is being sent. When I create the Image however, I use
 file=REQUEST['file'], and the resulting image stores the path to the
 file, instead of the file contents. So, given that I've uploaded a
 file, and that its name is in REQUEST['file'], how do I get at its
 contents when creating the Image?
 
 ___
 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] ZClasses on top of my Python classes?

2000-11-15 Thread Randall Kern



I've seen several doc tidbits suggesting one create 
ZClasses derived from their Python classes, sticking all the biz logic in the 
python classes, and the presentation in the ZClasses...

Could someone provide some insight into why this is 
better than simply writing separate python classes for logic and 
presentation? (Although I have to admit hitting the "Restart Server" 
button every time I make a typo is getting old)

Thanks!
-Randy


Re: [Zope] modifying objectValues from an external method?

2000-11-15 Thread Randall Kern

dtml-call expr="manage_delObjects(ids=objectIds())"

Place this in a DTML method, and it will remove all the sub-objects in the
folder you call it on.

Example:

Create a folder "Test".  In that folder, create a DTML method called
remove_all, and put the DTML from above in it.  Then create another Folder
inside Test called "Lossy".  Create some random stuff you don't mind losing
into this new folder.

Open your browser, and goto http://yourserverhere/Test/Lossy/remove_all

Go back to the manage interface, and notice that all that stuff you didn't
mind losing is gone.

-Randy
- Original Message -
From: "Bowyer, Alex" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, November 15, 2000 9:53 PM
Subject: [Zope] modifying objectValues from an external method?


 You may remember I have posted a couple of times about problems I have had
 with manage_delObjects to delete a news article object from a news page
 which contains several child news article objects.

 I thought I would try and avoid the problem and make a Python method to
 remove the item. This method takes the list of articles (i.e.
objectValues)
 and does the deletion on the parameter passed in.

 The problem I have is, objectValues doesn't seem to exist at Python level,
 only at DTML level. So instead of:

 dtml-call "my_delete_function(objectValues)"

 which is not valid, I have to use:

 dtml-let my_list=objectValues
   dtml-call "my_delete_function(my_list)"
 /dtml-let

 The problem with this is that even though the parameter is passed by
 reference, the changes are only being done to my_list and not passed back
to
 objectValues. So I lose them once my_list is out of scope.

 Can anyone suggest an alternative or a workaround? I thought about
returning
 the modified list from the function, but DTML provides no functionality to
 set objectValues equal to this result.

 Any help would be appreciated!

 Thanks

 Alex

 ==
 Alex Bowyer
 IT Contractor, Logica Australasia
 Tel: +61 2 9202 8130
 Fax: +61 2 9922 7466
 E-mail : [EMAIL PROTECTED]
 WWW: http://www.logica.com.au/
 ==

 ___
 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] Where to store my data?

2000-11-13 Thread Randall Kern



I've just started playing with Zope again, and this 
time I'm going to spend enough time with it to actually decide if it's crazy or 
I am :)

My project currently consists of a bunch of 
community "modules" written in PHP using MySQL as a data store. Each 
modules PHP code produces an XML page, by running a bunch of queries in the 
database, and performing some logic. These XML pages are then processed 
using XSLT, with a model very similar to Acquisition.

I'm getting very tired of the poor language design 
inherent in PHP, and wanted to start using Python again.

(Big reason for doing this work: In the 
current package, each module is only accessible from a hardcoded URL, such as 
/links for the Links module, etc. Many of my customers want to change the 
layout of their site, and in fact maybe have two Links modules, 
etc.)

So far, sounds like Zope would be a great system 
for me. It would give my customers a good platform to customize their 
sites, and give me a good platform to build my modules with.

Now, short of just doing it and then discovering 
what I did wrong, I'm hoping to get some advice from the Zope community on how 
to structure this system.

This is a fairly large system, I host about 10 
customers per box, serving about 4MM page views. 99% of the pages are 
dynamic, doing real-time database queries.

Some of my first questions:
-Is Zope a good choice for this kind of 
project?
-Which is better: Store my content (Forum 
posts, Links, etc) in ZODB, or a MySQL database?
-Build my Product (right term?) in DTML/ZClasses 
(seems easier for my users to customize?) or build it in Python?
-Can I (easily) build this system in 4 
layers:
 Content -- 
actual low-level storage, rarely customized
 Logic/Object 
Representation -- layer used to interact with the content, 
also rarely customized, although does have configuration options
 XML (page 
contents) -- every URL should result in an XML document, 
containing all the information that will be presented on that page. 
Written in DTML?
 XSLT (page 
rendering) -- the XML documents must be transformed into 
HTML/etc. These transformations, like the page contents should be 
inherited; excuse me, acquired.
-Simple things should be simple, Complex things 
should be possible. -- My users should be able to plop a Links module into their 
site, edit the Properties for that Object, and it works. If they want to 
change the way Links are categorized, they should be able to, although it'll 
take a while longer :)

Thanks for your Zen,
-Randy