Commit 919582f2 authored by Boxiang Sun's avatar Boxiang Sun

new Base_getattro implementation

parent 94873f41
......@@ -539,6 +539,9 @@ PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *) PYSTON_NOEXCEPT;
PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *) PYSTON_NOEXCEPT;
PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *) PYSTON_NOEXCEPT;
PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *) PYSTON_NOEXCEPT;
PyAPI_FUNC(PyObject *) PyObject_GetDict(PyObject *) PYSTON_NOEXCEPT;
PyAPI_FUNC(void) PyObject_ClearDict(PyObject *) PYSTON_NOEXCEPT;
PyAPI_FUNC(void) PyObject_SetDict(PyObject *, PyObject *) PYSTON_NOEXCEPT;
PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *) PYSTON_NOEXCEPT;
PyAPI_FUNC(PyObject *) _PyObject_NextNotImplemented(PyObject *) PYSTON_NOEXCEPT;
PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *) PYSTON_NOEXCEPT;
......
......@@ -590,9 +590,14 @@ extern "C" PyObject** _PyObject_GetDictPtr(PyObject* obj) noexcept {
Py_ssize_t dictoffset;
PyTypeObject* tp = Py_TYPE(obj);
// if (!(tp->tp_flags & Py_TPFLAGS_HAVE_CLASS))
// return NULL;
// dictoffset = tp->tp_dictoffset;
// if(dictoffset == 0)
// return NULL;
if (!tp->instancesHaveHCAttrs()) {
dictoffset = tp->tp_dictoffset;
if (dictoffset == 0)
if(dictoffset == 0)
return NULL;
if (dictoffset < 0) {
Py_ssize_t tsize;
......@@ -609,11 +614,44 @@ extern "C" PyObject** _PyObject_GetDictPtr(PyObject* obj) noexcept {
}
return (PyObject**)((char*)obj + dictoffset);
} else {
fatalOrError(PyExc_NotImplementedError, "unimplemented for hcattrs");
return nullptr;
// fatalOrError(PyExc_NotImplementedError, "unimplemented for hcattrs");
return &Py_None;
// return nullptr;
}
}
extern "C" PyObject* PyObject_GetDict(PyObject* obj) noexcept {
PyTypeObject* tp = Py_TYPE(obj);
if (!tp->instancesHaveHCAttrs()) {
if (!tp->instancesHaveDictAttrs())
return NULL;
return obj->getDict();
} else {
Box* attrwrapper = obj->getAttrWrapper();
// unwritable dict, this is just a copy of object's dict.
return attrwrapperToDict(attrwrapper);
// convertAttrwrapperToPrivateDict(attrwrapper);
// return unwrapAttrWrapper(attrwrapper);
}
}
extern "C" void PyObject_ClearDict(PyObject* obj) noexcept {
obj->clearAttrsForDealloc();
}
extern "C" void PyObject_SetDict(PyObject* obj, PyObject* dict) noexcept {
PyObject *d_key, *d_value;
Py_ssize_t i = 0;
while (PyDict_Next(dict, &i, &d_key, &d_value)) {
if (PyString_CheckExact(d_key)) {
Py_INCREF(d_key);
PyString_InternInPlace(&d_key);
Py_DECREF(d_key);
}
if (PyObject_SetAttr(obj, d_key, d_value) < 0)
return;
}
}
/* These methods are used to control infinite recursion in repr, str, print,
etc. Container objects that may recursively contain themselves,
e.g. builtin dictionaries and lists, should used Py_ReprEnter() and
......
......@@ -632,6 +632,161 @@ endlabel:
*/
}
/*
* Helpers for __dict__ descriptor. We don't want to expose the dicts
* inherited from various builtin types. The builtin base usually provides
* its own __dict__ descriptor, so we use that when we can.
*/
static PyTypeObject* get_builtin_base_with_dict(PyTypeObject* type) {
while (type->tp_base != NULL) {
if (type->tp_dictoffset != 0 && !(type->tp_flags & Py_TPFLAGS_HEAPTYPE))
return type;
type = type->tp_base;
}
return NULL;
}
static PyObject* get_dict_descriptor(PyTypeObject* type) {
static PyObject* dict_str;
PyObject* descr;
if (dict_str == NULL) {
dict_str = PyString_InternFromString("__dict__");
if (dict_str == NULL)
return NULL;
}
descr = _PyType_Lookup(type, dict_str);
if (descr == NULL || !PyDescr_IsData(descr))
return NULL;
return descr;
}
static void raise_dict_descr_error(PyObject* obj) {
PyErr_Format(PyExc_TypeError, "this __dict__ descriptor does not support "
"'%.200s' objects",
obj->cls->tp_name);
}
static PyObject* subtype_dict(PyObject* obj, void* context) {
PyObject** dictptr;
PyObject* dict;
PyTypeObject* base;
base = get_builtin_base_with_dict(obj->cls);
if (base != NULL) {
descrgetfunc func;
PyObject* descr = get_dict_descriptor(base);
if (descr == NULL) {
raise_dict_descr_error(obj);
return NULL;
}
func = descr->cls->tp_descr_get;
if (func == NULL) {
raise_dict_descr_error(obj);
return NULL;
}
return func(descr, obj, (PyObject*)(obj->cls));
}
dictptr = _PyObject_GetDictPtr(obj);
if (dictptr == NULL) {
PyErr_SetString(PyExc_AttributeError, "This object has no __dict__");
return NULL;
}
// Pyston change:
dict = PyObject_GetDict(obj);
if (dict == NULL) {
dict = PyDict_New();
PyObject_SetDict(obj, dict);
}
// dict = *dictptr;
// if (dict == NULL)
// *dictptr = dict = PyDict_New();
Py_XINCREF(dict);
return dict;
}
static int subtype_setdict(PyObject* obj, PyObject* value, void* context) {
PyObject** dictptr;
PyObject* dict;
PyTypeObject* base;
base = get_builtin_base_with_dict(obj->cls);
if (base != NULL) {
descrsetfunc func;
PyObject* descr = get_dict_descriptor(base);
if (descr == NULL) {
raise_dict_descr_error(obj);
return -1;
}
func = descr->cls->tp_descr_set;
if (func == NULL) {
raise_dict_descr_error(obj);
return -1;
}
return func(descr, obj, value);
}
dictptr = _PyObject_GetDictPtr(obj);
if (dictptr == NULL) {
PyErr_SetString(PyExc_AttributeError, "This object has no __dict__");
return -1;
}
if (value != NULL && !PyDict_Check(value)) {
PyErr_Format(PyExc_TypeError, "__dict__ must be set to a dictionary, "
"not a '%.200s'",
Py_TYPE(value)->tp_name);
return -1;
}
// Pyston change:
// we can't rely on _PyObject_GetDictPtr, it just check the object has __dict__ or not.
// I think we can't check it by see whether the object contains '__dict__' attributes.
dict = PyObject_GetDict(obj);
// dict = *dictptr;
Py_XINCREF(value);
// *dictptr = value;
PyObject_SetDict(obj, value);
Py_XDECREF(dict);
return 0;
}
static PyObject* subtype_getweakref(PyObject* obj, void* context) {
PyObject** weaklistptr;
PyObject* result;
if (Py_TYPE(obj)->tp_weaklistoffset == 0) {
PyErr_SetString(PyExc_AttributeError, "This object has no __weakref__");
return NULL;
}
assert(Py_TYPE(obj)->tp_weaklistoffset > 0);
assert(Py_TYPE(obj)->tp_weaklistoffset + sizeof(PyObject*) <= (size_t)(Py_TYPE(obj)->tp_basicsize));
weaklistptr = (PyObject**)((char*)obj + Py_TYPE(obj)->tp_weaklistoffset);
if (*weaklistptr == NULL)
result = Py_None;
else
result = *weaklistptr;
Py_INCREF(result);
return result;
}
/* Three variants on the subtype_getsets list. */
static PyGetSetDef subtype_getsets_full[]
= { { "__dict__", subtype_dict, subtype_setdict, PyDoc_STR("dictionary for instance variables (if defined)"), 0 },
{ "__weakref__", subtype_getweakref, NULL, PyDoc_STR("list of weak references to the object (if defined)"), 0 },
{ 0, 0, 0, 0, 0 } };
static PyGetSetDef subtype_getsets_dict_only[]
= { { "__dict__", subtype_dict, subtype_setdict, PyDoc_STR("dictionary for instance variables (if defined)"), 0 },
{ 0, 0, 0, 0, 0 } };
static PyGetSetDef subtype_getsets_weakref_only[]
= { { "__weakref__", subtype_getweakref, NULL, PyDoc_STR("list of weak references to the object (if defined)"), 0 },
{ 0, 0, 0, 0, 0 } };
void BoxedClass::freeze() {
assert(!is_constant);
assert(tp_name); // otherwise debugging will be very hard
......@@ -7109,6 +7264,7 @@ Box* _typeNew(BoxedClass* metatype, BoxedString* name, BoxedTuple* bases, BoxedD
RELEASE_ASSERT(classes.back() == made, "");
classes.pop_back();
if (boxedSlots) {
// Set ht_slots
BoxedTuple* slotsTuple = BoxedTuple::create(final_slot_names.size());
......@@ -7135,12 +7291,21 @@ Box* _typeNew(BoxedClass* metatype, BoxedString* name, BoxedTuple* bases, BoxedD
assert(!final_slot_names.size()); // would need to decref them here
}
if ((made->instancesHaveHCAttrs() || made->instancesHaveDictAttrs())
&& !(base->instancesHaveHCAttrs() || base->instancesHaveDictAttrs())) {
// if ((made->instancesHaveHCAttrs() || made->instancesHaveDictAttrs())
// && !(base->instancesHaveHCAttrs() || base->instancesHaveDictAttrs())) {
if (!(base->instancesHaveHCAttrs() || base->instancesHaveDictAttrs())) {
// We shouldn't be adding dict attrs to anything that didn't already have them:
assert(!made->instancesHaveDictAttrs());
// if (weaklist_offset && attrs_offset)
// made->tp_getset = subtype_getsets_full;
// else if (weaklist_offset && attrs_offset)
// made->tp_getset = subtype_getsets_weakref_only;
// else if (!weaklist_offset && attrs_offset)
// made->tp_getset = subtype_getsets_dict_only;
// else
// made->tp_getset = NULL;
static BoxedString* dict_str = getStaticString("__dict__");
made->setattr(dict_str, dict_descr, NULL);
}
......
......@@ -1385,16 +1385,112 @@ static Box* type_dict(Box* obj, void* context) noexcept {
abort();
}
/*
* Helpers for __dict__ descriptor. We don't want to expose the dicts
* inherited from various builtin types. The builtin base usually provides
* its own __dict__ descriptor, so we use that when we can.
*/
static PyTypeObject* get_builtin_base_with_dict(PyTypeObject* type) {
while (type->tp_base != NULL) {
if (type->tp_dictoffset != 0 && !(type->tp_flags & Py_TPFLAGS_HEAPTYPE))
return type;
type = type->tp_base;
}
return NULL;
}
static PyObject* get_dict_descriptor(PyTypeObject* type) {
static PyObject* dict_str;
PyObject* descr;
if (dict_str == NULL) {
dict_str = PyString_InternFromString("__dict__");
if (dict_str == NULL)
return NULL;
}
descr = _PyType_Lookup(type, dict_str);
if (descr == NULL || !PyDescr_IsData(descr))
return NULL;
return descr;
}
static void raise_dict_descr_error(PyObject* obj) {
PyErr_Format(PyExc_TypeError, "this __dict__ descriptor does not support "
"'%.200s' objects",
obj->cls->tp_name);
}
static Box* type_sub_dict(Box* obj, void* context) noexcept {
// This should only be getting called for hc-backed classes:
assert(obj->cls->instancesHaveHCAttrs());
// assert(obj->cls->instancesHaveHCAttrs());
PyObject** dictptr;
PyObject* dict;
PyTypeObject* base;
if (!obj->cls->instancesHaveHCAttrs() && !obj->cls->instancesHaveDictAttrs()) {
// raiseExcHelper(AttributeError, "This object has no __dict__");
PyErr_SetString(PyExc_AttributeError, "This object has no __dict__");
return NULL;
}
// base = get_builtin_base_with_dict(obj->cls);
// if (base != NULL) {
// descrgetfunc func;
// PyObject* descr = get_dict_descriptor(base);
// if (descr == NULL) {
// raise_dict_descr_error(obj);
// return NULL;
// }
// func = descr->cls->tp_descr_get;
// if (func == NULL) {
// raise_dict_descr_error(obj);
// return NULL;
// }
// return func(descr, obj, (PyObject*)(obj->cls));
// }
//
// dictptr = _PyObject_GetDictPtr(obj);
// if (dictptr == NULL) {
// PyErr_SetString(PyExc_AttributeError, "This object has no __dict__");
// return NULL;
// }
return incref(obj->getAttrWrapper());
}
static int type_sub_set_dict(BORROWED(Box*) obj, BORROWED(Box*) val, void* context) noexcept {
// This should only be getting called for hc-backed classes:
assert(obj->cls->instancesHaveHCAttrs());
// assert(obj->cls->instancesHaveHCAttrs());
// PyObject** dictptr;
// PyObject* dict;
// PyTypeObject* base;
if (!obj->cls->instancesHaveHCAttrs() && !obj->cls->instancesHaveDictAttrs()) {
PyErr_SetString(PyExc_AttributeError, "This object has no __dict__");
return -1;
// raiseExcHelper(AttributeError, "This object has no __dict__");
}
// base = get_builtin_base_with_dict(obj->cls);
// if (base != NULL) {
// descrgetfunc func;
// PyObject* descr = get_dict_descriptor(base);
// if (descr == NULL) {
// raise_dict_descr_error(obj);
// return -1;
// }
// func = descr->cls->tp_descr_get;
// if (func == NULL) {
// raise_dict_descr_error(obj);
// return -1;
// }
// return func(descr, obj, (PyObject*)(obj->cls));
// }
// if (val != NULL && !PyDict_Check(val) && !(val->cls != attrwrapper_cls)) {
// raiseExcHelper(TypeError, "__dict__ must be set to a dictionary, not a '%s'", val->cls->tp_name);
// }
Py_INCREF(val);
obj->setDictBacked(val);
......
wget https://pypi.python.org/packages/source/Z/Zope2/Zope2-2.13.24.tar.gz
wget https://pypi.python.org/packages/source/P/Products.StandardCacheManagers/Products.StandardCacheManagers-2.13.1.tar.gz
wget https://pypi.python.org/packages/source/P/Products.PythonScripts/Products.PythonScripts-2.13.2.zip
wget https://pypi.python.org/packages/source/P/Products.MIMETools/Products.MIMETools-2.13.0.zip
wget https://pypi.python.org/packages/source/P/Products.MailHost/Products.MailHost-2.13.2.zip
wget https://pypi.python.org/packages/source/P/Products.ExternalMethod/Products.ExternalMethod-2.13.1.zip
wget https://pypi.python.org/packages/source/P/Products.BTreeFolder2/Products.BTreeFolder2-2.13.5.tar.gz
wget https://pypi.python.org/packages/source/z/zope.viewlet/zope.viewlet-3.7.2.tar.gz
wget https://pypi.python.org/packages/source/z/zope.traversing/zope.traversing-3.13.2.zip
wget https://pypi.python.org/packages/source/z/zope.testing/zope.testing-3.9.7.tar.gz
wget https://pypi.python.org/packages/source/z/zope.testbrowser/zope.testbrowser-3.11.1.tar.gz
wget https://pypi.python.org/packages/source/z/zope.tales/zope.tales-3.5.3.tar.gz
wget https://pypi.python.org/packages/source/z/zope.tal/zope.tal-3.5.2.zip
wget https://pypi.python.org/packages/source/z/zope.structuredtext/zope.structuredtext-3.5.1.tar.gz
wget https://pypi.python.org/packages/source/z/zope.size/zope.size-3.4.1.tar.gz
wget https://pypi.python.org/packages/source/z/zope.site/zope.site-3.9.2.tar.gz
wget https://pypi.python.org/packages/source/z/zope.sequencesort/zope.sequencesort-3.4.0.tar.gz
wget https://pypi.python.org/packages/source/z/zope.sendmail/zope.sendmail-3.7.5.tar.gz
wget https://pypi.python.org/packages/source/z/zope.security/zope.security-3.7.4.tar.gz
wget https://pypi.python.org/packages/source/z/zope.schema/zope.schema-3.7.1.tar.gz
wget https://pypi.python.org/packages/source/z/zope.publisher/zope.publisher-3.12.6.tar.gz
wget https://pypi.python.org/packages/source/z/zope.ptresource/zope.ptresource-3.9.0.tar.gz
wget https://pypi.python.org/packages/source/z/zope.proxy/zope.proxy-3.6.1.zip
wget https://pypi.python.org/packages/source/z/zope.processlifetime/zope.processlifetime-1.0.tar.gz
wget https://pypi.python.org/packages/source/z/zope.pagetemplate/zope.pagetemplate-3.5.2.tar.gz
wget https://pypi.python.org/packages/source/z/zope.location/zope.location-3.9.1.tar.gz
wget https://pypi.python.org/packages/source/z/zope.lifecycleevent/zope.lifecycleevent-3.6.2.tar.gz
wget https://pypi.python.org/packages/source/z/zope.interface/zope.interface-3.6.7.zip
wget https://pypi.python.org/packages/source/z/zope.i18nmessageid/zope.i18nmessageid-3.5.3.tar.gz
wget https://pypi.python.org/packages/source/z/zope.i18n/zope.i18n-3.7.4.tar.gz
wget https://pypi.python.org/packages/source/z/zope.exceptions/zope.exceptions-3.6.2.tar.gz
wget https://pypi.python.org/packages/source/z/zope.event/zope.event-3.5.2.tar.gz
wget https://pypi.python.org/packages/source/z/zope.deferredimport/zope.deferredimport-3.5.3.tar.gz
wget https://pypi.python.org/packages/source/z/zope.contenttype/zope.contenttype-3.5.5.zip
wget https://pypi.python.org/packages/source/z/zope.contentprovider/zope.contentprovider-3.7.2.tar.gz
wget https://pypi.python.org/packages/source/z/zope.container/zope.container-3.11.2.tar.gz
wget https://pypi.python.org/packages/source/z/zope.configuration/zope.configuration-3.7.4.zip
wget https://pypi.python.org/packages/source/z/zope.component/zope.component-3.9.5.tar.gz
wget https://pypi.python.org/packages/source/z/zope.browserresource/zope.browserresource-3.10.3.zip
wget https://pypi.python.org/packages/source/z/zope.browserpage/zope.browserpage-3.12.2.tar.gz
wget https://pypi.python.org/packages/source/z/zope.browsermenu/zope.browsermenu-3.9.1.zip
wget https://pypi.python.org/packages/source/z/zope.browser/zope.browser-1.3.zip
wget https://pypi.python.org/packages/source/z/zLOG/zLOG-2.11.2.tar.gz
wget https://pypi.python.org/packages/source/z/zExceptions/zExceptions-2.13.0.zip
wget https://pypi.python.org/packages/source/z/zdaemon/zdaemon-2.0.7.tar.gz
wget https://pypi.python.org/packages/source/t/transaction/transaction-1.1.1.tar.gz
wget https://pypi.python.org/packages/source/t/tempstorage/tempstorage-2.12.2.zip
wget https://pypi.python.org/packages/2.7/p/pytz/pytz-2015.7-py2.7.egg
wget https://pypi.python.org/packages/source/i/initgroups/initgroups-2.13.0.zip
wget https://pypi.python.org/packages/source/d/docutils/docutils-0.12.tar.gz
wget https://pypi.python.org/packages/source/Z/ZopeUndo/ZopeUndo-2.12.0.zip
wget https://pypi.python.org/packages/source/Z/ZODB3/ZODB3-3.10.5.tar.gz
wget https://pypi.python.org/packages/source/Z/ZConfig/ZConfig-2.9.3.tar.gz
wget https://pypi.python.org/packages/source/R/RestrictedPython/RestrictedPython-3.6.0.zip
wget https://pypi.python.org/packages/source/R/Record/Record-2.13.0.zip
wget https://pypi.python.org/packages/source/P/Products.ZCTextIndex/Products.ZCTextIndex-2.13.5.zip
wget https://pypi.python.org/packages/source/P/Products.ZCatalog/Products.ZCatalog-2.13.27.zip
wget https://pypi.python.org/packages/source/P/Products.OFSP/Products.OFSP-2.13.2.zip
wget https://pypi.python.org/packages/source/P/Persistence/Persistence-2.13.2.zip
wget https://pypi.python.org/packages/source/M/MultiMapping/MultiMapping-2.13.0.zip
wget https://pypi.python.org/packages/source/M/Missing/Missing-2.13.1.zip
wget https://pypi.python.org/packages/source/E/ExtensionClass/ExtensionClass-2.13.2.zip
wget https://pypi.python.org/packages/source/D/DocumentTemplate/DocumentTemplate-2.13.2.zip
wget https://pypi.python.org/packages/source/D/DateTime/DateTime-2.12.8.tar.gz
wget https://pypi.python.org/packages/source/A/Acquisition/Acquisition-2.13.9.tar.gz
wget https://pypi.python.org/packages/source/A/AccessControl/AccessControl-2.13.14.tar.gz
wget https://pypi.python.org/packages/source/m/mechanize/mechanize-0.2.5.zip
wget https://pypi.python.org/packages/source/z/zope.annotation/zope.annotation-3.5.0.tar.gz
wget https://pypi.python.org/packages/source/z/zope.broken/zope.broken-3.6.0.zip
wget https://pypi.python.org/packages/source/z/zope.filerepresentation/zope.filerepresentation-3.6.1.tar.gz
wget https://pypi.python.org/packages/source/z/zope.dottedname/zope.dottedname-3.4.6.tar.gz
wget https://pypi.python.org/packages/source/z/zc.lockfile/zc.lockfile-1.0.2.tar.gz
# skip-if: True
import os
import sys
import subprocess
sys.path.append(os.path.dirname(__file__) + "/../lib")
from test_helper import run_test
"""
Using this test file.
The /bin/python is the pyston executable so if you recompile pyston, you need to run this
script again to update it.
"""
def print_progress_header(text):
print "\n>>>"
print ">>> " + text + "..."
print ">>>"
ENV_NAME = "zope_test_env_" + os.path.basename(sys.executable)
DEPENDENCIES = ["nose==1.3.7", "six"]
SRC_DIR = ENV_NAME
PYTHON_EXE = os.path.abspath(ENV_NAME + "/bin/python")
EASY_INSTALL_EXE = os.path.abspath(ENV_NAME + "/bin/easy_install")
MK_ZOPE_INSTANCE_EXE = os.path.abspath(ENV_NAME + "/bin/mkzopeinstance")
HOME_DIR = os.path.expanduser('~')
ZOPE_DIR = HOME_DIR + '/Zope-2.13.24-pakcages'
ZOPE_ENV_PATH = os.path.abspath(ENV_NAME)
INSTANCE_DIR = os.path.abspath(ENV_NAME + "/instance")
def creat_zope_virtual_dir():
if not os.path.exists(ENV_NAME) or os.stat(sys.executable).st_mtime > os.stat(ENV_NAME + "/bin/python").st_mtime:
print "Creating virtualenv to install testing dependencies..."
VIRTUALENV_SCRIPT = os.path.dirname(__file__) + "/../lib/virtualenv/virtualenv.py"
try:
args = [sys.executable, VIRTUALENV_SCRIPT, "-p", sys.executable, ENV_NAME]
print "Running", args
subprocess.check_call(args)
subprocess.check_call([ENV_NAME + "/bin/pip", "install"] + DEPENDENCIES)
except:
print "Error occurred; trying to remove partially-created directory"
ei = sys.exc_info()
try:
subprocess.check_call(["rm", "-rf", ENV_NAME])
except Exception as e:
print e
raise ei[0], ei[1], ei[2]
import shutil
def mk_ZOPE_DIR():
# Make sure we are in a clean dir.
if os.path.exists(ZOPE_DIR):
shutil.rmtree(ZOPE_DIR)
os.makedirs(ZOPE_DIR)
# ********************************
# ********************************
# **** Modified Zope Packages ****
# ********************************
# ********************************
modified_list = [
("Acquisition-2.13.9", "https://lab.nexedi.com/Daetalus/Acquisition-2.13.9/repository/archive.zip?ref=python_implementation"),
("AccessControl-2.13.14", "https://lab.nexedi.com/Daetalus/AccessControl-2.13.14/repository/archive.zip?ref=python_implementation"),
("ExtensionClass-2.13.2", "https://lab.nexedi.com/Daetalus/ExtensionClass-2.13.2/repository/archive.zip?ref=pyston_patch"),
("zope.container-3.11.2", "https://lab.nexedi.com/Daetalus/zope.container-3.11.2/repository/archive.zip?ref=master"),
("zope.proxy-3.6.1", "https://lab.nexedi.com/Daetalus/zope.proxy-3.6.1/repository/archive.zip?ref=master"),
("zope.security-3.7.4", "https://lab.nexedi.com/Daetalus/zope.security-3.7.4/repository/archive.zip?ref=master"),
("DocumentTemplate-2.13.2", "https://lab.nexedi.com/Daetalus/DocumentTemplate-2.13.2/repository/archive.zip?ref=master"),
("RestrictedPython-3.6.0", "https://lab.nexedi.com/Daetalus/RestrictedPython-3.6.0/repository/archive.zip?ref=master"),
("ZODB3-3.10.5", "https://lab.nexedi.com/Daetalus/ZODB3-3.10.5/repository/archive.zip?ref=pyston_patch"),
("Zope2-2.13.24", "https://lab.nexedi.com/Daetalus/Zope2-2.13.24/repository/archive.zip?ref=python_implementation"),]
# Download zope packages except the packages listed in modified_list
zope_packages = open(os.path.dirname(__file__) + "/getZope.sh")
zope_download_list = zope_packages.read().splitlines()
m_pkg_link = []
um_pkg_link = []
for each_pkg in zope_download_list:
modified = None
for modified_pkg in modified_list:
pkg_name = modified_pkg[0]
pkg_link = modified_pkg[1]
a = pkg_name in each_pkg
if pkg_name in each_pkg:
modified = modified_pkg
m_link = ''.join(['wget ', pkg_link, ' -O ', pkg_name, '.zip'])
m_pkg_link.append(m_link)
break
if modified is None:
um_pkg_link.append(each_pkg)
else:
modified_list.remove(modified)
# print(zope_download_list)
# print(um_pkg_link)
print(len(zope_download_list))
print(len(um_pkg_link))
print(m_pkg_link)
# the package list is something like
# ['wget url', 'wget url'...]
def download_zope_packages(package_list):
for each_line in package_list:
commands = each_line.split(' ')
subprocess.check_call(commands, cwd=ZOPE_DIR)
def createZopeInstance():
try:
print_progress_header("Creating Zope instance")
commands = [MK_ZOPE_INSTANCE_EXE, '-d', INSTANCE_DIR, '-u', 'nexedi:270']
print(commands)
subprocess.check_call(commands, cwd=ZOPE_ENV_PATH)
except:
raise
def buildZope():
try:
print_progress_header("Building Zope packages")
commands = [EASY_INSTALL_EXE, '-H', 'None', '-i', ZOPE_DIR, 'Zope2']
# print(ZOPE_DIR)
# print(ZOPE_ENV_PATH)
# print(EASY_INSTALL_EXE)
subprocess.check_call(commands, cwd=ZOPE_ENV_PATH)
except:
raise
creat_zope_virtual_dir()
# mk_ZOPE_DIR()
# download_zope_packages(um_pkg_link)
download_zope_packages(m_pkg_link)
buildZope()
createZopeInstance()
print("Passed")
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