我目前正在开发一个内部使用的Django应用程序,它运行在本地网络中的一个服务器(服务器1),但是当数据保存到数据库时,需要对另一个服务器(服务器2)进行写访问。在
保存新记录时,Django在外部服务器(服务器2)上创建一个新目录,并使用适当的文件夹名。这在Django testserver上运行得很好,它似乎可以访问整个本地网络。在
我现在已经成功地用Apache和mod wsgi部署了Django应用程序,但是文件夹创建过程似乎不再起作用了。我试过一些方法,但似乎不能很快解决。有什么想法吗?这真的可以用Django和Apache实现吗?在def create_folder(self,request,obj,form, change, serverfolder, templatefolder):
try:
source_dir = templatefolder # Replace with path to project folder template
if not os.path.exists(destination_dir):
dir_util.copy_tree(source_dir,destination_dir)
obj.projectfolder = destination_dir
messages.success(request,"Project folder created on %s" % (serverfolder))
obj.create_folder = False
obj.has_folder = True
else:
messages.warning(request,"No new project folder created on %s server" % (obj.office.abbreviation))
except Exception,e:
messages.warning(request,str(e) + " Error during project folder creation on %s server!" % (obj.office.abbreviation))
def save_model(self, request, obj, form, change):
serverfolder = r'\\C-s-002\Projects' #C-s-002 is the external server in the same local network as the server on which Django is running
templatefolder = r'\\C-s-002\Projects\XXX Project Template'
self.create_folder(request,obj,form, change, serverfolder, templatefolder)