SyncCode.py 4.97 KB
Newer Older
1
# -*- coding: utf-8 -*-
Jean-Paul Smets's avatar
Jean-Paul Smets committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
#          Sebastien Robin <seb@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################

30
from Products.ERP5Type.Accessor.TypeDefinition import list_types
31
from Products.ERP5Type.Globals import Persistent
32
import re
Jean-Paul Smets's avatar
Jean-Paul Smets committed
33

34 35
SYNCML_NAMESPACE = 'SYNCML:SYNCML1.2'

Jean-Paul Smets's avatar
Jean-Paul Smets committed
36 37 38 39 40 41 42
class SyncCode(Persistent):
  """
    Class giving the Synchronization's Constants
  """

  # SyncML Alert Codes
  TWO_WAY = 200
Sebastien Robin's avatar
Sebastien Robin committed
43
  SLOW_SYNC = 201 # This means we get the data from the publication
44
  ONE_WAY_FROM_SERVER = 204
Nicolas Delaby's avatar
Nicolas Delaby committed
45
  CODE_LIST = ( TWO_WAY, ONE_WAY_FROM_SERVER, )
Jean-Paul Smets's avatar
Jean-Paul Smets committed
46 47 48

  # SyncML Status Codes
  SUCCESS = 200
49
  ITEM_ADDED = 201
50 51
  WAITING_DATA = 214
  REFRESH_REQUIRED = 508
52

Jean-Paul Smets's avatar
Jean-Paul Smets committed
53 54 55 56 57 58
  CHUNK_OK = 214
  CONFLICT = 409 # A conflict is detected
  CONFLICT_MERGE = 207 # We have merged the two versions, sending
                       # whatever is needed to change(replace)
  CONFLICT_CLIENT_WIN = 208 # The client is the "winner", we keep
                            # the version of the client
Sebastien Robin's avatar
Sebastien Robin committed
59 60 61
  UNAUTHORIZED = 401
  AUTH_REQUIRED = 407
  AUTH_ACCEPTED = 212
Jean-Paul Smets's avatar
Jean-Paul Smets committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77

  # Difference between publication and subscription
  PUB = 1
  SUB = 0

  NULL_ANCHOR = '00000000T000000Z'

  # ERP5 Sync Codes
  SYNCHRONIZED = 1
  SENT = 2
  NOT_SENT = 3
  PARTIAL = 4
  NOT_SYNCHRONIZED = 5
  PUB_CONFLICT_MERGE = 6
  PUB_CONFLICT_CLIENT_WIN = 8

78
  MAX_LINES = 5000
79
  MAX_OBJECTS = 300
Jean-Paul Smets's avatar
Jean-Paul Smets committed
80

Sebastien Robin's avatar
Sebastien Robin committed
81
  action_tag = 'workflow_action'
82 83
  #NOT_EDITABLE_PROPERTY = ('id','object','uid','xupdate:element',action_tag,
  #                         'xupdate:attribute','local_role')
84 85 86 87
  XUPDATE_INSERT =        ('xupdate:insert-after','xupdate:insert-before')
  XUPDATE_ADD =           ('xupdate:append',)
  XUPDATE_DEL =           ('xupdate:remove',)
  XUPDATE_UPDATE =        ('xupdate:update',)
88
  XUPDATE_EL =        ('xupdate:element',)
89 90 91 92 93
  XUPDATE_INSERT_OR_ADD = tuple(XUPDATE_INSERT) + tuple(XUPDATE_ADD)
  XUPDATE_TAG = tuple(XUPDATE_INSERT) + tuple(XUPDATE_ADD) + \
                tuple(XUPDATE_UPDATE) + tuple(XUPDATE_DEL)
  text_type_list = ('text','string')
  list_type_list = list_types
94
  none_type = 'None'
95
  force_conflict_list = ('layout_and_schema','ModificationDate')
96
  binary_type_list = ('image','file','document','pickle')
97 98
  date_type_list = ('date',)
  dict_type_list = ('dict',)
Sebastien Robin's avatar
Sebastien Robin committed
99
  int_type_list = ('int',)
100
  pickle_type_list = ('object',)
101
  data_type_list = ('data',)
102
  xml_object_tag = 'object'
Sebastien Robin's avatar
Sebastien Robin committed
103 104
  #history_tag = 'workflow_history'
  history_tag = 'workflow_action'
105
  local_role_tag = 'local_role'
106 107
  local_permission_tag = 'local_permission'
  local_permission_list = (local_permission_tag,'/'+local_permission_tag)
108 109 110
  local_group_tag = 'local_group'
  local_role_list = (local_role_tag,'/'+local_role_tag,
                     local_group_tag,'/'+local_group_tag)
Sebastien Robin's avatar
Sebastien Robin committed
111
  ADDABLE_PROPERTY = local_role_list + (history_tag,) + local_permission_list
112 113
  NOT_EDITABLE_PROPERTY = ('id','object','uid','xupdate:attribute') \
                          + XUPDATE_EL + ADDABLE_PROPERTY
114 115 116 117 118 119
  sub_object_exp = re.compile("/object\[@id='.*'\]/")
  object_exp = re.compile("/object\[@id='.*'\]")
  attribute_type_exp = re.compile("^.*attribute::type$")
  sub_sub_object_exp = re.compile("/object\[@id='.*'\]/object\[@id='.*'\]/")
  history_exp = re.compile("/%s\[@id='.*'\]" % history_tag)
  bad_history_exp = re.compile("/%s\[@id='.*'\]/" % history_tag)
120 121 122 123 124 125

  #media types :

  MEDIA_TYPE = {}
  MEDIA_TYPE['TEXT_XML'] = 'text/xml'
  MEDIA_TYPE['TEXT_VCARD'] = 'text/vcard'
126 127 128 129 130 131
  MEDIA_TYPE['TEXT_XVCARD'] = 'text/x-vcard'

  #content types :
  CONTENT_TYPE = {}
  CONTENT_TYPE['SYNCML_XML'] = 'application/vnd.syncml+xml'
  CONTENT_TYPE['SYNCML_WBXML'] = 'application/vnd.syncml+wbxml'
Nicolas Delaby's avatar
Nicolas Delaby committed
132 133 134

  #Activity priority
  PRIORITY = 5
135 136 137 138 139 140 141

  #Namespace
  #In SyncML Representation Protocol OMA
  #we use URN as format of namespace
  # List namespaces supported
  URN_LIST = ('SYNCML:SYNCML1.1', 'SYNCML:SYNCML1.2')