Commit 8d721ad5 authored by Tres Seaver's avatar Tres Seaver

  - Removed spurious 'self' argument from scarecrow interfaces;  suppressed
    'self' in interface methods created from actual method objects.
parent 24194aba
......@@ -53,6 +53,10 @@ Zope Changes
Bugs:
- Removed spurious 'self' from scarecrow interfaces; updated
method-generation in Interface package to ignore self when
source is a method (rather than a function).
- Collector #32: Use difflib instead of ndiff
- Fixed long standing bug in PythonScript where get_size returned
......
......@@ -10,7 +10,7 @@ CO_VARKEYWORDS = 8
class MethodClass:
def fromFunction(self, func, interface=''):
def fromFunction(self, func, interface='', strip_first=0):
m=Method(func.__name__, func.__doc__)
defaults=func.func_defaults or ()
c=func.func_code
......@@ -18,15 +18,17 @@ class MethodClass:
names=c.co_varnames
d={}
nr=na-len(defaults)
if nr==0:
if strip_first and nr==0: # 'strip_first' implies method, has 'self'
defaults=defaults[1:]
nr=1
for i in range(len(defaults)):
d[names[i+nr]]=defaults[i]
m.positional=names[1:na]
m.required=names[1:nr]
start_index = strip_first and 1 or 0
m.positional=names[start_index:na]
m.required=names[start_index:nr]
m.optional=d
argno = na
......@@ -45,7 +47,7 @@ class MethodClass:
def fromMethod(self, meth, interface=''):
func = meth.im_func
return self.fromFunction(func, interface)
return self.fromFunction(func, interface, strip_first=1)
class Method(Attribute):
"""Method interfaces
......
......@@ -34,7 +34,7 @@ class BrowserIdManagerInterface(
visitors, and for servicing requests from Session Data Managers
related to the browser id.
"""
def encodeUrl(self, url):
def encodeUrl(url):
"""
Encodes a provided URL with the current request's browser id
and returns the result. For example, the call
......@@ -46,7 +46,7 @@ class BrowserIdManagerInterface(
Raises: BrowserIdManagerErr. If there is no current browser id.
"""
def getBrowserIdName(self):
def getBrowserIdName():
"""
Returns a string with the name of the cookie/form variable which is
used by the current browser id manager as the name to look up when
......@@ -55,7 +55,7 @@ class BrowserIdManagerInterface(
Permission required: Access contents information
"""
def getBrowserId(self, create=1):
def getBrowserId(create=1):
"""
If create=0, returns a the current browser id or None if there
is no browser id associated with the current request. If create=1,
......@@ -72,14 +72,14 @@ class BrowserIdManagerInterface(
is found in REQUEST.
"""
def hasBrowserId(self):
def hasBrowserId():
"""
Returns true if there is a browser id for this request.
Permission required: Access contents information
"""
def isBrowserIdNew(self):
def isBrowserIdNew():
"""
Returns true if browser id is 'new'. A browser id is 'new'
when it is first created and the client has therefore not sent it
......@@ -90,7 +90,7 @@ class BrowserIdManagerInterface(
Raises: BrowserIdManagerErr. If there is no current browser id.
"""
def isBrowserIdFromForm(self):
def isBrowserIdFromForm():
"""
Returns true if browser id comes from a form variable (query
string or post).
......@@ -100,7 +100,7 @@ class BrowserIdManagerInterface(
Raises: BrowserIdManagerErr. If there is no current browser id.
"""
def isBrowserIdFromCookie(self):
def isBrowserIdFromCookie():
"""
Returns true if browser id comes from a cookie.
......@@ -109,7 +109,7 @@ class BrowserIdManagerInterface(
Raises: BrowserIdManagerErr. If there is no current browser id.
"""
def flushBrowserIdCookie(self):
def flushBrowserIdCookie():
"""
Deletes the browser id cookie from the client browser, iff the
'cookies' browser id namespace is being used.
......@@ -120,7 +120,7 @@ class BrowserIdManagerInterface(
a browser id namespace at the time of the call.
"""
def setBrowserIdCookieByForce(self, bid):
def setBrowserIdCookieByForce(bid):
"""
Sets the browser id cookie to browser id 'bid' by force.
Useful when you need to 'chain' browser id cookies across domains
......@@ -143,7 +143,7 @@ class SessionDataManagerInterface(
related to Session Data Objects. It also communicates with a Browser
Id Manager to provide information about browser ids.
"""
def getBrowserIdManager(self):
def getBrowserIdManager():
"""
Returns the nearest acquirable browser id manager.
......@@ -152,7 +152,7 @@ class SessionDataManagerInterface(
Permission required: Access session data
"""
def getSessionData(self, create=1):
def getSessionData(create=1):
"""
Returns a Session Data Object associated with the current
browser id. If there is no current browser id, and create is true,
......@@ -162,7 +162,7 @@ class SessionDataManagerInterface(
Permission required: Access session data
"""
def hasSessionData(self):
def hasSessionData():
"""
Returns true if a Session Data Object associated with the
current browser id is found in the Session Data Container. Does
......@@ -171,7 +171,7 @@ class SessionDataManagerInterface(
Permission required: Access session data
"""
def getSessionDataByKey(self, key):
def getSessionDataByKey(key):
"""
Returns a Session Data Object associated with 'key'. If there is
no Session Data Object associated with 'key' return None.
......
......@@ -77,7 +77,7 @@ Transient Objects
import Interface
class Transient(Interface.Base):
def invalidate(self):
def invalidate():
"""
Invalidate (expire) the transient object.
......@@ -85,69 +85,69 @@ class Transient(Interface.Base):
related to this object to be called as a side effect.
"""
def isValid(self):
def isValid():
"""
Return true if transient object is still valid, false if not.
A transient object is valid if its invalidate method has not been
called.
"""
def getLastAccessed(self):
def getLastAccessed():
"""
Return the time the transient object was last accessed in
integer seconds-since-the-epoch form.
"""
def setLastAccessed(self):
def setLastAccessed():
"""
Cause the last accessed time to be set to now.
"""
def getCreated(self):
def getCreated():
"""
Return the time the transient object was created in integer
seconds-since-the-epoch form.
"""
def getContainerKey(self):
def getContainerKey():
"""
Return the key under which the object was placed in its
container.
"""
class DictionaryLike(Interface.Base):
def keys(self):
def keys():
"""
Return sequence of key elements.
"""
def values(self):
def values():
"""
Return sequence of value elements.
"""
def items(self):
def items():
"""
Return sequence of (key, value) elements.
"""
def get(self, k, default='marker'):
def get(k, default='marker'):
"""
Return value associated with key k. If k does not exist and default
is not marker, return default, else raise KeyError.
"""
def has_key(self, k):
def has_key(k):
"""
Return true if item referenced by key k exists.
"""
def clear(self):
def clear():
"""
Remove all key/value pairs.
"""
def update(self, d):
def update(d):
"""
Merge dictionary d into ourselves.
"""
......@@ -155,36 +155,36 @@ class DictionaryLike(Interface.Base):
# DictionaryLike does NOT support copy()
class ItemWithId(Interface.Base):
def getId(self):
def getId():
"""
Returns a meaningful unique id for the object. Note that this id
need not the key under which the object is stored in its container.
"""
class TTWDictionary(DictionaryLike, ItemWithId):
def set(self, k, v):
def set(k, v):
"""
Call __setitem__ with key k, value v.
"""
def delete(self, k):
def delete(k):
"""
Call __delitem__ with key k.
"""
def __guarded_setitem__(self, k, v):
def __guarded_setitem__(k, v):
"""
Call __setitem__ with key k, value v.
"""
class ImmutablyValuedMappingOfPickleableObjects(Interface.Base):
def __setitem__(self, k, v):
def __setitem__(k, v):
"""
Sets key k to value v, if k is both hashable and pickleable and
v is pickleable, else raise TypeError.
"""
def __getitem__(self, k):
def __getitem__(k):
"""
Returns the value associated with key k.
......@@ -195,7 +195,7 @@ class ImmutablyValuedMappingOfPickleableObjects(Interface.Base):
to the mapping via __setitem__.
"""
def __delitem__(self, k):
def __delitem__(k):
"""
Remove the key/value pair related to key k.
"""
......@@ -207,7 +207,7 @@ class HomogeneousItemContainer(Interface.Base):
2. Is responsible for the creation of its subobjects.
3. Allows for the access of a subobject by key.
"""
def get(self, k, default=None):
def get(k, default=None):
"""
Return value associated with key k via __getitem__. If value
associated with k does not exist, return default.
......@@ -216,14 +216,14 @@ class HomogeneousItemContainer(Interface.Base):
is passed in and returned.
"""
def has_key(self, k):
def has_key(k):
"""
Return true if container has value associated with key k, else
return false.
"""
class StringKeyedHomogeneousItemContainer(HomogeneousItemContainer):
def new(self, k):
def new(k):
"""
Creates a new subobject of the type supported by this container
with key "k" and returns it.
......@@ -239,7 +239,7 @@ class StringKeyedHomogeneousItemContainer(HomogeneousItemContainer):
Returned object is acquisition-wrapped in self.
"""
def new_or_existing(self, k):
def new_or_existing(k):
"""
If an object already exists in the container with key "k", it
is returned.
......@@ -256,24 +256,24 @@ class StringKeyedHomogeneousItemContainer(HomogeneousItemContainer):
"""
class TransientItemContainer(Interface.Base):
def setTimeoutMinutes(self, timeout_mins):
def setTimeoutMinutes(timeout_mins):
"""
Set the number of minutes of inactivity allowable for subobjects
before they expire.
"""
def getTimeoutMinutes(self):
def getTimeoutMinutes():
"""
Return the number of minutes allowed for subobject inactivity
before expiration.
"""
def getAddNotificationTarget(self):
def getAddNotificationTarget():
"""
Returns the currently registered 'add notification' value, or None.
"""
def setAddNotificationTarget(self, f):
def setAddNotificationTarget(f):
"""
Cause the 'add notification' function to be 'f'.
......@@ -290,13 +290,13 @@ class TransientItemContainer(Interface.Base):
print "id of 'item' arg was %s" % item.getId()
"""
def getDelNotificationTarget(self):
def getDelNotificationTarget():
"""
Returns the currently registered 'delete notification' value, or
None.
"""
def setDelNotificationTarget(self, f):
def setDelNotificationTarget(f):
"""
Cause the 'delete notification' function to be 'f'.
......
......@@ -5,7 +5,7 @@ class CatalogAware:
Description of the Item interface
"""
def creator(self):
def creator():
"""
Return a sequence of user names who have the local Owner role
......@@ -14,7 +14,7 @@ class CatalogAware:
"""
def summary(self, num=200):
def summary(num=200):
"""
Returns the summary of the text contents of the object (if
......@@ -22,7 +22,7 @@ class CatalogAware:
"""
def index_object(self):
def index_object():
"""
This object will try and catalog itself when this method is
......@@ -30,7 +30,7 @@ class CatalogAware:
"""
def unindex_object(self):
def unindex_object():
"""
This object will try and uncatalog itself when this method is
......@@ -38,7 +38,7 @@ class CatalogAware:
"""
def reindex_all(self, obj=None):
def reindex_all(obj=None):
"""
This method will cause this object to get reindexed. If this
......
......@@ -11,7 +11,7 @@
#
##############################################################################
__version__ = "$Revision: 1.5 $"[11:-2]
__version__ = "$Revision: 1.6 $"[11:-2]
import time, Interface, re
......@@ -21,7 +21,7 @@ class EtagBaseInterface(Interface.Base):
Basic Etag support interface, meaning the object supports generating
an Etag that can be used by certain HTTP and WebDAV Requests.
"""
def http__etag(self):
def http__etag():
"""\
Entity tags are used for comparing two or more entities from
the same requested resource. Predominantly used for Caching,
......@@ -37,7 +37,7 @@ class EtagBaseInterface(Interface.Base):
match the current Etag).
"""
def http__refreshEtag(self):
def http__refreshEtag():
"""\
While it may make sense to use the ZODB Object Id or
bobobase_modification_time to generate an Etag, this could
......
......@@ -11,7 +11,7 @@
#
##############################################################################
__version__='$Revision: 1.4 $'[11:-2]
__version__='$Revision: 1.5 $'[11:-2]
import Interface
......@@ -35,6 +35,7 @@ class LockItemInterface(Interface.Base):
"""
# XXX: WAAAA! What is a ctor doing in the interface?
def __init__(self, creator, owner, depth=0, timeout='Infinity',
locktype='write', lockscope='exclusive', token=None):
"""\
......@@ -68,36 +69,36 @@ class LockItemInterface(Interface.Base):
the object.
"""
def getCreator(self):
def getCreator():
""" Returns the Zope user who created the lock. This is returned
in a tuple containing the Users ID and the path to the user folder
they came from."""
def getCreatorPath(self):
def getCreatorPath():
""" Returns a string of the path to the user object in the user
folder they were found in. """
def getOwner(self):
def getOwner():
""" Returns the string value of the 'owner' property sent
in by WebDAV """
def getLockToken(self):
def getLockToken():
""" returns the opaque lock token """
def getDepth(self):
def getDepth():
""" returns the depth of the lock """
def getTimeout(self):
def getTimeout():
""" returns an integer value of the timeout setting """
def getTimeoutString(self):
def getTimeoutString():
""" returns the timeout value in a form acceptable by
WebDAV (ie - 'Seconds-40800') """
def setTimeout(self, newtimeout):
def setTimeout(newtimeout):
""" refreshes the timeout information """
def getModifiedTime(self):
def getModifiedTime():
""" returns a time.time value of the last time the Lock was
modified. From RFC 2518:
......@@ -108,13 +109,13 @@ class LockItemInterface(Interface.Base):
The modified time is used to calculate the refreshed value """
def refresh(self):
def refresh():
""" Tickles the locks modified time by setting it to the current
time.time() value. (As stated in the RFC, the timeout counter
SHOULD be restarted for any HTTP method called by the lock owner
on the locked object). """
def isValid(self):
def isValid():
""" Returns true if (self.getModifiedTime() + self.getTimeout())
is greater than the current time.time() value. """
# now = time.time()
......@@ -123,18 +124,18 @@ class LockItemInterface(Interface.Base):
#
# return (modified + timeout > now) # there's time remaining
def getLockType(self):
def getLockType():
""" returns the lock type ('write') """
def getLockScope(self):
def getLockScope():
""" returns the lock scope ('exclusive') """
def asLockDiscoveryProperty(self, ns='d'):
def asLockDiscoveryProperty(ns='d'):
""" Return the lock rendered as an XML representation of a
WebDAV 'lockdiscovery' property. 'ns' is the namespace identifier
used on the XML elements."""
def asXML(self):
def asXML():
""" Render a full XML representation of a lock for WebDAV,
used when returning the value of a newly created lock. """
......@@ -173,41 +174,41 @@ class WriteLockInterface(Interface.Base):
"""
def wl_lockItems(self, killinvalids=0):
def wl_lockItems(killinvalids=0):
""" Returns (key, value) pairs of locktoken, lock.
if 'killinvalids' is true, invalid locks (locks whose timeout
has been exceeded) will be deleted"""
def wl_lockValues(self, killinvalids=0):
def wl_lockValues(killinvalids=0):
""" Returns a sequence of locks. if 'killinvalids' is true,
invalid locks will be deleted"""
def wl_lockTokens(self, killinvalids=0):
def wl_lockTokens(killinvalids=0):
""" Returns a sequence of lock tokens. if 'killinvalids' is true,
invalid locks will be deleted"""
def wl_hasLock(self, token, killinvalids=0):
def wl_hasLock(token, killinvalids=0):
""" Returns true if the lock identified by the token is attached
to the object. """
def wl_isLocked(self):
def wl_isLocked():
""" Returns true if 'self' is locked at all. If invalid locks
still exist, they should be deleted."""
def wl_setLock(self, locktoken, lock):
def wl_setLock(locktoken, lock):
""" Store the LockItem, 'lock'. The locktoken will be used to fetch
and delete the lock. If the lock exists, this MUST
overwrite it if all of the values except for the 'timeout' on the
old and new lock are the same. """
def wl_getLock(self, locktoken):
def wl_getLock(locktoken):
""" Returns the locktoken identified by the locktokenuri """
def wl_delLock(self, locktoken):
def wl_delLock(locktoken):
""" Deletes the locktoken identified by the locktokenuri """
def wl_clearLocks(self):
def wl_clearLocks():
""" Deletes ALL DAV locks on the object - should only be called
by lock management machinery. """
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment