cubicweb.python.js

This file contains extensions for standard javascript types

Date.prototype.nextMonth()

returns the first day of the next month

Date.prototype.getRealDay()

returns the day of week, 0 being monday, 6 being sunday

cubicweb.python.js._parseDate(datestring, format)

_parseData does the actual parsing job needed by strptime

cubicweb.python.js.strptime(datestring, format)

basic implementation of strptime. The only recognized formats defined in _DATE_FORMAT_REGEXES (i.e. %Y, %d, %m, %H, %M)

String.prototype.startswith(prefix)

python-like startsWith method for js strings >>>

String.prototype.endswith(suffix)

python-like endsWith method for js strings

String.prototype.strip()

python-like strip method for js strings

String.prototype.rstrip()

python-like rstrip method for js strings

cubicweb.python.js.makeUnboundMethod(meth)

transforms a function into an unbound method

cubicweb.python.js._isAttrSkipped(attrname)

simple internal function that tells if the attribute should be copied from baseclasses or not

cubicweb.python.js.makeConstructor(userctor)

internal function used to build the class constructor

cubicweb.python.js.defclass(name, bases, classdict)

this is a js class factory. objects returned by this function behave more or less like a python class. The class function prototype is inspired by the python type builtin

注解

  • methods are _STATICALLY_ attached when the class it created

  • multiple inheritance was never tested, which means it doesn't work ;-)