[Zope-dev] Request for amplification on new Product permissions API.

2000-07-06 Thread R. David Murray

OK, I read Brian's excellent HowTo on the 2.2 Product permissions API,
but it unfortunately doesn't give me the answer to my current
2.2 problem (or if it does there's something else I don't know that
is preventing me from figuring it out).

I'm trying to update EMarket to work under 2.2.  EMarket has a
shopper object.  A shopper's current set of potential purchases
is stored on the shopper object in a 'basket' attribute.  What
gets assigned to this attribute is an instance of a 'Basket' class.
It inherits from Persistent and Acquisition.implicit.  (Shopper,
among other things, inherits from OFS.SimpleItem, by the way.)

So, when I access the page that displays the current shopping cart,
under 2.2 I get an unauthorized error when the dtml code
attemps to access an attribute of the basket object.

So, what do I need to do to allow controlled access to this object?
I understand that Shopper, inheriting from SimpleItem, already has
the access to unprotected subobjects flag.  And I'd rather protect
the object correctly, anyway .  I tried adding an ac_permissions
structure to the class, giving View permission to the attribute
that is throwing the unauthorized error, but that doesn't seem to
have changed the behavior.  Adding the access to subobjects flag
also didn't do anything.  I created a new shopper/basket just in
case the changes don't affect existing objects, but still got the
same unauthorized error.

--RDM


___
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] why does an error in my externalmethod ...

2000-07-06 Thread Dieter Maurer

Joachim Schmitz writes:
 > 
 > make the folder from which it was invoked inaccessable ?
 > 
 > continuing work on my external, I removed all modifications of self, so no
 > transactions or better modifications of the ZODB took place. During the
 > development cycle: editing the external methods, testing it through
 > calling it through the browser, after editing the method the call of
 > /Movies/testForm resulted in a not found error.
 > also I cannot enter the folder "Movies", if I click on it in the
 > managementscreen, I also get the not found error. There is no transaction
 > to undo, I restarted Zope no luck, I tried to delete the folder and get
 > the error:
 > 
 > Error Type: SystemError
 > Error Value: Failed to import class setrecord from module __main__

 > 

 > The class setrecord is in my external-method. I luckily had packed zodb
 > shortly before that, and it is just a testserver. So I copied the
 > Data.fs.old to Data.fs. Till now I could not reproduce the error. I still
 > have the corrupted Data.fs. 

You should be very careful, not to store instances of
classes defined in external method files in the ZODB.

The reason:
  These Python files are not imported in a standard way,
  but instead they are read and executed.

  Therefore, the unpickler is not able to find the
  classes module, you get the problem you reported.


When you need to store class instances in the ZODB,
you should define these classes in a standard
package. The "Shared" packages is designed for this
purpose. Create an appropiately named subpackage (e.g.
company name) and put your modules there.


In your case, you may have written to a persistent object
unintentionally.


Dieter

___
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] why does an error in my externalmethod ...

2000-07-06 Thread Joachim Schmitz


make the folder from which it was invoked inaccessable ?

continuing work on my external, I removed all modifications of self, so no
transactions or better modifications of the ZODB took place. During the
development cycle: editing the external methods, testing it through
calling it through the browser, after editing the method the call of
.../Movies/testForm resulted in a not found error.
also I cannot enter the folder "Movies", if I click on it in the
managementscreen, I also get the not found error. There is no transaction
to undo, I restarted Zope no luck, I tried to delete the folder and get
the error:

Error Type: SystemError
Error Value: Failed to import class setrecord from module __main__

(Object: manage_delObjects)
File /usr/local/Zope-2.1.4/lib/python/ZPublisher/Publish.py, line 102, in
call_object
(Object: manage_delObjects)
File /usr/local/Zope-2.1.4/lib/python/OFS/ObjectManager.py, line 395, in
manage_delObjects
(Object: ElementWithAttributes)
File /usr/local/Zope-2.1.4/lib/python/OFS/ObjectManager.py, line 267, in
_delObject
(Object: ElementWithAttributes)
File /usr/local/Zope-2.1.4/lib/python/ZODB/Connection.py, line 396, in 
setstate
SystemError: (see above)
 
The class setrecord is in my external-method. I luckily had packed zodb
shortly before that, and it is just a testserver. So I copied the
Data.fs.old to Data.fs. Till now I could not reproduce the error. I still
have the corrupted Data.fs. 

But I had that occure before, after making an error in the external
method, the calling folder was not accessible anymore. But there I also
had modified self, so I had a transaction which I could "undo".  


Mit freundlichen Grüßen

Joachim Schmitz  

  
AixtraWare, Ing. Büro für Internetanwendungen
Hüsgenstr. 33a, D-52457 Aldenhoven  
Telefon: +49-2464-8851, FAX: +49-2464-905163



___
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: [Python-Dev] ExtensionClass and __radd__()?

2000-07-06 Thread Jim Fulton

Greg Ward wrote:
> 
> Hi all --
> 
> looks like ExtensionClass doesn't recognize/implement the '__radd__()'
> protocol.  Speculation below; first, a demonstration.  Normal case: a
> regular class Number that knows how to add itself to other number-like
> things:

(demonstration snipped)

> Speculation time: I'm guessing that this is similar to the problem with
> 'isinstance()' and ExtensionClass that I found several months ago, which
> was heroically debugged by Barry.  To recap, it's a mutual
> finger-pointing bug: Python (Guido) can claim that it's up to
> ExtensionClass (Jim) to emulate the full semantics of Python
> classes/instances, but ExtensionClass can claim that Python should be
> more relaxed in what it accepts as a "class object" or "instance
> object".
> 
> I think the relevant code in Python is in Objects/abstract.c,
> specifically 'PyNumber_Add()' and the BINOP macro:
> 
> #define BINOP(v, w, opname, ropname, thisfunc) \
> if (PyInstance_Check(v) || PyInstance_Check(w)) \
> return PyInstance_DoBinOp(v, w, opname, ropname, thisfunc)
> 
> [...]
> PyNumber_Add(v, w)
> PyObject *v, *w;
> {
> PySequenceMethods *m;
> 
> BINOP(v, w, "__add__", "__radd__", PyNumber_Add);
> [...]
> 
> My guess is that PyInstance_Check() returns false for ExtensionClass
> instances.  Two possible fixes: loosen up PyInstance_Check(), or loosen
> up BINOP.
> 
> Well, it's a nice theory.  It doesn't explain why '__add__()' works for
> ExtensionClass while '__radd__()' does not; perhaps ExtensionClass
> implements that much of Python's class semantics, but doesn't go as far
> as '__radd__()'.

I'd love to see __radd__ added. ;) I don't remember why it's not there.
Maybe I was just lazy.  It may be fairly hard to add. I haven't looked
in quite a while. As anyone whos looked at ExtensionClass sources may
be able to tell, ExtensionClass has to play quite a few tricks to:

- Try to sanely bridge the quite different semantics of Python
  "types" and "classes" (e.g. there's no radd for "types").

- Try to overcome the fact that the interpreter special-cases 
  InstanceType and ClassType pretty liberally. To (try to and
  mostly succeed to) provide instance semantics I have to do 
  alot of weird indirection. This is especially hard for 
  numeric things.

  Your analysis of the code demonstrates this issue. ExtensionClass
  instances are not of type InstanceType. In fact, each ExtensionClass
  is a separate type and instances of different ExtensionClasses have
  different types.

  Note that I just got around to responding to your earlier 
  post "Comparison inconsistency with ExtensionClass".
  This has a similar root cause: the special-case treatment
  of InstanceType.

I think that the *real* solution to this problem is to get rid
of ExtensionClass. ;) To do this, I need to get the features
I have in ExtensionClass into Python. I guess there's some hope
for that in Python 3K (love that name :).

In the mean time, I don't have time to fix the radd problem
myself, but would be willing to advise someone who wanted
to try to take it on, especially if we could work out some
phone or face-to-face sessions.

Jim

--
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
Technical Director   (888) 344-4332http://www.python.org  
Digital Creationshttp://www.digicool.com   http://www.zope.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.

___
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] why does my externalmethod generate a ZODB transaction

2000-07-06 Thread Martijn Pieters

On Thu, Jul 06, 2000 at 09:29:53AM +0200, Joachim Schmitz wrote:
> answering to myself, cause nobody else could find the reason in the code I
> provided, because I didn't include the real culprit. Here is the very much
> abreviatet version, which also generates a transaction:
> 
> def workform(self,REQUEST):
> "Die Masken EinAusgabe"
> self.form=REQUEST.form<-- this does it
> return "this generated a transaction"
> 
> So don't modify the "self" of an external method.

self is the object this method is called on. So if this is method 'foo' in
Folder 'bar', called with http://www.spamandeggs.com/bar/foo, self is bar. The
EM is a method of the container object.

Indeed, setting self.form will store REQUEST.form in that object attribute,
causing Zope to commit a new version of the object. After all, you made a
change to it!

-- 
Martijn Pieters
| Software Engineermailto:[EMAIL PROTECTED]
| Digital Creations  http://www.digicool.com/
| Creators of Zope   http://www.zope.org/
| ZopeStudio: http://www.zope.org/Products/ZopeStudio
-

___
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] ExtensionClass and __radd__()?

2000-07-06 Thread Greg Ward

On 06 July 2000, Pavlos Christoforou said:
> A quick note which you probably already know:
> 
> grep add ExtensionClass.c gives:
[...lots...]
> whereas grep radd ExtensionClass.c returns nothing

Yep, did the same myself shortly after posting.  It's not really clear
what 'py__add__' is and how it works, though, so it's not obvious if
'py__radd__' is the right thing to add, and if so how to add it.

Greg


If it's just a matter
of adding radd (and rsub, rmul, and rdiv) in all those places
-- 
Greg Ward - software developer[EMAIL PROTECTED]
MEMS Exchange / CNRI   voice: +1-703-262-5376
Reston, Virginia, USAfax: +1-703-262-5367

___
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] why does my externalmethod generate a ZODB transaction

2000-07-06 Thread Chris McDonough

Any method called directly through the web (e.g. like this one, which I
assume is through an HTTP POST) will be bounded in a transaction.  Why
would you not want this to happen?

> -Original Message-
> From: Joachim Schmitz [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 06, 2000 3:30 AM
> To: zope-dev
> Subject: Re: [Zope-dev] why does my externalmethod generate a ZODB
> transaction
> 
> 
> Hi,
> 
> answering to myself, cause nobody else could find the reason 
> in the code I
> provided, because I didn't include the real culprit. Here is 
> the very much
> abreviatet version, which also generates a transaction:
> 
> def workform(self,REQUEST):
> "Die Masken EinAusgabe"
> self.form=REQUEST.form<-- this does it
> return "this generated a transaction"
> 
> So don't modify the "self" of an external method.
> 
> 
> Mit freundlichen Grüßen
> 
> Joachim Schmitz  
> 
>   
> AixtraWare, Ing. Büro für Internetanwendungen
> Hüsgenstr. 33a, D-52457 Aldenhoven  
> Telefon: +49-2464-8851, FAX: +49-2464-905163
> 
> 
> 
> ___
> 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 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] SQL-Output

2000-07-06 Thread Andre Schubert

Hi,

i have a little problem on outputting data from an SQL-Query. The
Problem is, that the user should select his own Fieldnames
he want to show for output. The input form sends a request to the output
form, with  a query-string and some other stuff and a key named ausgabe.

The key ausgabe is a sequence with all Fielnames the user clicked. Now
in the outputform i have a sequence looking for the search-query. If
sequence starts it prints a table-head with all selected field-names out
of the second sequence ausgabe. The problem is: my table in the
relational database has a column named 'Name'. If i write in the
sequence at bottom  then the result is the the value of
Namne is printed. But if i write  and the
current item is Name then Name is printed out and not the Value of Name
from the DB.
Could anybody help me.

as

P.S.: sorry for my bad english




   

 

  Name
  
    
  



   


  
 
   
 


   

  

   







___
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] ExtensionClass and __radd__()?

2000-07-06 Thread Pavlos Christoforou

On Wed, 5 Jul 2000, Greg Ward wrote:

> 
> Well, it's a nice theory.  It doesn't explain why '__add__()' works for
> ExtensionClass while '__radd__()' does not; perhaps ExtensionClass
> implements that much of Python's class semantics, but doesn't go as far
> as '__radd__()'.
> 

A quick note which you probably already know:

grep add ExtensionClass.c gives:

static PyObject *py__add__, *py__sub__, *py__mul__, *py__div__,
  INIT_PY_NAME(__add__); BINOP(add,Add)
  FILLENTRY(nm->nb, add, add, METH_VARARGS, "Add to another");
  FILLENTRY(sm->sq, concat, add, METH_VARARGS,
  SET_SPECIAL(add,add); subclass_add(PyObject *self, PyObject *v)
  UNLESS(m=subclass_getspecial(self,py__add__)) return NULL;
  && AsCMethod(m)->meth==(PyCFunction)add_by_name
ASSIGN(m,AsCMethod(m)->type->tp_as_number->nb_add(self,v));
  (binaryfunc)subclass_add, /*nb_add*/
(binaryfunc)subclass_add, /*sq_concat*/
  return; /* we added a reference; don't delete now */ 

whereas grep radd ExtensionClass.c returns nothing


Pavlos


___
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] Product Data Storage

2000-07-06 Thread Andy Dawkins

>If you can at all avoid it, I think you should find a way to store it in
>the ZODB.

Ultimatley thats what I am aiming for

>Maybe a Configuration product that would allow you to create arbitrary
>configuration information and still be able to access it without making
>filesystem calls. Think about DC's Zope on a CD demo. Not that you really
>need to do that sort of thing, but it's really not going to work if you
>have to write stuff to the filesystem.

A Configuration product isn't a bad idea, although it still leaves the
question of where do you put it, in the root? in a configuration directory?
in the Product folder?

>Actually, an XML Docment somewhere at root level should give you the kind
>of flexibility you're looking for. Lot's of people are using XML files
>for conf these days (they're all jumping... don't you want to...)

I am not too keen on writing confurations or preferences documents on the
root.  My reasoning is that the root is not the correct place for that kind
of thing, you don't see any linux confurations in / its all filed away
nicely in respective folders.

>That being said, I totally agree that if you need to store something in a
>file, put it in Zope/var. I, for one, have my Zope application code on
>partition along with other apps, and the data, like Data.fs on another. I
>typically don't expect the apps partition to grow very much, or very
>often, In fact, only when I install something. So it would be quite
>shocking to have that space filling unexpectedly.

This is how it is going to work for now.  I have taken Dan Piersons advice
for this one.

Thanks for your comments.

-Andy


___
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] why does my externalmethod generate a ZODB transaction

2000-07-06 Thread Joachim Schmitz

Hi,

answering to myself, cause nobody else could find the reason in the code I
provided, because I didn't include the real culprit. Here is the very much
abreviatet version, which also generates a transaction:

def workform(self,REQUEST):
"Die Masken EinAusgabe"
self.form=REQUEST.form<-- this does it
return "this generated a transaction"

So don't modify the "self" of an external method.


Mit freundlichen Grüßen

Joachim Schmitz  

  
AixtraWare, Ing. Büro für Internetanwendungen
Hüsgenstr. 33a, D-52457 Aldenhoven  
Telefon: +49-2464-8851, FAX: +49-2464-905163



___
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 )